diff --git a/packages/flutter_tools/bin/xcode_backend.dart b/packages/flutter_tools/bin/xcode_backend.dart index 1357baa8867..7b715d8882b 100644 --- a/packages/flutter_tools/bin/xcode_backend.dart +++ b/packages/flutter_tools/bin/xcode_backend.dart @@ -540,8 +540,6 @@ class Context { final String buildMode = parseFlutterBuildMode(); - _validateBuildMode(platform, buildMode); - final List 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 _generateFlutterArgsForAssemble({ required String command, required String buildMode, diff --git a/packages/flutter_tools/lib/src/ios/xcode_build_settings.dart b/packages/flutter_tools/lib/src/ios/xcode_build_settings.dart index 253bc7fe3cd..6a54493d092 100644 --- a/packages/flutter_tools/lib/src/ios/xcode_build_settings.dart +++ b/packages/flutter_tools/lib/src/ios/xcode_build_settings.dart @@ -180,9 +180,6 @@ Future> _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. diff --git a/packages/flutter_tools/test/general.shard/xcode_backend_test.dart b/packages/flutter_tools/test/general.shard/xcode_backend_test.dart index 24c602551ac..43bb74ca273 100644 --- a/packages/flutter_tools/test/general.shard/xcode_backend_test.dart +++ b/packages/flutter_tools/test/general.shard/xcode_backend_test.dart @@ -103,7 +103,6 @@ void main() { 'CONFIGURATION': buildMode, 'FLUTTER_ROOT': flutterRoot.path, 'INFOPLIST_PATH': 'Info.plist', - 'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(), }, commands: [ 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( @@ -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( - ['build', platformName], - { - 'ACTION': 'install', - 'CONFIGURATION': buildMode, - 'BUILT_PRODUCTS_DIR': buildDir.path, - 'FLUTTER_ROOT': flutterRoot.path, - 'INFOPLIST_PATH': 'Info.plist', - }, - commands: [], - 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( - ['build', platformName], - { - 'ACTION': 'install', - 'CONFIGURATION': buildMode, - 'BUILT_PRODUCTS_DIR': buildDir.path, - 'FLUTTER_ROOT': flutterRoot.path, - 'INFOPLIST_PATH': 'Info.plist', - 'FLUTTER_CLI_BUILD_MODE': 'debug', - }, - commands: [], - 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( - ['build', platformName], - { - 'ACTION': 'build', - 'CONFIGURATION': buildMode, - 'BUILT_PRODUCTS_DIR': buildDir.path, - 'FLUTTER_ROOT': flutterRoot.path, - 'INFOPLIST_PATH': 'Info.plist', - }, - commands: [], - 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( - ['build', platformName], - { - 'ACTION': 'debug', - 'CONFIGURATION': buildMode, - 'BUILT_PRODUCTS_DIR': buildDir.path, - 'FLUTTER_ROOT': flutterRoot.path, - 'INFOPLIST_PATH': 'Info.plist', - 'FLUTTER_CLI_BUILD_MODE': 'debug', - }, - commands: [], - 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( @@ -609,7 +475,6 @@ void main() { 'CONFIGURATION': buildMode, 'FLUTTER_ROOT': flutterRoot.path, 'INFOPLIST_PATH': 'Info.plist', - 'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(), }, commands: [ 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( @@ -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( @@ -802,7 +665,6 @@ void main() { 'ARCHS': 'arm64', 'ONLY_ACTIVE_ARCH': 'YES', 'NATIVE_ARCH': 'x86_64', - 'FLUTTER_CLI_BUILD_MODE': buildMode.toLowerCase(), }, commands: [ 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( diff --git a/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart b/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart index b30cb08924e..af72538c4c9 100644 --- a/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart +++ b/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart @@ -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, - ['build'], - environment: { - '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, diff --git a/packages/flutter_tools/test/integration.shard/xcode_verify_configuration_test.dart b/packages/flutter_tools/test/integration.shard/xcode_verify_configuration_test.dart deleted file mode 100644 index 930437b505c..00000000000 --- a/packages/flutter_tools/test/integration.shard/xcode_verify_configuration_test.dart +++ /dev/null @@ -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([ - 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([ - 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([ - 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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'ios', - '--config-only', - '--debug', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'ios', - '--config-only', - '--debug', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'ios', - '--config-only', - '--release', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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([ - flutterBin, - 'create', - moduleDirectory.path, - '--template=module', - '--project-name=hello', - ], workingDirectory: projectDir.path); - - final flutterCommand = [ - 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 ['pod', 'install'], - workingDirectory: hostAppDirectory.path, - environment: const {'LANG': 'en_US.UTF-8'}, - ); - - expect(podResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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([ - flutterBin, - 'create', - moduleDirectory.path, - '--template=module', - '--project-name=hello', - ], workingDirectory: projectDir.path); - - final flutterCommand = [ - 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 ['pod', 'install'], - workingDirectory: hostAppDirectory.path, - environment: const {'LANG': 'en_US.UTF-8'}, - ); - - expect(podResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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([ - flutterBin, - 'create', - moduleDirectory.path, - '--template=module', - '--project-name=hello', - ], workingDirectory: projectDir.path); - - final flutterCommand = [ - 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 ['pod', 'install'], - workingDirectory: hostAppDirectory.path, - environment: const {'LANG': 'en_US.UTF-8'}, - ); - - expect(podResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'macos', - '--config-only', - '--debug', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'macos', - '--config-only', - '--debug', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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 = [ - flutterBin, - ...getLocalEngineArguments(), - 'build', - 'macos', - '--config-only', - '--release', - ]; - final ProcessResult flutterResult = await processManager.run( - flutterCommand, - workingDirectory: projectDir.path, - ); - - expect(flutterResult, const ProcessResultMatcher()); - - final xcodeCommand = [ - '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. - ); -}