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() {
"assemble"
"--no-version-check"
"-dTargetPlatform=darwin"
"-dDarwinArchs=x86_64"
"-dDarwinArchs=x86_64 arm64"
"-dTargetFile=${target_path}"
"-dBuildMode=${build_mode}"
"-dTreeShakeIcons=${TREE_SHAKE_ICONS}"
......
......@@ -116,9 +116,6 @@ def flutter_additional_macos_build_settings(target)
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
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.
# 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
......
......@@ -80,7 +80,7 @@ abstract class UnpackMacOS extends Target {
}
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 ProcessResult infoResult = environment.processManager.runSync(<String>[
'lipo',
......@@ -186,7 +186,7 @@ class DebugMacOSFramework extends Target {
final Iterable<DarwinArch> darwinArchs = environment.defines[kDarwinArchs]
?.split(' ')
.map(getDarwinArchForName)
?? <DarwinArch>[DarwinArch.x86_64];
?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
final Iterable<String> darwinArchArguments =
darwinArchs.expand((DarwinArch arch) => <String>['-arch', getNameForDarwinArch(arch)]);
......@@ -256,7 +256,7 @@ class CompileMacOSFramework extends Target {
?.split(' ')
.map(getDarwinArchForName)
.toList()
?? <DarwinArch>[DarwinArch.x86_64];
?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
if (targetPlatform != TargetPlatform.darwin) {
throw Exception('compile_macos_framework is only supported for darwin TargetPlatform.');
}
......
......@@ -200,15 +200,12 @@ Future<List<String>> _xcodeBuildSettingsLines({
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
// (to run natively without Rosetta translation on an ARM Mac),
// the app will fail to build unless it also excludes arm64 simulators.
String excludedSimulatorArchs = 'i386';
if (!(await project.ios.pluginsSupportArmSimulator())) {
excludedSimulatorArchs += ' arm64';
}
......
......@@ -291,7 +291,6 @@ void main() {
'FLUTTER_BUILD_DIR=build',
'FLUTTER_BUILD_NAME=1.0.0',
'FLUTTER_BUILD_NUMBER=1',
'EXCLUDED_ARCHS=arm64',
'DART_DEFINES=Zm9vLmJhcj0y,Zml6ei5mYXI9Mw==',
'DART_OBFUSCATION=true',
'EXTRA_FRONT_END_OPTIONS=--enable-experiment=non-nullable',
......@@ -303,6 +302,7 @@ void main() {
'PACKAGE_CONFIG=/.dart_tool/package_config.json',
'COCOAPODS_PARALLEL_CODE_SIGN=true',
]));
expect(contents, isNot(contains('EXCLUDED_ARCHS')));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
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