Unverified Commit a618ca27 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

[macOS] Enable universal binary builds by default (#100271)

This changes the default build architectures for Flutter macOS apps to
x86_64 and arm64. Previously, we manually excluded arm64 builds via the
EXCLUDE_ARCHS Xcode setting in Flutter's generated xcconfig file. This
eliminates setting EXCLUDE_ARCHS during the build and updates the
default architectures in the tool and in the macos_assemble.sh wrapper.

Issue: https://github.com/flutter/flutter/issues/97681
Umbrella issue: https://github.com/flutter/flutter/issues/60113
parent 7f241ba3
...@@ -70,7 +70,7 @@ BuildApp() { ...@@ -70,7 +70,7 @@ BuildApp() {
"assemble" "assemble"
"--no-version-check" "--no-version-check"
"-dTargetPlatform=darwin" "-dTargetPlatform=darwin"
"-dDarwinArchs=x86_64" "-dDarwinArchs=x86_64 arm64"
"-dTargetFile=${target_path}" "-dTargetFile=${target_path}"
"-dBuildMode=${build_mode}" "-dBuildMode=${build_mode}"
"-dTreeShakeIcons=${TREE_SHAKE_ICONS}" "-dTreeShakeIcons=${TREE_SHAKE_ICONS}"
......
...@@ -116,9 +116,6 @@ def flutter_additional_macos_build_settings(target) ...@@ -116,9 +116,6 @@ def flutter_additional_macos_build_settings(target)
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
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}\" $(inherited)" build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}\" $(inherited)"
# ARM not yet supported https://github.com/flutter/flutter/issues/69221
build_configuration.build_settings['EXCLUDED_ARCHS'] = 'arm64'
# When deleted, the deployment version will inherit from the higher version derived from the 'Runner' target. # When deleted, the deployment version will inherit from the higher version derived from the 'Runner' 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 'MACOSX_DEPLOYMENT_TARGET' if inherit_deployment_target build_configuration.build_settings.delete 'MACOSX_DEPLOYMENT_TARGET' if inherit_deployment_target
......
...@@ -80,7 +80,7 @@ abstract class UnpackMacOS extends Target { ...@@ -80,7 +80,7 @@ abstract class UnpackMacOS extends Target {
} }
void _thinFramework(Environment environment, String frameworkBinaryPath) { void _thinFramework(Environment environment, String frameworkBinaryPath) {
final String archs = environment.defines[kDarwinArchs] ?? 'x86_64'; final String archs = environment.defines[kDarwinArchs] ?? 'x86_64 arm64';
final List<String> archList = archs.split(' ').toList(); final List<String> archList = archs.split(' ').toList();
final ProcessResult infoResult = environment.processManager.runSync(<String>[ final ProcessResult infoResult = environment.processManager.runSync(<String>[
'lipo', 'lipo',
...@@ -186,7 +186,7 @@ class DebugMacOSFramework extends Target { ...@@ -186,7 +186,7 @@ class DebugMacOSFramework extends Target {
final Iterable<DarwinArch> darwinArchs = environment.defines[kDarwinArchs] final Iterable<DarwinArch> darwinArchs = environment.defines[kDarwinArchs]
?.split(' ') ?.split(' ')
.map(getDarwinArchForName) .map(getDarwinArchForName)
?? <DarwinArch>[DarwinArch.x86_64]; ?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
final Iterable<String> darwinArchArguments = final Iterable<String> darwinArchArguments =
darwinArchs.expand((DarwinArch arch) => <String>['-arch', getNameForDarwinArch(arch)]); darwinArchs.expand((DarwinArch arch) => <String>['-arch', getNameForDarwinArch(arch)]);
...@@ -256,7 +256,7 @@ class CompileMacOSFramework extends Target { ...@@ -256,7 +256,7 @@ class CompileMacOSFramework extends Target {
?.split(' ') ?.split(' ')
.map(getDarwinArchForName) .map(getDarwinArchForName)
.toList() .toList()
?? <DarwinArch>[DarwinArch.x86_64]; ?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
if (targetPlatform != TargetPlatform.darwin) { if (targetPlatform != TargetPlatform.darwin) {
throw Exception('compile_macos_framework is only supported for darwin TargetPlatform.'); throw Exception('compile_macos_framework is only supported for darwin TargetPlatform.');
} }
......
...@@ -200,15 +200,12 @@ Future<List<String>> _xcodeBuildSettingsLines({ ...@@ -200,15 +200,12 @@ Future<List<String>> _xcodeBuildSettingsLines({
xcodeBuildSettings.add('ARCHS=$arch'); xcodeBuildSettings.add('ARCHS=$arch');
} }
} }
if (useMacOSConfig) {
// ARM not yet supported https://github.com/flutter/flutter/issues/69221
xcodeBuildSettings.add('EXCLUDED_ARCHS=arm64');
} else {
String excludedSimulatorArchs = 'i386';
if (!useMacOSConfig) {
// If any plugins or their dependencies do not support arm64 simulators // If any plugins or their dependencies do not support arm64 simulators
// (to run natively without Rosetta translation on an ARM Mac), // (to run natively without Rosetta translation on an ARM Mac),
// the app will fail to build unless it also excludes arm64 simulators. // the app will fail to build unless it also excludes arm64 simulators.
String excludedSimulatorArchs = 'i386';
if (!(await project.ios.pluginsSupportArmSimulator())) { if (!(await project.ios.pluginsSupportArmSimulator())) {
excludedSimulatorArchs += ' arm64'; excludedSimulatorArchs += ' arm64';
} }
......
...@@ -291,7 +291,6 @@ void main() { ...@@ -291,7 +291,6 @@ void main() {
'FLUTTER_BUILD_DIR=build', 'FLUTTER_BUILD_DIR=build',
'FLUTTER_BUILD_NAME=1.0.0', 'FLUTTER_BUILD_NAME=1.0.0',
'FLUTTER_BUILD_NUMBER=1', 'FLUTTER_BUILD_NUMBER=1',
'EXCLUDED_ARCHS=arm64',
'DART_DEFINES=Zm9vLmJhcj0y,Zml6ei5mYXI9Mw==', 'DART_DEFINES=Zm9vLmJhcj0y,Zml6ei5mYXI9Mw==',
'DART_OBFUSCATION=true', 'DART_OBFUSCATION=true',
'EXTRA_FRONT_END_OPTIONS=--enable-experiment=non-nullable', 'EXTRA_FRONT_END_OPTIONS=--enable-experiment=non-nullable',
...@@ -303,6 +302,7 @@ void main() { ...@@ -303,6 +302,7 @@ void main() {
'PACKAGE_CONFIG=/.dart_tool/package_config.json', 'PACKAGE_CONFIG=/.dart_tool/package_config.json',
'COCOAPODS_PARALLEL_CODE_SIGN=true', 'COCOAPODS_PARALLEL_CODE_SIGN=true',
])); ]));
expect(contents, isNot(contains('EXCLUDED_ARCHS')));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
......
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