Skip to content

Conversation

@zhibisora
Copy link

@zhibisora zhibisora commented May 22, 2024

use

final String arch = globals.platform.version.contains('arm64') ? 'arm64' : globals.platform.version.contains('x86_64') ? 'x86_64' : '';
final String destination = 'platform=macOS${arch.isEmpty?'':',arch=$arch'}';

and

'-destination', destination,

make Xcode know which device to choose for the build.

This will not affect the architecture version of the build result, the actual build version is still determined by the xcode settings. This is simply a more precise specification of the build target to minimize Xcode complaints.

If there is no matching architectural information in the version, the code behavior falls back to what it was before this pr.

fixes #86590

Pre-launch Checklist

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

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@google-cla
Copy link

google-cla bot commented May 22, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop framework flutter/packages/flutter repository. See also f: labels. labels May 22, 2024
@zhibisora zhibisora force-pushed the specify_arch_macos branch from d3d4bd0 to 40c323a Compare May 23, 2024 21:10
@github-actions github-actions bot removed the framework flutter/packages/flutter repository. See also f: labels. label May 23, 2024
@andrewkolos
Copy link
Contributor

@cbracken is this something you could review?

@andrewkolos
Copy link
Contributor

@cbracken is this something you could review?

FYI: Chris will likely be out of action for the next 10 days or so.

@loic-sharma loic-sharma added the platform-mac Building on or for macOS specifically label Jun 24, 2024
throwToolExit('Unable to find expected configuration in Xcode project.');
}
// Specifying the architecture makes the destination clear to Xcode
final String arch = globals.platform.version.contains('arm64') ? 'arm64' : globals.platform.version.contains('x86_64') ? 'x86_64' : '';
Copy link
Member

@jmagman jmagman Jun 24, 2024

Choose a reason for hiding this comment

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

Sorry for the delay on this review.
Instead of string parsing, you should check OperatingSystemUtils.hostPlatform:

Suggested change
final String arch = globals.platform.version.contains('arm64') ? 'arm64' : globals.platform.version.contains('x86_64') ? 'x86_64' : '';
final String arch = globals.os.hostPlatform == HostPlatform.darwin_arm64 ? 'arm64' : 'x86_64';

What would the empty string fallback do?

Copy link
Author

Choose a reason for hiding this comment

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

The empty string fallback is just in case it's not fetched, it does nothing and keeps the behaviour before this pr.

Copy link
Author

@zhibisora zhibisora Jul 11, 2024

Choose a reason for hiding this comment

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

Using an empty string also allows the old tests to pass normally. If I switch to using globals.os.hostPlatform, I might need to modify the existing tests, as the destination parameter is hard-coded in the current tests. I'm not sure if this is an acceptable practice.

In build_macos_test.dart on line 127, '-destination', 'platform=macOS' is written as a string. I might need to modify it to pass this PR.

@cbracken
Copy link
Member

@zhibisora are you still working on this?

@zhibisora
Copy link
Author

zhibisora commented Jul 11, 2024

@zhibisora are you still working on this?

Yes, I had some other things to handle before, but I will continue working on it from now on.

@zhibisora zhibisora force-pushed the specify_arch_macos branch from 40c323a to 4f06fef Compare July 11, 2024 22:15
@zhibisora zhibisora force-pushed the specify_arch_macos branch from 312e981 to 0531557 Compare July 11, 2024 22:49
@cbracken
Copy link
Member

Right on. Give us a shout when this is passing tests and ready for review! Thanks!

@jmagman
Copy link
Member

jmagman commented Jul 17, 2024

Example failure:

[2024-07-11 15:55:28.438858] [STDOUT] run:stderr: 2024-07-11 15:55:28.435 xcodebuild[19672:128982] Writing error result bundle to /var/folders/cs/cqkgmb4n27n6k5bhvx0_34d00000gp/T/ResultBundle_2024-11-07_15-55-0028.xcresult
[2024-07-11 15:55:28.470962] [STDOUT] run:stderr: xcodebuild: error: unreadable input ' arch=arm64' at end of value for option 'Destination'

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8742668911423530689/+/u/run_run_debug_test_macos/stdout

@jmagman
Copy link
Member

jmagman commented Jul 25, 2024

Heads up, after #152347 you'll be able to grab the ARCH build settings before the actual compilation happens.

@LouiseHsu
Copy link
Contributor

Are you still working on this? Would you like any help?
Also heads up #152347 has landed :)

@cbracken cbracken marked this pull request as draft August 14, 2024 20:53
@cbracken
Copy link
Member

Converting to draft for the time being. @zhibisora is this still something you're working on?

@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, visit Writing a golden file test for package:flutter.

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

@jmagman
Copy link
Member

jmagman commented Aug 21, 2024

Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks!

@jmagman jmagman closed this Aug 21, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 26, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

This PR resolves warning when building macOS app in environments with
multiple available destinations (i.e. arm Macs with Rosetta).

| | Debug | Release | Profile |
|---|---|---|---|
| **Before** | <img width="657" alt="image"
src="https://github.com/user-attachments/assets/5207f2cc-2785-4bef-8eb0-e9a5a7431c91"
/> | <img width="699" alt="image"
src="https://github.com/user-attachments/assets/31f38373-adf9-4797-982d-782569be0681"
/> | <img width="699" alt="image"
src="https://github.com/user-attachments/assets/be1432f9-0668-44b9-b75e-ae4a56c0ff6e"
/> |
| **After** | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/62f3b37b-8461-4274-b9be-53df22bec82d"
/> | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/7c0489e7-0f7f-4498-b9d2-6d566722a05a"
/> | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/d0a3e065-3ae7-4d53-beb5-d2a96aa01aea"
/> |


For release/profile builds `generic/platform=macOS` was chosen because
these configurations are "fat" (includes all arches) so it is a
preferred way of building device-agnostic actions such as `xcodebuild
build`, as per `xcodebuild` documentation.

fixes #86590 

Also, kudos to @zhibisora. This PR is heavily inspired by
#148920. Although, I failed to
properly rebase it onto current master (you know, monorepo merge and
format changes).


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
stan-at-work pushed a commit to stan-at-work/flutter that referenced this pull request May 26, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

This PR resolves warning when building macOS app in environments with
multiple available destinations (i.e. arm Macs with Rosetta).

| | Debug | Release | Profile |
|---|---|---|---|
| **Before** | <img width="657" alt="image"
src="https://github.com/user-attachments/assets/5207f2cc-2785-4bef-8eb0-e9a5a7431c91"
/> | <img width="699" alt="image"
src="https://github.com/user-attachments/assets/31f38373-adf9-4797-982d-782569be0681"
/> | <img width="699" alt="image"
src="https://github.com/user-attachments/assets/be1432f9-0668-44b9-b75e-ae4a56c0ff6e"
/> |
| **After** | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/62f3b37b-8461-4274-b9be-53df22bec82d"
/> | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/7c0489e7-0f7f-4498-b9d2-6d566722a05a"
/> | <img width="672" alt="image"
src="https://github.com/user-attachments/assets/d0a3e065-3ae7-4d53-beb5-d2a96aa01aea"
/> |


For release/profile builds `generic/platform=macOS` was chosen because
these configurations are "fat" (includes all arches) so it is a
preferred way of building device-agnostic actions such as `xcodebuild
build`, as per `xcodebuild` documentation.

fixes flutter#86590 

Also, kudos to @zhibisora. This PR is heavily inspired by
flutter#148920. Although, I failed to
properly rebase it onto current master (you know, monorepo merge and
format changes).


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop platform-mac Building on or for macOS specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Xcode 13 "flutter run -d macos" prints warning that there are multiple matching destinations, "arch:x86_64" and "name:Any Mac"

6 participants