Exclude arm64 from iOS app archs if unsupported by plugins (#87244)
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
@@ -20,6 +21,7 @@ import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/fake_process_manager.dart';
|
||||
import '../../src/fakes.dart';
|
||||
|
||||
const String xcodebuild = '/usr/bin/xcodebuild';
|
||||
|
||||
@@ -38,7 +40,8 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
const FakeCommand kARMCheckCommand = FakeCommand(
|
||||
// x64 host.
|
||||
const FakeCommand kx64CheckCommand = FakeCommand(
|
||||
command: <String>[
|
||||
'sysctl',
|
||||
'hw.optional.arm64',
|
||||
@@ -46,6 +49,15 @@ void main() {
|
||||
exitCode: 1,
|
||||
);
|
||||
|
||||
// ARM host.
|
||||
const FakeCommand kARMCheckCommand = FakeCommand(
|
||||
command: <String>[
|
||||
'sysctl',
|
||||
'hw.optional.arm64',
|
||||
],
|
||||
stdout: 'hw.optional.arm64: 1',
|
||||
);
|
||||
|
||||
FakeProcessManager fakeProcessManager;
|
||||
XcodeProjectInterpreter xcodeProjectInterpreter;
|
||||
FakePlatform platform;
|
||||
@@ -70,7 +82,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not fully installed', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: "xcode-select: error: tool 'xcodebuild' requires Xcode, "
|
||||
@@ -87,7 +99,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild versionText returns null when xcodebuild is not installed', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
exception: ProcessException(xcodebuild, <String>['-version']),
|
||||
@@ -100,7 +112,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild versionText returns formatted version text', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode 8.3.3\nBuild version 8E3004b',
|
||||
@@ -114,7 +126,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild versionText handles Xcode version string with unexpected format', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode Ultra5000\nBuild version 8E3004b',
|
||||
@@ -128,7 +140,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild version parts can be parsed', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode 11.4.1\nBuild version 11N111s',
|
||||
@@ -142,7 +154,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild minor and patch version default to 0', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode 11\nBuild version 11N111s',
|
||||
@@ -156,7 +168,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild version parts is null when version has unexpected format', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode Ultra5000\nBuild version 8E3004b',
|
||||
@@ -192,7 +204,7 @@ void main() {
|
||||
'xcodebuild isInstalled is false when Xcode is not fully installed', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: "xcode-select: error: tool 'xcodebuild' requires Xcode, "
|
||||
@@ -209,7 +221,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild isInstalled is false when version has unexpected format', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode Ultra5000\nBuild version 8E3004b',
|
||||
@@ -223,7 +235,7 @@ void main() {
|
||||
testWithoutContext('xcodebuild isInstalled is true when version has expected format', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-version'],
|
||||
stdout: 'Xcode 8.3.3\nBuild version 8E3004b',
|
||||
@@ -237,13 +249,7 @@ void main() {
|
||||
testWithoutContext('xcrun runs natively on arm64', () {
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'sysctl',
|
||||
'hw.optional.arm64',
|
||||
],
|
||||
stdout: 'hw.optional.arm64: 1',
|
||||
),
|
||||
kARMCheckCommand,
|
||||
]);
|
||||
|
||||
expect(xcodeProjectInterpreter.xcrunCommand(), <String>[
|
||||
@@ -295,7 +301,7 @@ void main() {
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
@@ -329,7 +335,7 @@ void main() {
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
@@ -358,7 +364,7 @@ void main() {
|
||||
};
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
@@ -391,7 +397,7 @@ void main() {
|
||||
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'xcrun',
|
||||
@@ -416,7 +422,7 @@ void main() {
|
||||
const String workingDirectory = '/';
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-list'],
|
||||
),
|
||||
@@ -440,7 +446,7 @@ void main() {
|
||||
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-list'],
|
||||
exitCode: 66,
|
||||
@@ -466,7 +472,7 @@ void main() {
|
||||
|
||||
fakeProcessManager.addCommands(const <FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
kx64CheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>['xcrun', 'xcodebuild', '-list'],
|
||||
exitCode: 74,
|
||||
@@ -676,10 +682,171 @@ Information about project "Runner":
|
||||
fs.file(xcodebuild).createSync(recursive: true);
|
||||
});
|
||||
|
||||
group('arm simulator', () {
|
||||
FakeProcessManager fakeProcessManager;
|
||||
XcodeProjectInterpreter xcodeProjectInterpreter;
|
||||
|
||||
setUp(() {
|
||||
fakeProcessManager = FakeProcessManager.empty();
|
||||
xcodeProjectInterpreter = XcodeProjectInterpreter.test(processManager: fakeProcessManager);
|
||||
});
|
||||
|
||||
testUsingContext('does not exclude arm64 simulator when supported by all plugins', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
|
||||
..createSync(recursive: true);
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'/usr/bin/arch',
|
||||
'-arm64e',
|
||||
'xcrun',
|
||||
'xcodebuild',
|
||||
'-alltargets',
|
||||
'-sdk',
|
||||
'iphonesimulator',
|
||||
'-project',
|
||||
podXcodeProject.path,
|
||||
'-showBuildSettings',
|
||||
],
|
||||
stdout: '''
|
||||
Build settings for action build and target plugin1:
|
||||
ENABLE_BITCODE = NO;
|
||||
EXCLUDED_ARCHS = i386;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
UNRELATED_BUILD_SETTING = arm64;
|
||||
|
||||
Build settings for action build and target plugin2:
|
||||
ENABLE_BITCODE = NO;
|
||||
EXCLUDED_ARCHS = i386;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
UNRELATED_BUILD_SETTING = arm64;
|
||||
'''
|
||||
),
|
||||
]);
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.readAsStringSync(), contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386\n'));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_arm),
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
XcodeProjectInterpreter: () => xcodeProjectInterpreter,
|
||||
});
|
||||
|
||||
testUsingContext('excludes arm64 simulator when build setting fetch fails', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
|
||||
..createSync(recursive: true);
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'/usr/bin/arch',
|
||||
'-arm64e',
|
||||
'xcrun',
|
||||
'xcodebuild',
|
||||
'-alltargets',
|
||||
'-sdk',
|
||||
'iphonesimulator',
|
||||
'-project',
|
||||
podXcodeProject.path,
|
||||
'-showBuildSettings',
|
||||
],
|
||||
exitCode: 1,
|
||||
),
|
||||
]);
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.readAsStringSync(), contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 arm64\n'));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_arm),
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
XcodeProjectInterpreter: () => xcodeProjectInterpreter,
|
||||
});
|
||||
|
||||
testUsingContext('excludes arm64 simulator when unsupported by plugins', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
final Directory podXcodeProject = project.ios.hostAppRoot.childDirectory('Pods').childDirectory('Pods.xcodeproj')
|
||||
..createSync(recursive: true);
|
||||
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
kWhichSysctlCommand,
|
||||
kARMCheckCommand,
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'/usr/bin/arch',
|
||||
'-arm64e',
|
||||
'xcrun',
|
||||
'xcodebuild',
|
||||
'-alltargets',
|
||||
'-sdk',
|
||||
'iphonesimulator',
|
||||
'-project',
|
||||
podXcodeProject.path,
|
||||
'-showBuildSettings',
|
||||
],
|
||||
stdout: '''
|
||||
Build settings for action build and target plugin1:
|
||||
ENABLE_BITCODE = NO;
|
||||
EXCLUDED_ARCHS = i386;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
UNRELATED_BUILD_SETTING = arm64;
|
||||
|
||||
Build settings for action build and target plugin2:
|
||||
ENABLE_BITCODE = NO;
|
||||
EXCLUDED_ARCHS = i386 arm64;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
UNRELATED_BUILD_SETTING = arm64;
|
||||
'''
|
||||
),
|
||||
]);
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.readAsStringSync(), contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 arm64\n'));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_arm),
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
XcodeProjectInterpreter: () => xcodeProjectInterpreter,
|
||||
});
|
||||
});
|
||||
|
||||
void testUsingOsxContext(String description, dynamic Function() testMethod) {
|
||||
testUsingContext(description, testMethod, overrides: <Type, Generator>{
|
||||
Artifacts: () => localArtifacts,
|
||||
Platform: () => macOS,
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(hostPlatform: HostPlatform.darwin_x64),
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
@@ -708,6 +875,21 @@ Information about project "Runner":
|
||||
expect(buildPhaseScriptContents.contains('EXCLUDED_ARCHS'), isFalse);
|
||||
});
|
||||
|
||||
testUsingOsxContext('excludes i386 simulator', () async {
|
||||
const BuildInfo buildInfo = BuildInfo.debug;
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.readAsStringSync(), contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386\n'));
|
||||
|
||||
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
|
||||
expect(buildPhaseScript.readAsStringSync(), isNot(contains('EXCLUDED_ARCHS')));
|
||||
});
|
||||
|
||||
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
|
||||
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, treeShakeIcons: false);
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||
|
||||
@@ -306,6 +306,14 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
|
||||
return <String, String>{};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> pluginsBuildSettingsOutput(
|
||||
Directory podXcodeProject, {
|
||||
Duration timeout = const Duration(minutes: 1),
|
||||
}) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> cleanWorkspace(String workspacePath, String scheme, { bool verbose = false }) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user