mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove build configuration mismatch warning (#174715)
A build configuration mismatch warning was introduced in https://github.com/flutter/flutter/pull/169395 to help handle dev_dependencies relying on the build configuration. However, we disabled dev_dependencies from being excluded per configuration in https://github.com/flutter/flutter/pull/171015. This warning therefore can also be removed. Fixes https://github.com/flutter/flutter/issues/174015. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
4760345abe
commit
b039be55b3
@ -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,
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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.
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user