-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Detect plugins based on .flutter-plugins-dependencies; avoid refreshing twice in iOS/MacOS
#157393
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
Detect plugins based on .flutter-plugins-dependencies; avoid refreshing twice in iOS/MacOS
#157393
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
.flutter-plugins-dependencies for hasPlugins.FlutterCommand to refreshPluginsList; use .flutter-plugins-dependencies for hasPlugins.
FlutterCommand to refreshPluginsList; use .flutter-plugins-dependencies for hasPlugins..flutter-plugins-dependencies; avoid refreshing twice in iOS/MacOS
f61fb9c to
aad7ef5
Compare
| project, | ||
| iosPlatform: project.ios.existsSync(), | ||
| macOSPlatform: project.macos.existsSync(), | ||
| forceCocoaPodsOnly: forceCocoaPodsOnly, |
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.
In #157391 (comment) I said
I don't think it was added in #146256, but the call site parameters were changed.
This was true, but I think the logic added in that PR was intended to forceCocoaPodsOnly for add-to-app, since add-to-app currently only supports CocoaPods and not Swift Package Manager.
flutter/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
Lines 263 to 268 in 7504abc
| await processPodsIfNeeded( | |
| project.ios, | |
| getIosBuildDirectory(), | |
| buildInfo.mode, | |
| forceCocoaPodsOnly: true, | |
| ); |
| result['swift_package_manager_enabled'] = !forceCocoaPodsOnly && project.usesSwiftPackageManager; |
However, build_ios_framework_module_test (post-submit only test) would test this, so I checked this out, set flutter config --enable-swift-package-manager, and it still passed. Which makes sense because that project.usesSwiftPackageManager explicitly checks if it's an add-to-app module (!isModule).
flutter/packages/flutter_tools/lib/src/project.dart
Lines 269 to 272 in 7504abc
| bool get usesSwiftPackageManager { | |
| if (!manifest.disabledSwiftPackageManager && | |
| (ios.existsSync() || macos.existsSync()) && | |
| !isModule) { |
All that to say, I still think this isn't needed, but not for the reason I said before.
@loic-sharma can you check my work here?
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.
Which makes sense because that
project.usesSwiftPackageManagerexplicitly checks if it's an add-to-app module (!isModule).
...and I just remembered that command can be run from a normal flutter created iOS or macOS app, not just a module.
On this PR:
$ flutter config --enable-swift-package-manager
$ flutter create test_create
$ cd test_create
$ flutter pub add camera
$ flutter build ios-framework --xcframework --no-debug --no-profile
$ ls build/ios/framework/Release/
On master that directory contains camera_avfoundation.xcframework, but on this PR it doesn't.
.flutter-plugins-dependencies should have swift_package_manager_enabled false at this point.
"swift_package_manager_enabled":true
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.
@loic-sharma this would be a good integration test to add.
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 flutter build ios-framework command acts unexpectedly on a non-module project if Swift Package Manager is enabled. If I do this:
flutter build ios-framework --xcframework --no-debug --no-profile
The build completes, however, this unexpectedly generates a Swift package manifest that includes plugins and then later deletes it.
Interestingly, the produced App.xframework doesn't seem to statically link against the plugins?
$ nm --extern-only --just-symbol-name build/ios/framework/Release/App.xcframework/ios-arm64/App.framework/App -arch arm64
_kDartIsolateSnapshotData
_kDartIsolateSnapshotInstructions
_kDartVmSnapshotData
_kDartVmSnapshotInstructions
dyld_stub_binder
I'll need to dig into this 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.
Sounds good, thanks for looking at this!
I am not explicitly blocked, but I would like to know (can be tomorrow) if I should expect to pursue this change (that is, it should be OK if other bugs or considerations are fixed) or if I should expect to drop it (in which case I might want to just opt-out all users of processPodsIfNeeded from generating .flutter-plugins: #157393 (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.
I suspect you should drop this for now and reassign to me. I should clean this up as part of adding add-to-app support to SwiftPM. Thoughts @jmagman?
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.
Based on https://github.com/flutter/flutter/pull/157393/files#r1811810540 this will make iOS add-to-app framework stop being generated (sorry I didn't think it all through before I said to go for this, @matanlurey)
I'm not familiar with this command or workflow - is there a way to either (a) make the command that triggers this trigger the |
|
One workaround if we don't want to land this - I could hardcode |
|
I'm not familiar with this area. Let me read up a bit and I'll loop back on the things I was tagged on! :) |
I vote this. I meant to ask why it running twice (which is bad) is related to moving off the deprecated |
|
Sounds good, thanks for the discussion! I reassigned #157391 and will open a smaller scope PR for |
…t`. (#157527) Work towards #48918. Workaround for #157391 (see #157393 (comment)). I'll run all post-submit tasks as well on this PR using `test: all`.
Closes #157391.
Two small but interconnected changes here:
hasPluginsto use the presence of.flutter-plugins-dependencies, not.flutter-pluginsprocessPodsIfNeededto rely on the implicitrefreshPluginsListprovided byFlutterCommand.