[CP-stable]Remove build configuration mismatch warning (#174725)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

https://github.com/flutter/flutter/issues/174015

### Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples

Removes obsolete warning and error message when switching between build mode through Xcode.

### Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)

When building through Xcode, if you previously ran from a different build mode (debug, profile, release), it will show a warning (or error if archiving) that you need to run a Flutter command to have the correct build settings. This is no longer required.

### Workaround:
Is there a workaround for this issue?

Run the command the warning/error provides.

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

### Validation Steps:
What are the steps to validate that this fix works?

1. flutter build ios --release
2. Run in Xcode (debug mode)
3. See there is no warning
This commit is contained in:
flutteractionsbot 2025-09-03 09:18:09 -07:00 committed by GitHub
parent e9f7d4b533
commit 0abdca4ecc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 0 additions and 793 deletions

View File

@ -540,8 +540,6 @@ class Context {
final String buildMode = parseFlutterBuildMode();
_validateBuildMode(platform, buildMode);
final List<String> flutterArgs = _generateFlutterArgsForAssemble(
command: 'build',
buildMode: buildMode,
@ -570,53 +568,6 @@ class Context {
echo('Project $projectPath built and packaged successfully.');
}
/// Validate that the build mode targeted matches the build mode set by the
/// Flutter CLI.
/// If it doesn't match, print a warning unless the Xcode action is `install`,
/// which means the app is being archived for distribution. In that case, print
/// an error and fail the build.
///
/// The targeted build mode might not match the one set by Flutter CLI when it
/// is changed and ran directly through Xcode.
///
/// Flutter may change settings or files depending on the build mode. For
/// example, dev dependencies are excluded from release builds and requires
/// the Flutter CLI to update certain files.
void _validateBuildMode(TargetPlatform platform, String currentBuildMode) {
final String? buildModeCLILastUsed = environment['FLUTTER_CLI_BUILD_MODE'];
// Also fail the build if ACTION=install, which indicates the app is being
// built for distribution.
final String? action = environment['ACTION'];
final fatal = action == 'install';
if (buildModeCLILastUsed == null) {
final message =
'Your Flutter build settings are outdated. Please run '
'"flutter build ${platform.name} --config-only --$currentBuildMode" in your Flutter '
'project and try again.\n';
if (fatal) {
echoXcodeError(message);
exitApp(-1);
} else {
echoXcodeWarning(message);
return;
}
}
if (currentBuildMode != buildModeCLILastUsed) {
final message =
'Your Flutter project is currently configured for $buildModeCLILastUsed mode. '
'Please run `flutter build ${platform.name} --config-only --$currentBuildMode` '
'in your Flutter project to update your settings.\n';
if (fatal) {
echoXcodeError(message);
exitApp(-1);
} else {
echoXcodeWarning(message);
}
}
}
List<String> _generateFlutterArgsForAssemble({
required String command,
required String buildMode,

View File

@ -180,9 +180,6 @@ Future<List<String>> _xcodeBuildSettingsLines({
parsedBuildNumber(manifest: project.manifest, buildInfo: buildInfo) ?? '1';
xcodeBuildSettings.add('FLUTTER_BUILD_NUMBER=$buildNumber');
// The current build mode being targeted.
xcodeBuildSettings.add('FLUTTER_CLI_BUILD_MODE=${buildInfo.mode.cliName}');
// CoreDevices in debug and profile mode are launched, but not built, via Xcode.
// Set the CONFIGURATION_BUILD_DIR so Xcode knows where to find the app
// bundle to launch.

View File

@ -103,7 +103,6 @@ void main() {
'CONFIGURATION': buildMode,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -191,7 +190,6 @@ void main() {
'TREE_SHAKE_ICONS': treeShake,
'SRCROOT': srcRoot,
'TARGET_DEVICE_OS_VERSION': iOSVersion,
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -234,137 +232,6 @@ void main() {
expect(context.stdout, contains('built and packaged successfully.'));
expect(context.stderr, isEmpty);
});
test(
'exits with useful error message when missing FLUTTER_CLI_BUILD_MODE during archive',
() {
final Directory buildDir = fileSystem.directory('/path/to/builds')
..createSync(recursive: true);
final Directory flutterRoot = fileSystem.directory('/path/to/flutter')
..createSync(recursive: true);
const buildMode = 'Release';
final context = TestContext(
<String>['build', platformName],
<String, String>{
'ACTION': 'install',
'CONFIGURATION': buildMode,
'BUILT_PRODUCTS_DIR': buildDir.path,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
},
commands: <FakeCommand>[],
fileSystem: fileSystem,
);
expect(() => context.run(), throwsException);
expect(
context.stderr,
contains(
'error: Your Flutter build settings are outdated. '
'Please run "flutter build ${platform.name} --config-only --release" '
'in your Flutter project and try again.',
),
);
},
);
test('exits with useful error message when build mode mismatches during archive', () {
final Directory buildDir = fileSystem.directory('/path/to/builds')
..createSync(recursive: true);
final Directory flutterRoot = fileSystem.directory('/path/to/flutter')
..createSync(recursive: true);
const buildMode = 'Release';
final context = TestContext(
<String>['build', platformName],
<String, String>{
'ACTION': 'install',
'CONFIGURATION': buildMode,
'BUILT_PRODUCTS_DIR': buildDir.path,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
'FLUTTER_CLI_BUILD_MODE': 'debug',
},
commands: <FakeCommand>[],
fileSystem: fileSystem,
);
expect(() => context.run(), throwsException);
expect(
context.stderr,
contains(
'error: Your Flutter project is currently configured for debug mode. '
'Please run `flutter build ${platform.name} --config-only --release` '
'in your Flutter project to update your settings.',
),
);
});
test('prints useful warning message when missing FLUTTER_CLI_BUILD_MODE', () {
final Directory buildDir = fileSystem.directory('/path/to/builds')
..createSync(recursive: true);
final Directory flutterRoot = fileSystem.directory('/path/to/flutter')
..createSync(recursive: true);
const buildMode = 'Release';
final context = TestContext(
<String>['build', platformName],
<String, String>{
'ACTION': 'build',
'CONFIGURATION': buildMode,
'BUILT_PRODUCTS_DIR': buildDir.path,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
},
commands: <FakeCommand>[],
fileSystem: fileSystem,
fakeProcessManager: FakeProcessManager.any(),
);
context.run();
expect(
context.stderr,
contains(
'warning: Your Flutter build settings are outdated. '
'Please run "flutter build ${platform.name} --config-only --release" '
'in your Flutter project and try again.',
),
);
});
test('prints useful warning message when build mode mismatches', () {
final Directory buildDir = fileSystem.directory('/path/to/builds')
..createSync(recursive: true);
final Directory flutterRoot = fileSystem.directory('/path/to/flutter')
..createSync(recursive: true);
const buildMode = 'Release';
final context = TestContext(
<String>['build', platformName],
<String, String>{
'ACTION': 'debug',
'CONFIGURATION': buildMode,
'BUILT_PRODUCTS_DIR': buildDir.path,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
'FLUTTER_CLI_BUILD_MODE': 'debug',
},
commands: <FakeCommand>[],
fileSystem: fileSystem,
fakeProcessManager: FakeProcessManager.any(),
);
context.run();
expect(
context.stderr,
contains(
'warning: Your Flutter project is currently configured for debug mode. '
'Please run `flutter build ${platform.name} --config-only --release` '
'in your Flutter project to update your settings.',
),
);
});
});
}
@ -557,7 +424,6 @@ void main() {
'BUILT_PRODUCTS_DIR': buildDir.path,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -609,7 +475,6 @@ void main() {
'CONFIGURATION': buildMode,
'FLUTTER_ROOT': flutterRoot.path,
'INFOPLIST_PATH': 'Info.plist',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -689,7 +554,6 @@ void main() {
'TREE_SHAKE_ICONS': treeShake,
'SRCROOT': srcRoot,
'TARGET_DEVICE_OS_VERSION': iOSVersion,
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -747,7 +611,6 @@ void main() {
'ARCHS': 'arm64 x86_64',
'ONLY_ACTIVE_ARCH': 'YES',
'NATIVE_ARCH': 'arm64e',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -802,7 +665,6 @@ void main() {
'ARCHS': 'arm64',
'ONLY_ACTIVE_ARCH': 'YES',
'NATIVE_ARCH': 'x86_64',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(
@ -856,7 +718,6 @@ void main() {
'INFOPLIST_PATH': 'Info.plist',
'ARCHS': 'arm64 x86_64',
'NATIVE_ARCH': 'arm64e',
'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(),
},
commands: <FakeCommand>[
FakeCommand(

View File

@ -54,20 +54,6 @@ void main() {
await expectXcodeBackendFails(unknownFlutterBuildMode);
}, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
test('Xcode backend warns archiving a non-release build.', () async {
final ProcessResult result = await Process.run(
xcodeBackendPath,
<String>['build'],
environment: <String, String>{
'CONFIGURATION': 'Debug',
'ACTION': 'install',
'FLUTTER_CLI_BUILD_MODE': 'debug',
},
);
expect(result.stderr, contains('warning: Flutter archive not built in Release mode.'));
expect(result.exitCode, isNot(0));
}, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
test('Xcode backend warns when unable to determine platform', () async {
final ProcessResult result = await Process.run(
xcodeBackendPath,

View File

@ -1,588 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import '../src/common.dart';
import 'test_utils.dart';
void main() {
late Directory tempDir;
late Directory projectDir;
setUpAll(() async {
tempDir = createResolvedTempDirectorySync('xcode_dev_dependencies_test.');
projectDir = tempDir.childDirectory('project')..createSync();
final Directory tempPluginADir = tempDir.childDirectory('plugin_a')..createSync();
// Create a Flutter project.
await processManager.run(<String>[
flutterBin,
'create',
projectDir.path,
'--project-name=testapp',
], workingDirectory: projectDir.path);
// Create a Flutter plugin to add as a dev dependency to the Flutter project.
await processManager.run(<String>[
flutterBin,
'create',
tempPluginADir.path,
'--template=plugin',
'--project-name=plugin_a',
'--platforms=ios,macos',
], workingDirectory: tempPluginADir.path);
// Add a dev dependency on plugin_a
await processManager.run(<String>[
flutterBin,
'pub',
'add',
'dev:plugin_a',
'--path',
tempPluginADir.path,
], workingDirectory: projectDir.path);
});
tearDownAll(() {
tryToDelete(tempDir);
});
group(
'Xcode build iOS app',
() {
test(
'succeeds when Flutter CLI last used configuration matches Xcode configuration',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'generic/platform=iOS Simulator',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(xcodeResult, const ProcessResultMatcher(stdoutPattern: '** BUILD SUCCEEDED **'));
},
);
test(
'fails if Flutter CLI last used configuration does not match Xcode configuration when archiving',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'archive',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Release',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
exitCode: 65,
stdoutPattern: 'error: Your Flutter project is currently configured for debug mode.',
stderrPattern: '** ARCHIVE FAILED **',
),
);
},
);
test(
'warns if Flutter CLI last used configuration does not match Xcode configuration when building',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--release',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
stdoutPattern:
'warning: Your Flutter project is currently configured for release mode.',
),
);
},
);
},
skip: !platform.isMacOS, // [intended] iOS builds only work on macos.
);
group(
'Xcode build iOS module',
() {
test(
'succeeds when Flutter CLI last used configuration matches Xcode configuration',
() async {
final Directory moduleDirectory = projectDir.childDirectory('hello');
await processManager.run(<String>[
flutterBin,
'create',
moduleDirectory.path,
'--template=module',
'--project-name=hello',
], workingDirectory: projectDir.path);
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: moduleDirectory.path,
);
expect(flutterResult, const ProcessResultMatcher());
final Directory hostAppDirectory = projectDir.childDirectory('hello_host_app');
hostAppDirectory.createSync();
copyDirectory(
fileSystem.directory(
fileSystem.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'ios_host_app'),
),
hostAppDirectory,
);
final ProcessResult podResult = await processManager.run(
const <String>['pod', 'install'],
workingDirectory: hostAppDirectory.path,
environment: const <String, String>{'LANG': 'en_US.UTF-8'},
);
expect(podResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'Host.xcworkspace',
'-scheme',
'Host',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: hostAppDirectory.path,
);
expect(xcodeResult, const ProcessResultMatcher(stdoutPattern: '** BUILD SUCCEEDED **'));
},
);
test(
'fails if Flutter CLI last used configuration does not match Xcode configuration when archiving',
() async {
final Directory moduleDirectory = projectDir.childDirectory('hello');
await processManager.run(<String>[
flutterBin,
'create',
moduleDirectory.path,
'--template=module',
'--project-name=hello',
], workingDirectory: projectDir.path);
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: moduleDirectory.path,
);
expect(flutterResult, const ProcessResultMatcher());
final Directory hostAppDirectory = projectDir.childDirectory('hello_host_app');
hostAppDirectory.createSync();
copyDirectory(
fileSystem.directory(
fileSystem.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'ios_host_app'),
),
hostAppDirectory,
);
final ProcessResult podResult = await processManager.run(
const <String>['pod', 'install'],
workingDirectory: hostAppDirectory.path,
environment: const <String, String>{'LANG': 'en_US.UTF-8'},
);
expect(podResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'archive',
'-workspace',
'Host.xcworkspace',
'-scheme',
'Host',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Release',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: hostAppDirectory.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
exitCode: 65,
stdoutPattern: 'error: Your Flutter project is currently configured for debug mode.',
stderrPattern: '** ARCHIVE FAILED **',
),
);
},
);
test(
'warns if Flutter CLI last used configuration does not match Xcode configuration when building',
() async {
final Directory moduleDirectory = projectDir.childDirectory('hello');
await processManager.run(<String>[
flutterBin,
'create',
moduleDirectory.path,
'--template=module',
'--project-name=hello',
], workingDirectory: projectDir.path);
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'ios',
'--config-only',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: moduleDirectory.path,
);
expect(flutterResult, const ProcessResultMatcher());
final Directory hostAppDirectory = projectDir.childDirectory('hello_host_app');
hostAppDirectory.createSync();
copyDirectory(
fileSystem.directory(
fileSystem.path.join(getFlutterRoot(), 'dev', 'integration_tests', 'ios_host_app'),
),
hostAppDirectory,
);
final ProcessResult podResult = await processManager.run(
const <String>['pod', 'install'],
workingDirectory: hostAppDirectory.path,
environment: const <String, String>{'LANG': 'en_US.UTF-8'},
);
expect(podResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'Host.xcworkspace',
'-scheme',
'Host',
'-destination',
'generic/platform=iOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: hostAppDirectory.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
stdoutPattern:
'warning: Your Flutter project is currently configured for release mode.',
),
);
},
);
},
skip: !platform.isMacOS, // [intended] iOS builds only work on macos.
);
group(
'Xcode build macOS app',
() {
test(
'succeeds when Flutter CLI last used configuration matches Xcode configuration',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'macos',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'platform=macOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(xcodeResult, const ProcessResultMatcher(stdoutPattern: '** BUILD SUCCEEDED **'));
},
);
test(
'fails if Flutter CLI last used configuration does not match Xcode configuration when archiving',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'macos',
'--config-only',
'--debug',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'archive',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'platform=macOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Release',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
exitCode: 65,
stdoutPattern: 'error: Your Flutter project is currently configured for debug mode.',
stderrPattern: '** ARCHIVE FAILED **',
),
);
},
);
test(
'warns if Flutter CLI last used configuration does not match Xcode configuration when building',
() async {
final flutterCommand = <String>[
flutterBin,
...getLocalEngineArguments(),
'build',
'macos',
'--config-only',
'--release',
];
final ProcessResult flutterResult = await processManager.run(
flutterCommand,
workingDirectory: projectDir.path,
);
expect(flutterResult, const ProcessResultMatcher());
final xcodeCommand = <String>[
'xcodebuild',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-destination',
'platform=macOS',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'COMPILER_INDEX_STORE_ENABLE=NO',
'VERBOSE_SCRIPT_LOGGING=true',
'-configuration',
'Debug',
];
final ProcessResult xcodeResult = await processManager.run(
xcodeCommand,
workingDirectory: projectDir.path,
);
expect(
xcodeResult,
const ProcessResultMatcher(
stdoutPattern:
'warning: Your Flutter project is currently configured for release mode.',
),
);
},
);
},
skip: !platform.isMacOS, // [intended] iOS builds only work on macos.
);
}