-
Notifications
You must be signed in to change notification settings - Fork 29.7k
in flutter run, throw tool exit when --flavor is provided but is not supported on the target device
#139045
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in flutter run, throw tool exit when --flavor is provided but is not supported on the target device
#139045
Conversation
210b8cb to
5ee78c6
Compare
5ee78c6 to
84e55e1
Compare
|
fyi @christopherfujino, this is now ready for review again (assuming my last commit doesn't break test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was macOS flavor support removed while I was gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I previously assumed macOS was supported, but I don't think this is the case?
macOS support is not documented. I also think flutter build macos --flavor results in a ToolExit saying Could not find an option named "flavor".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work with flutter run -d macos? If so, fixing flutter build macos might be a one line fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should document flavors support for macOS (assuming it works). IIRC the setup process in Xcode would be similar but not identical. I'll do more research.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we deleted the test in april. Not sure what we should do moving forward... #125581
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
- macOS support is not documented,
- macOS support is not under test, and most importantly
- users can't even build with flavors on macOS (unless they are publishing builds produced by
flutter run),
then it's clear to me that macOS is not supported. If support is desired, then it should go through the normal feature request process, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chatted with @christopherfujino. I still think it's fair for this PR to merge as is, but it's arguably worth seeing if macOS flavor support can be easily fixed before making it officially unsupported.
I will see what the current state of macOS flavor support is (i.e. does flutter run --flavor even work properly for macOS?). Then, I'll check in with Hans and see if they have any opinions on the matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important correction: flutter build macos --flavor does work. I was accidentally doing flutter run -d macos --flavor instead. Still, the other two points are valid, so I will file an issue and get Hans' input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some offline conversations about this, so I'm adding an update here for posterity's sake. I'm allotting myself some time to investigate #139774. If getting flavors for macOS back under test proves simple enough, I'll do that and get support for it publicly documented.
f346d48 to
4565874
Compare
4565874 to
6188b2e
Compare
…oes-not-support-flavor
| // Useful for test readability. | ||
| // ignore: avoid_redundant_argument_values | ||
| final FakeDevice device = FakeDevice(supportsFlavors: false); | ||
| testDeviceManager.devices = <Device>[device]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have two devices, one of which IS supported, and another that is NOT supported, and then pass the --all flag? I'm guessing in that case we should throw tool exit, right?
| final bool flavorsSupportedOnEveryDevice = devices! | ||
| .every((Device device) => device.supportsFlavors); | ||
| if (flavor != null && !flavorsSupportedOnEveryDevice) { | ||
| throwToolExit('--flavor is only supported for Android, macOS, and iOS devices.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts:
- The API here of
List<Device>? deviceshere is unfortunate, but I won't ask you to refactor this in this PR. I'm guessinglate final Future<List<Devices>> devices = findAllTargetDevices();would probably be more readable (although it's unfortunate thatfindAllTargetDevices()has hidden dependencies, but alas) - I'm guessing that here
deviceswill be only devices that: are available AND we have determined we will be running the app on, right? In which case, it seems like this validation logic is correct. - Do we also need validation logic for
flutter test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. I'm guessing that here
deviceswill be only devices that: are available AND we have determined we will be running the app on, right? In which case, it seems like this validation logic is correct.
This was my understanding from the last time I read the code. It also makes sense with the name of findAllTargetDevices.
3. Do we also need validation logic for flutter test
This seems like a good idea. I first need to figure out how device selection works for flutter test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the validation for flutter test. It is unclear to me whether or not this validation should itself be under test. Given its simplicity and that most of the neighboring throwToolExits also do not seem to be under test, I've elected to not create an integration test for this (perhaps I'm succumbing to broken window theory here). I did manually test this.
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iOS and macOS parts LGTM, I'll let @christopherfujino finish his review.
Thank you so much for tracking down the macOS flavor issues. Just today I was able to implement something in packages tooling for iOS and macOS and it's so much nicer when the tool works the same for both!
christopherfujino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
… but is not supported on the target device (flutter/flutter#139045)
|
What's the sense of this change? Now developers have to duplicate all run configurations, one for Web (without flavor option) and one for Mobile (with flavor option), causing massive inconvenience for no gain! |
When questioning the purpose of a PR, I recommend first reading both the PR and the issue associated with it. One or both of these should include the reason for the change. In this case, the original issue, #134197, includes the reasoning. Regardless, a new issue has been opened to discuss this further, #143574. |
|
It would be excellent if we could continue using the flavor flag without breaking the build. that way we can continue using our run configuration for mobile and web. |
It's a rhetorical question: I did read the PR and I just think the solution is causing more problems than it's supposed to fix. |
Fixes #134197
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.