mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Support iOS arm64 simulator (#85642)
This commit is contained in:
parent
4013fe2131
commit
f76b292626
@ -147,7 +147,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
'Debug',
|
'Debug',
|
||||||
'App.xcframework',
|
'App.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'App.framework',
|
'App.framework',
|
||||||
'flutter_assets',
|
'flutter_assets',
|
||||||
'vm_snapshot_data',
|
'vm_snapshot_data',
|
||||||
@ -210,7 +210,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
mode,
|
mode,
|
||||||
'App.xcframework',
|
'App.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'App.framework',
|
'App.framework',
|
||||||
'App',
|
'App',
|
||||||
));
|
));
|
||||||
@ -219,7 +219,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
mode,
|
mode,
|
||||||
'App.xcframework',
|
'App.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'App.framework',
|
'App.framework',
|
||||||
'Info.plist',
|
'Info.plist',
|
||||||
));
|
));
|
||||||
@ -312,7 +312,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
mode,
|
mode,
|
||||||
'device_info.xcframework',
|
'device_info.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'device_info.framework',
|
'device_info.framework',
|
||||||
'device_info',
|
'device_info',
|
||||||
);
|
);
|
||||||
@ -321,7 +321,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
mode,
|
mode,
|
||||||
'device_info.xcframework',
|
'device_info.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'device_info.framework',
|
'device_info.framework',
|
||||||
'Headers',
|
'Headers',
|
||||||
'DeviceInfoPlugin.h',
|
'DeviceInfoPlugin.h',
|
||||||
@ -368,7 +368,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
outputPath,
|
outputPath,
|
||||||
mode,
|
mode,
|
||||||
'FlutterPluginRegistrant.xcframework',
|
'FlutterPluginRegistrant.xcframework',
|
||||||
'ios-x86_64-simulator',
|
'ios-arm64_x86_64-simulator',
|
||||||
'FlutterPluginRegistrant.framework',
|
'FlutterPluginRegistrant.framework',
|
||||||
'Headers',
|
'Headers',
|
||||||
'GeneratedPluginRegistrant.h',
|
'GeneratedPluginRegistrant.h',
|
||||||
|
@ -447,7 +447,6 @@
|
|||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
@ -390,7 +390,6 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
|
|
||||||
INFOPLIST_FILE = Host/Info.plist;
|
INFOPLIST_FILE = Host/Info.plist;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(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).
|
# 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
|
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
|
||||||
Dir.new(configuration_engine_dir).each_child do |xcframework_file|
|
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)"
|
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
|
||||||
elsif xcframework_file.start_with?("ios-") # ios-armv7_arm64
|
elsif xcframework_file.start_with?("ios-") # ios-armv7_arm64
|
||||||
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)"
|
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.
|
# 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
|
build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' if inherit_deployment_target
|
||||||
|
|
||||||
# Apple Silicon ARM simulators not yet supported.
|
# Override legacy Xcode 11 style VALID_ARCHS[sdk=iphonesimulator*]=x86_64 and prefer Xcode 12 EXCLUDED_ARCHS.
|
||||||
build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
|
build_configuration.build_settings['VALID_ARCHS[sdk=iphonesimulator*]'] = '$(ARCHS_STANDARD)'
|
||||||
|
build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'i386'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -672,9 +672,8 @@ String _getIosEngineArtifactPath(String engineDirectory,
|
|||||||
if (!platformDirectory.basename.startsWith('ios-')) {
|
if (!platformDirectory.basename.startsWith('ios-')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// ios-x86_64-simulator, ios-armv7_arm64 (Xcode 11), or ios-arm64_armv7 (Xcode 12).
|
// ios-x86_64-simulator, ios-arm64_x86_64-simulator, ios-armv7_arm64 (Xcode 11), or ios-arm64_armv7 (Xcode 12).
|
||||||
final bool simulatorDirectory =
|
final bool simulatorDirectory = platformDirectory.basename.endsWith('-simulator');
|
||||||
platformDirectory.basename.endsWith('-simulator');
|
|
||||||
if ((environmentType == EnvironmentType.simulator && simulatorDirectory) ||
|
if ((environmentType == EnvironmentType.simulator && simulatorDirectory) ||
|
||||||
(environmentType == EnvironmentType.physical && !simulatorDirectory)) {
|
(environmentType == EnvironmentType.physical && !simulatorDirectory)) {
|
||||||
flutterFrameworkSource = platformDirectory;
|
flutterFrameworkSource = platformDirectory;
|
||||||
|
@ -547,8 +547,8 @@ List<DarwinArch> defaultIOSArchsForEnvironment(
|
|||||||
EnvironmentType environmentType) {
|
EnvironmentType environmentType) {
|
||||||
if (environmentType == EnvironmentType.simulator) {
|
if (environmentType == EnvironmentType.simulator) {
|
||||||
return <DarwinArch>[
|
return <DarwinArch>[
|
||||||
// Apple Silicon ARM simulators not yet supported.
|
|
||||||
DarwinArch.x86_64,
|
DarwinArch.x86_64,
|
||||||
|
DarwinArch.arm64,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return <DarwinArch>[
|
return <DarwinArch>[
|
||||||
@ -876,7 +876,7 @@ const String kIosArchs = 'IosArchs';
|
|||||||
/// The define to control what macOS architectures are built for.
|
/// The define to control what macOS architectures are built for.
|
||||||
///
|
///
|
||||||
/// This is expected to be a space-delimited list of architectures. If not
|
/// 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.
|
/// Supported values are x86_64 and arm64.
|
||||||
const String kDarwinArchs = 'DarwinArchs';
|
const String kDarwinArchs = 'DarwinArchs';
|
||||||
|
@ -454,7 +454,6 @@ end
|
|||||||
simulatorConfiguration,
|
simulatorConfiguration,
|
||||||
'SYMROOT=${simulatorBuildOutput.path}',
|
'SYMROOT=${simulatorBuildOutput.path}',
|
||||||
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
||||||
'ARCHS=x86_64',
|
|
||||||
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
||||||
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
||||||
];
|
];
|
||||||
|
@ -190,8 +190,9 @@ List<String> _xcodeBuildSettingsLines({
|
|||||||
String arch;
|
String arch;
|
||||||
if (localEngineName.endsWith('_arm')) {
|
if (localEngineName.endsWith('_arm')) {
|
||||||
arch = 'armv7';
|
arch = 'armv7';
|
||||||
|
} else if (localEngineName.contains('_arm64')) {
|
||||||
|
arch = 'arm64';
|
||||||
} else if (localEngineName.contains('_sim')) {
|
} else if (localEngineName.contains('_sim')) {
|
||||||
// Apple Silicon ARM simulators not yet supported.
|
|
||||||
arch = 'x86_64';
|
arch = 'x86_64';
|
||||||
} else {
|
} else {
|
||||||
arch = 'arm64';
|
arch = 'arm64';
|
||||||
@ -203,8 +204,7 @@ List<String> _xcodeBuildSettingsLines({
|
|||||||
// ARM not yet supported https://github.com/flutter/flutter/issues/69221
|
// ARM not yet supported https://github.com/flutter/flutter/issues/69221
|
||||||
xcodeBuildSettings.add('EXCLUDED_ARCHS=arm64');
|
xcodeBuildSettings.add('EXCLUDED_ARCHS=arm64');
|
||||||
} else {
|
} else {
|
||||||
// Apple Silicon ARM simulators not yet supported.
|
xcodeBuildSettings.add('EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386');
|
||||||
xcodeBuildSettings.add('EXCLUDED_ARCHS[sdk=iphonesimulator*]=arm64 i386');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final MapEntry<String, String> config in buildInfo.toEnvironmentConfig().entries) {
|
for (final MapEntry<String, String> config in buildInfo.toEnvironmentConfig().entries) {
|
||||||
|
@ -698,7 +698,7 @@ Information about project "Runner":
|
|||||||
|
|
||||||
final String contents = config.readAsStringSync();
|
final String contents = config.readAsStringSync();
|
||||||
expect(contents.contains('ARCHS=armv7'), isTrue);
|
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');
|
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
|
||||||
expect(buildPhaseScript.existsSync(), isTrue);
|
expect(buildPhaseScript.existsSync(), isTrue);
|
||||||
@ -751,13 +751,7 @@ Information about project "Runner":
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('sim local engine', () {
|
group('sim local engine', () {
|
||||||
Artifacts localArtifacts;
|
testUsingContext('sets ARCHS=x86_64 when x86 sim local engine is set', () async {
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
localArtifacts = Artifacts.test(localEngine: 'out/ios_debug_sim_unopt');
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('sets ARCHS=x86_64 when sim local engine is set', () async {
|
|
||||||
const BuildInfo buildInfo = BuildInfo.debug;
|
const BuildInfo buildInfo = BuildInfo.debug;
|
||||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
final FlutterProject project = FlutterProject.fromDirectoryTest(fs.directory('path/to/project'));
|
||||||
await updateGeneratedXcodeProperties(
|
await updateGeneratedXcodeProperties(
|
||||||
@ -777,7 +771,33 @@ Information about project "Runner":
|
|||||||
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
||||||
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
|
expect(buildPhaseScriptContents.contains('ARCHS=x86_64'), isTrue);
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
Artifacts: () => localArtifacts,
|
Artifacts: () => Artifacts.test(localEngine: 'out/ios_debug_sim_unopt'),
|
||||||
|
Platform: () => macOS,
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
});
|
||||||
|
|
||||||
|
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(
|
||||||
|
project: project,
|
||||||
|
buildInfo: buildInfo,
|
||||||
|
);
|
||||||
|
|
||||||
|
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=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=arm64'), isTrue);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Artifacts: () => Artifacts.test(localEngine: 'out/ios_debug_sim_arm64'),
|
||||||
Platform: () => macOS,
|
Platform: () => macOS,
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
Loading…
Reference in New Issue
Block a user