Skip to content

Commit a618ca2

Browse files
authored
[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: flutter/flutter#97681 Umbrella issue: flutter/flutter#60113
1 parent 7f241ba commit a618ca2

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

packages/flutter_tools/bin/macos_assemble.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ BuildApp() {
7070
"assemble"
7171
"--no-version-check"
7272
"-dTargetPlatform=darwin"
73-
"-dDarwinArchs=x86_64"
73+
"-dDarwinArchs=x86_64 arm64"
7474
"-dTargetFile=${target_path}"
7575
"-dBuildMode=${build_mode}"
7676
"-dTreeShakeIcons=${TREE_SHAKE_ICONS}"

packages/flutter_tools/bin/podhelper.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ def flutter_additional_macos_build_settings(target)
116116
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
117117
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}\" $(inherited)"
118118

119-
# ARM not yet supported https://github.com/flutter/flutter/issues/69221
120-
build_configuration.build_settings['EXCLUDED_ARCHS'] = 'arm64'
121-
122119
# When deleted, the deployment version will inherit from the higher version derived from the 'Runner' target.
123120
# If the pod only supports a higher version, do not delete to correctly produce an error.
124121
build_configuration.build_settings.delete 'MACOSX_DEPLOYMENT_TARGET' if inherit_deployment_target

packages/flutter_tools/lib/src/build_system/targets/macos.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ abstract class UnpackMacOS extends Target {
8080
}
8181

8282
void _thinFramework(Environment environment, String frameworkBinaryPath) {
83-
final String archs = environment.defines[kDarwinArchs] ?? 'x86_64';
83+
final String archs = environment.defines[kDarwinArchs] ?? 'x86_64 arm64';
8484
final List<String> archList = archs.split(' ').toList();
8585
final ProcessResult infoResult = environment.processManager.runSync(<String>[
8686
'lipo',
@@ -186,7 +186,7 @@ class DebugMacOSFramework extends Target {
186186
final Iterable<DarwinArch> darwinArchs = environment.defines[kDarwinArchs]
187187
?.split(' ')
188188
.map(getDarwinArchForName)
189-
?? <DarwinArch>[DarwinArch.x86_64];
189+
?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
190190

191191
final Iterable<String> darwinArchArguments =
192192
darwinArchs.expand((DarwinArch arch) => <String>['-arch', getNameForDarwinArch(arch)]);
@@ -256,7 +256,7 @@ class CompileMacOSFramework extends Target {
256256
?.split(' ')
257257
.map(getDarwinArchForName)
258258
.toList()
259-
?? <DarwinArch>[DarwinArch.x86_64];
259+
?? <DarwinArch>[DarwinArch.x86_64, DarwinArch.arm64];
260260
if (targetPlatform != TargetPlatform.darwin) {
261261
throw Exception('compile_macos_framework is only supported for darwin TargetPlatform.');
262262
}

packages/flutter_tools/lib/src/ios/xcode_build_settings.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,12 @@ Future<List<String>> _xcodeBuildSettingsLines({
200200
xcodeBuildSettings.add('ARCHS=$arch');
201201
}
202202
}
203-
if (useMacOSConfig) {
204-
// ARM not yet supported https://github.com/flutter/flutter/issues/69221
205-
xcodeBuildSettings.add('EXCLUDED_ARCHS=arm64');
206-
} else {
207-
String excludedSimulatorArchs = 'i386';
208203

204+
if (!useMacOSConfig) {
209205
// If any plugins or their dependencies do not support arm64 simulators
210206
// (to run natively without Rosetta translation on an ARM Mac),
211207
// the app will fail to build unless it also excludes arm64 simulators.
208+
String excludedSimulatorArchs = 'i386';
212209
if (!(await project.ios.pluginsSupportArmSimulator())) {
213210
excludedSimulatorArchs += ' arm64';
214211
}

packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ void main() {
291291
'FLUTTER_BUILD_DIR=build',
292292
'FLUTTER_BUILD_NAME=1.0.0',
293293
'FLUTTER_BUILD_NUMBER=1',
294-
'EXCLUDED_ARCHS=arm64',
295294
'DART_DEFINES=Zm9vLmJhcj0y,Zml6ei5mYXI9Mw==',
296295
'DART_OBFUSCATION=true',
297296
'EXTRA_FRONT_END_OPTIONS=--enable-experiment=non-nullable',
@@ -303,6 +302,7 @@ void main() {
303302
'PACKAGE_CONFIG=/.dart_tool/package_config.json',
304303
'COCOAPODS_PARALLEL_CODE_SIGN=true',
305304
]));
305+
expect(contents, isNot(contains('EXCLUDED_ARCHS')));
306306
}, overrides: <Type, Generator>{
307307
FileSystem: () => fileSystem,
308308
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[

0 commit comments

Comments
 (0)