Unverified Commit f76b2926 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Support iOS arm64 simulator (#85642)

parent 4013fe21
......@@ -147,7 +147,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
'Debug',
'App.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'App.framework',
'flutter_assets',
'vm_snapshot_data',
......@@ -210,7 +210,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
mode,
'App.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'App.framework',
'App',
));
......@@ -219,7 +219,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
mode,
'App.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'App.framework',
'Info.plist',
));
......@@ -312,7 +312,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
mode,
'device_info.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'device_info.framework',
'device_info',
);
......@@ -321,7 +321,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
mode,
'device_info.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'device_info.framework',
'Headers',
'DeviceInfoPlugin.h',
......@@ -368,7 +368,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
outputPath,
mode,
'FlutterPluginRegistrant.xcframework',
'ios-x86_64-simulator',
'ios-arm64_x86_64-simulator',
'FlutterPluginRegistrant.framework',
'Headers',
'GeneratedPluginRegistrant.h',
......
......@@ -447,7 +447,6 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
......
......@@ -390,7 +390,6 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
INFOPLIST_FILE = Host/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
......
......@@ -55,7 +55,7 @@ def flutter_additional_ios_build_settings(target)
# Profile can't be derived from the CocoaPods build configuration. Use release framework (for linking only).
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
Dir.new(configuration_engine_dir).each_child do |xcframework_file|
if xcframework_file.end_with?("-simulator") # ios-x86_64-simulator
if xcframework_file.end_with?("-simulator") # ios-arm64_x86_64-simulator
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
elsif xcframework_file.start_with?("ios-") # ios-armv7_arm64
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
......@@ -72,8 +72,9 @@ def flutter_additional_ios_build_settings(target)
# If the pod only supports a higher version, do not delete to correctly produce an error.
build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' if inherit_deployment_target
# Apple Silicon ARM simulators not yet supported.
build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
# Override legacy Xcode 11 style VALID_ARCHS[sdk=iphonesimulator*]=x86_64 and prefer Xcode 12 EXCLUDED_ARCHS.
build_configuration.build_settings['VALID_ARCHS[sdk=iphonesimulator*]'] = '$(ARCHS_STANDARD)'
build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'i386'
end
end
......
......@@ -672,9 +672,8 @@ String _getIosEngineArtifactPath(String engineDirectory,
if (!platformDirectory.basename.startsWith('ios-')) {
continue;
}
// ios-x86_64-simulator, ios-armv7_arm64 (Xcode 11), or ios-arm64_armv7 (Xcode 12).
final bool simulatorDirectory =
platformDirectory.basename.endsWith('-simulator');
// ios-x86_64-simulator, ios-arm64_x86_64-simulator, ios-armv7_arm64 (Xcode 11), or ios-arm64_armv7 (Xcode 12).
final bool simulatorDirectory = platformDirectory.basename.endsWith('-simulator');
if ((environmentType == EnvironmentType.simulator && simulatorDirectory) ||
(environmentType == EnvironmentType.physical && !simulatorDirectory)) {
flutterFrameworkSource = platformDirectory;
......
......@@ -547,8 +547,8 @@ List<DarwinArch> defaultIOSArchsForEnvironment(
EnvironmentType environmentType) {
if (environmentType == EnvironmentType.simulator) {
return <DarwinArch>[
// Apple Silicon ARM simulators not yet supported.
DarwinArch.x86_64,
DarwinArch.arm64,
];
}
return <DarwinArch>[
......@@ -876,7 +876,7 @@ const String kIosArchs = 'IosArchs';
/// The define to control what macOS architectures are built for.
///
/// This is expected to be a space-delimited list of architectures. If not
/// provided, defautls to x86_64.
/// provided, defaults to x86_64.
///
/// Supported values are x86_64 and arm64.
const String kDarwinArchs = 'DarwinArchs';
......
......@@ -454,7 +454,6 @@ end
simulatorConfiguration,
'SYMROOT=${simulatorBuildOutput.path}',
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
'ARCHS=x86_64',
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
];
......
......@@ -190,8 +190,9 @@ List<String> _xcodeBuildSettingsLines({
String arch;
if (localEngineName.endsWith('_arm')) {
arch = 'armv7';
} else if (localEngineName.contains('_arm64')) {
arch = 'arm64';
} else if (localEngineName.contains('_sim')) {
// Apple Silicon ARM simulators not yet supported.
arch = 'x86_64';
} else {
arch = 'arm64';
......@@ -203,8 +204,7 @@ List<String> _xcodeBuildSettingsLines({
// ARM not yet supported https://github.com/flutter/flutter/issues/69221
xcodeBuildSettings.add('EXCLUDED_ARCHS=arm64');
} else {
// Apple Silicon ARM simulators not yet supported.
xcodeBuildSettings.add('EXCLUDED_ARCHS[sdk=iphonesimulator*]=arm64 i386');
xcodeBuildSettings.add('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386');
}
for (final MapEntry<String, String> config in buildInfo.toEnvironmentConfig().entries) {
......
......@@ -698,7 +698,7 @@ Information about project "Runner":
final String contents = config.readAsStringSync();
expect(contents.contains('ARCHS=armv7'), isTrue);
expect(contents.contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=arm64 i386'), isTrue);
expect(contents.contains('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386'), isTrue);
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
......@@ -751,13 +751,33 @@ Information about project "Runner":
});
group('sim local engine', () {
Artifacts localArtifacts;
testUsingContext('sets ARCHS=x86_64 when x86 sim local engine is set', () async {
const BuildInfo buildInfo = BuildInfo.debug;
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
await updateGeneratedXcodeProperties(
project: project,
buildInfo: buildInfo,
);
setUp(() {
localArtifacts = Artifacts.test(localEngine: 'out/ios_debug_sim_unopt');
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('ARCHS=x86_64'), isTrue);
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
}, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(localEngine: 'out/ios_debug_sim_unopt'),
Platform: () => macOS,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('sets ARCHS=x86_64 when sim local engine is set', () async {
testUsingContext('sets ARCHS=arm64 when arm64 sim local engine is set', () async {
const BuildInfo buildInfo = BuildInfo.debug;
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
await updateGeneratedXcodeProperties(
......@@ -769,15 +789,15 @@ Information about project "Runner":
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('ARCHS=x86_64'), isTrue);
expect(contents.contains('ARCHS=arm64'), isTrue);
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
expect(buildPhaseScriptContents.contains('ARCHS=arm64'), isTrue);
}, overrides: <Type, Generator>{
Artifacts: () => localArtifacts,
Artifacts: () => Artifacts.test(localEngine: 'out/ios_debug_sim_arm64'),
Platform: () => macOS,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment