Skip to content

Force plugins to inherit minimum macOS version from Flutter app - #72764

Merged
jmagman merged 3 commits into
flutter:masterfrom
jmagman:macos-min-version
Jan 11, 2021
Merged

jmagman merged 3 commits into
flutter:masterfrom
jmagman:macos-min-version

Conversation

@jmagman

@jmagman jmagman commented Dec 22, 2020 •

Copy link
Copy Markdown
Member

Background

macOS version of #66590

Xcode supports specific SDK ranges, and every release they drop the lowest. For example, Xcode 12 dropped support for 10.8.
Xcode emits a warning when build targets support a minimum version lower than the range to indicate it can't validate compilation against the older SDK.

The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.9 to 10.16.99

This warning is benign: if the app supports a minimum of macOS 10.9, it doesn't cause any problems that a plugin framework embedded in the app supports macOS 10.8. These warnings concern users who think there's something wrong with their app, and there's no way for users to fix it (the plugin author would have to up their minimum supported version).

This warning was seen in flutter_gallery because the Reachability pod supported 10.8.

Description

If the plugin's minimum version is less than macOS 10.9, remove the version build setting. This will cause it to inherit from the minimum version set in the Flutter app (currently 10.11).

If the plugin minimum is higher than macOS 10.9, leave the build setting so if there is a versioning range issue (the plugin supports a minimum macOS 11 but the app needs 10.11) the correct error (not warning) will be emitted.

Related Issues

iOS issue at #40109, there's no macOS equivalent.

Tests

Added macOS to the plugin integration test. Confirm this test fails on master.

@jmagman jmagman self-assigned this Dec 22, 2020
@flutter-dashboard flutter-dashboard Bot added c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Dec 22, 2020
@flutter-dashboard

Copy link
Copy Markdown

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 Hixie on the #hackers channel in Chat.

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

@google-cla google-cla Bot added the cla: yes label Dec 22, 2020
@jmagman jmagman added the platform-macos Building on or for macOS specifically label Dec 22, 2020
Comment thread packages/flutter_tools/bin/podhelper.rb Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leftover debugging log.

Comment thread packages/flutter_tools/bin/podhelper.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should these *'s be +'s?

@christopherfujino christopherfujino Dec 22, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we validate that there are in fact two capture group matches?

@jmagman jmagman Dec 22, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

should these *'s be +'s?

No, then "11" is captured as "1" and "1".

Screen Shot 2020-12-22 at 10 40 42 AM

Screen Shot 2020-12-22 at 10 40 52 AM

should we validate that there are in fact two capture group matches?

If there's only one capture deployment_target_minor will be set to "", which is coerced to 0. So "11" is 11 and 0 which is what we want.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/(\d+).?(\d*)/ might be more precise though; there does need to be a first number.

@stuartmorgan-g

Copy link
Copy Markdown
Contributor

These warnings concern users who think there's something wrong with their app, and there's no way for users to fix it

Aren't we trading a single relatively clear warning for an arbitrary set of deprecated API warnings (also unfixable by the user), which may be confusing if reported to the plugin author? Or do we get those regardless when it's out of range?

@jmagman

jmagman commented Dec 29, 2020 •

Copy link
Copy Markdown
Member Author

Aren't we trading a single relatively clear warning for an arbitrary set of deprecated API warnings (also unfixable by the user), which may be confusing if reported to the plugin author? Or do we get those regardless when it's out of range?

You get the deprecated API warnings regardless of whether it's out of range. I just tested this.

#import <Carbon/Carbon.h>
...
UpTime();

UpTime was deprecated in 10.8. Whether I set my project to 10.8, which is out of range (equivalent to not doing this PR) or 10.9 I still get 'UpTime' is deprecated: first deprecated in macOS 10.8.

@jmagman

jmagman commented Dec 29, 2020

Copy link
Copy Markdown
Member Author

UpTime was deprecated in 10.8. Whether I set my project to 10.8, which is out of range (equivalent to not doing this PR) or 10.9 I still get 'UpTime' is deprecated: first deprecated in macOS 10.8.

Actually that experiment didn't make sense, it should have been 10.7 when that API wasn't deprecated. You're right, the deprecation warning does go away. However I'd still trade avoiding a warning for 100% of our users vs causing deprecation warnings for the ones that with pods using APIs deprecated before 10.9.

I really wish Xcode (it's not clang) didn't generate this warnings, or it was possible to turn it off. It's not very useful.

Comment thread packages/flutter_tools/bin/podhelper.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/(\d+).?(\d*)/ might be more precise though; there does need to be a first number.

Comment thread packages/flutter_tools/bin/podhelper.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To make the source of these numbers as clear as possible to future readers/maintainers, how about "Check if this is less than the minimum OS version supported by the latest stable version of Xcode (currently 10.9)"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The details are in the See MACOSX_DEPLOYMENT_TARGET note below. larger comment. I'll move it up.

Comment thread packages/flutter_tools/bin/podhelper.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic isn't correct; it treats 11.[0-8] as older. Would be good to add an 11.0 test case that would have caught that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well I failed the interview.

@stuartmorgan-g

Copy link
Copy Markdown
Contributor

However I'd still trade avoiding a warning for 100% of our users vs causing deprecation warnings for the ones that with pods using APIs deprecated before 10.9.

I guess that makes sense, given that a module developer who really wants to keep supporting old versions could do it with SDK ifdefs (although that's painful enough I'm not sure how many actually would). I do worry a bit about module developers getting reports of warnings they can't reproduce in their own builds, but hopefully it'll be clear enough.

@christopherfujino christopherfujino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@stuartmorgan-g

Copy link
Copy Markdown
Contributor

Was this ready for re-review? I thought it was waiting for a test update for the version comparison bug.

@jmagman

jmagman commented Jan 6, 2021

Copy link
Copy Markdown
Member Author

Was this ready for re-review? I thought it was waiting for a test update for the version comparison bug.

I wasn't going to set up Ruby testing infrastructure for just this. The integration test covers the positive test but I don't have a negative test (which would have caught my silly mistake). Any suggestions?

@stuartmorgan-g

Copy link
Copy Markdown
Contributor

Agreed Ruby testing would be overkill; I was assuming that the effect of that Ruby code would be to cause macos/Pods/Pods.xcodeproj/project.pbxproj not to contain a MACOSX_DEPLOYMENT_TARGET, in which case couldn't a test create a pod with a minimum version of 11, run a build, and validate that the file still has it?

@jmagman
jmagman force-pushed the macos-min-version branch from ae837c6 to f3231bd Compare January 8, 2021 01:56
// it's not a regression in the IPHONEOS_DEPLOYMENT_TARGET override logic.
// The plugintest target should not have IPHONEOS_DEPLOYMENT_TARGET set.
// See _reduceDarwinPluginMinimumVersion for details.
if (target == 'ios' && 'IPHONEOS_DEPLOYMENT_TARGET'.allMatches(podsProjectContent).length != 6) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@stuartmorgan I started out actually parsing the Xcode project for the plugintest target's build settings but that got pretty confusing. This count check is a bit of a cheat but it would definitely fail if the behavior was wrong or regressed...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense; I was thinking it wouldn't be in the project at all, so I didn't realize it would be non-trivial. Agreed that a full parser would be overkill here.

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

// it's not a regression in the IPHONEOS_DEPLOYMENT_TARGET override logic.
// The plugintest target should not have IPHONEOS_DEPLOYMENT_TARGET set.
// See _reduceDarwinPluginMinimumVersion for details.
if (target == 'ios' && 'IPHONEOS_DEPLOYMENT_TARGET'.allMatches(podsProjectContent).length != 6) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense; I was thinking it wouldn't be in the project at all, so I didn't realize it would be non-trivial. Agreed that a full parser would be overkill here.

@jmagman
jmagman merged commit 66145fe into flutter:master Jan 11, 2021
@jmagman
jmagman deleted the macos-min-version branch January 11, 2021 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. platform-macos 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.

3 participants