Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhance macOS build process to support architecture specification via dartDefines#176606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
abdelaziz-mahdy wants to merge3 commits intoflutter:master
base:master
Choose a base branch
Loading
fromabdelaziz-mahdy:fix-macos-darwin-archs-release

Conversation

abdelaziz-mahdy
Copy link

@abdelaziz-mahdyabdelaziz-mahdy commentedOct 6, 2025
edited
Loading

Description

This PR adds support for single-architecture macOS release builds by respecting theDarwinArchs dart-define flag when setting the xcodebuild destination.

Problem

Currently, Flutter'sbuild_macos.dart hardcodes the xcodebuild destination for release builds togeneric/platform=macOS, which forces universal binaries (arm64 + x86_64). This causes build failures for
plugins with architecture-specific dependencies that only support one architecture.

Example: ExecuTorch only provides arm64 binaries for macOS. Debug builds work perfectly because they use-destination platform=macOS,arch=arm64, but release builds fail because they attempt to compile for
both architectures.

Solution

This PR modifies the destination logic to check ifDarwinArchs is defined inbuildInfo.dartDefines. When present, it uses the architecture-specific destination (same behavior as debug builds). When
absent, it maintains the current behavior of using the generic platform for universal binaries (backward compatibility).

Usage

Build for arm64 only

flutter build macos --release --dart-define=DarwinArchs=arm64

Build for x86_64 only

flutter build macos --release --dart-define=DarwinArchs=x86_64

Default behavior (universal binary)

flutter build macos --release

Tests Added

  • Release build with DarwinArchs=arm64 uses specific architecture destination
  • Release build with DarwinArchs=x86_64 uses specific architecture destination
  • Release build without DarwinArchs uses generic destination (backward compatibility)

All 26 tests passing.

Related Issues

Fixes#176605

Breaking Changes

None. This change is backward compatible - existing builds without the DarwinArchs flag will continue to produce universal binaries as before.

If you had to change anything in theflutter/tests repo, include a link to the migration guide as per thebreaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel onDiscord.

Note: The Flutter team is currently trialing the use ofGemini Code Assist for GitHub. Comments from thegemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

kjxbyz reacted with thumbs up emoji
@abdelaziz-mahdyabdelaziz-mahdy requested a review froma team as acode ownerOctober 6, 2025 23:42
@github-actionsgithub-actionsbot added toolAffects the "flutter" command-line tool. See also t: labels. a: desktopRunning on desktop team-iosOwned by iOS platform team labelsOct 6, 2025
Copy link
Contributor

@gemini-code-assistgemini-code-assistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Code Review

This pull request enhances the macOS build process by allowing developers to specify the target architecture throughdartDefines. This is achieved by parsing aDarwinArchs value fromdartDefines and adjusting thexcodebuild destination parameter accordingly. The changes correctly fall back to building a universal binary ifDarwinArchs is not specified in a release build, preserving backward compatibility. The pull request also includes comprehensive tests for the new functionality.

Comment on lines 203 to 208
for (finalString definein buildInfo.dartDefines) {
if (define.startsWith('DarwinArchs=')) {
darwinArchs= define.substring('DarwinArchs='.length);
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

This loop can be written more concisely usingfirstWhere with atry-catch block, which is a common Dart idiom for finding the first element that satisfies a condition. This also provides an opportunity to use thekDarwinArchs constant frombuild_info.dart to avoid a magic string, improving maintainability.

Suggested change
for (finalString definein buildInfo.dartDefines) {
if (define.startsWith('DarwinArchs=')) {
darwinArchs= define.substring('DarwinArchs='.length);
break;
}
}
try {
finalString prefix='$kDarwinArchs=';
finalString define= buildInfo.dartDefines.firstWhere(
(String d)=> d.startsWith(prefix),
);
darwinArchs= define.substring(prefix.length);
}onStateError {
// No DarwinArchs define found.
}

@abdelaziz-mahdyabdelaziz-mahdy marked this pull request as draftOctober 7, 2025 00:59
@abdelaziz-mahdy
Copy link
Author

abdelaziz-mahdy commentedOct 7, 2025
edited
Loading

tested on the main issue and it didnt work correctly, seems like swift package manager builds both of the archs, but for some reason for debug it works correctly

@fluttergithubbot
Copy link
Contributor

An existing Git SHA,8420b1f0ef70fd6595922301c2fb86bb89384f00, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with--force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visitWriting a golden file test forpackage:flutter.

Reviewers: Read theTree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@abdelaziz-mahdyabdelaziz-mahdy marked this pull request as ready for reviewOctober 7, 2025 01:08
@abdelaziz-mahdy
Copy link
Author

tested on the main issue and it didnt work correctly, seems like swift package manager builds both of the archs, but for some reason for debug it works correctly

the issue is that flutter tools was cached, so after removing the cache now it works correctly

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
a: desktopRunning on desktopteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

SwiftPM macOS - Allow limiting architecture for release builds
2 participants
@abdelaziz-mahdy@fluttergithubbot

[8]ページ先頭

©2009-2025 Movatter.jp