Skip to content

Conversation

@mravn-google
Copy link
Contributor

@mravn-google mravn-google commented Feb 8, 2018

Move injection of Flutter plugins from just before build to just after getting/updating pub packages.

Plugin injection here means

The intention is to get us to a situation where upon initial project checkout or change to pubspec.yaml, the only step needed to get to a project buildable by platform-specific tooling is flutter packages get.

Discrepancies between pubspec.yaml and injected plugin files have caused usability problems (#11797). And we have been forced to check in the injected files as if they were source code (#13554) to make our project examples work out of the box.

Fixes #12752
Fixes #11797
Fixes #13554

Copy link
Contributor

@jakobr-google jakobr-google left a comment

Choose a reason for hiding this comment

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

Concept LGTM!

Copy link
Contributor

Choose a reason for hiding this comment

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

:)

@mravn-google mravn-google changed the title [Concept review only] Move plugin injection to just after pub get Move plugin injection to just after pub get Feb 13, 2018
@mravn-google mravn-google force-pushed the dep_inj branch 2 times, most recently from 7a0fde0 to 645b251 Compare February 13, 2018 21:29
@mravn-google
Copy link
Contributor Author

@jakobr-google, @xster This PR is ready for code review.

Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

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

LGTM assuming this is PR 1 of many. Otherwise I may have some additional questions.


// Check if you need to run pod install.
// The pod install will run if any of below is true.
// 1. Any plugins changed (add/update/delete)
Copy link
Member

Choose a reason for hiding this comment

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

This is still true no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See item 3.

bool flutterPodChanged: true,
}) async {
if (await _checkPodCondition()) {
if (!fs.file(fs.path.join(appIosDir.path, 'Podfile')).existsSync()) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this implies we've built in some knowledge here that flutter run will necessarily run flutter packages get before and will never have cases where pod install is run in a project that doesn't have a Podfile?

Copy link
Contributor Author

@mravn-google mravn-google Feb 15, 2018

Choose a reason for hiding this comment

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

That's the idea. flutter run already invokes flutter packages get if your pubspec.yaml file has changed relative to your .packages and/or .pubspec.lock. So you'll get a Podfile if your project needs it and you don't already have one; it just isn't done by our buildXcodeProject code path.

I guess I should add checks for those assumptions here.

Copy link
Member

Choose a reason for hiding this comment

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

A check would be good to proof against future refactors by maintainers unaware of this contract.

if (plugins.isNotEmpty)
const CocoaPods().setupPodfile(directory);
if (changed)
_ensurePodInstallIsExecutedOnNextIOSBuild(directory);
Copy link
Member

Choose a reason for hiding this comment

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

Based on your PR description, wouldn't you want to run pod install here too?

i.e. is the desired outcome that after flutter packages get, the user can just open Xcode and press run?

Copy link
Member

Choose a reason for hiding this comment

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

Can we also move this into the cocoapods.dart? To keep the encapsulation and discoverability clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention of this PR is that flutter packages get brings the project into a state where platform-specific tooling works without flutter xxx help.

For Android that means Gradle builds work. Gradle nicely does both dependency resolution of non-pub packages and actual building.

The directly corresponding iOS situation is that Cocoapods+Xcode work. Doing pod install as part of flutter packages get would break this symmetry. That may be just an academic point, but we seem to have gone to great lengths to avoid doing pod install until there is no way around it (I assume because the pods repo is painful to download). If the user just wants to run her Flutter project on Android, pod install is not needed. We don't know the user's intention at flutter packages get time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move into cocoapods.dart: good point, done.

Copy link
Member

Choose a reason for hiding this comment

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

SG

projectPath: fs.currentDirectory.path,
buildInfo: buildInfo,
target: target,
hasPlugins: hasFlutterPlugins,
Copy link
Member

Choose a reason for hiding this comment

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

Depending on if I understood the PR description intent correctly, it sounds like you want to move this call to updateXcodeGeneratedProperties to flutter packages get in a future PR too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. I left that out because 1) it was not necessary on a newly created project, and 2) the properties include information like the build mode which is not available when we run flutter packages get.

But 1) is because flutter create generates the Generated.xcconfig file with some default settings along with a .gitignore entry that causes it not to be present on subsequent git checkout. And for 2) those default settings can be used during flutter packages get too.

@xster
Copy link
Member

xster commented Feb 14, 2018

Should we add some new gitignores too?

@mravn-google
Copy link
Contributor Author

@xster There is a follow-up PR to remove generated files and update gitignore: #14697

@mravn-google
Copy link
Contributor Author

@xster Thanks for the review. I've restructured some of the code to make the intention clearer. I also worked on improving test coverage. PTAL and let me know whether your concerns have been addressed by the changes and the comments above.

Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

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

LGTM

@mravn-google mravn-google merged commit b3e4976 into flutter:master Feb 15, 2018
@mravn-google mravn-google deleted the dep_inj branch February 15, 2018 21:17
mravn-google added a commit that referenced this pull request Feb 15, 2018
mravn-google added a commit that referenced this pull request Feb 15, 2018
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

4 participants