Skip to content

Commit 7c63dbd

Browse files
committed
Fix flutter#160622: Restore watchOS companion app build protection
This fixes the regression introduced in PR flutter#154645 that broke `flutter run` for projects with Apple Watch extensions. The fix restores the check that prevents ARCHS from being set when a watchOS companion app is detected, while preserving the Swift Package Manager improvements from the original PR. The regression occurred because PR flutter#154645 accidentally removed the hasWatchCompanion check when refactoring the architecture handling code. This caused xcodebuild to attempt building watchOS targets with iOS architectures, which is impossible and results in build failures. Changes: - Move ONLY_ACTIVE_ARCH setting outside the hasWatchCompanion check (preserves SPM fix) - Keep ARCHS setting inside the \!hasWatchCompanion check (restores watchOS protection) This matches the historical pattern that worked from Flutter 2020-2024 and fixes the issue reported by users since Flutter 3.27.0. Fixes flutter#160622
1 parent 70a3c3c commit 7c63dbd

File tree

1 file changed

+6
-5
lines changed
  • packages/flutter_tools/lib/src/ios

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,15 @@ Future<XcodeBuildResult> buildXcodeProject({
382382
}
383383

384384
if (activeArch != null) {
385+
// ONLY_ACTIVE_ARCH specifies whether the product includes only code for
386+
// the native architecture.
387+
final onlyActiveArch = activeArch == getCurrentDarwinArch();
388+
389+
buildCommands.add('ONLY_ACTIVE_ARCH=${onlyActiveArch ? 'YES' : 'NO'}');
390+
385391
// Setting ARCHS to $activeArchName will break the build if a watchOS companion app exists,
386392
// as it cannot be build for the architecture of the Flutter app.
387393
if (!hasWatchCompanion) {
388-
// ONLY_ACTIVE_ARCH specifies whether the product includes only code for
389-
// the native architecture.
390-
final onlyActiveArch = activeArch == getCurrentDarwinArch();
391-
392-
buildCommands.add('ONLY_ACTIVE_ARCH=${onlyActiveArch ? 'YES' : 'NO'}');
393394
buildCommands.add('ARCHS=${activeArch.name}');
394395
}
395396
}

0 commit comments

Comments
 (0)