-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add Swift Package Manager docs #10827
Conversation
Visit the preview URL for this PR (updated for commit 32a0c1c): https://flutter-docs-prod--pr10827-spm-compatibility-ilxd3b00.web.app |
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
Package Manager yet. | ||
::: | ||
|
||
## How to disable Swift Package Manager |
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.
Ideally app developers enable SwiftPM and never disable it.
However, plugin developers need to enable/disable SwiftPM to test their plugin works with both package managers.
|
||
[flutter#146957]: https://github.com/flutter/flutter/issues/146957 | ||
|
||
## How to add Swift Package Manager integration to a project manually |
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.
Our hope is that the automatic migration will migrate most projects. Most users shouldn't need to follow these steps.
However, users might have modified their project in a way that breaks out automatic migration. Ideally these users would let us know about these modifications so that we can improve our automatic migration.
Question for reviewers: Is it clear that most people can skip these steps?
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.
suggestion: Remove manually. If the reader is doing something, then it's manual by definition.
## How to add Swift Package Manager integration to a project manually | |
## How to add Swift Package Manager integration to a project |
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 removed manually from the section header but clarified the section intro to clarify these steps are only necessary if the automatic migration fails.
Edit: After feedback from Seth, I restructured the page and re-added the manually
qualifier. See: #10827 (comment)
{% endtab %} | ||
{% endtabs %} | ||
|
||
## How to use a Swift Package Manager Flutter plugin that requires a higher OS version |
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.
This is a new kind of error that users can hit when using SwiftPM.
image:"development/packages-and-plugins/swift-package-manager/minimum-deployments.png", | ||
caption:"The target's Minimum Deployments setting" %} | ||
|
||
## How to add Swift Package Manager integration to a custom target |
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.
This is for less common scenarios where users have heavily modified their project. Most users won't need these steps. Please let me know if there's a better way to call out this special case without making the "manual migration" docs overly convoluted.
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.
Maybe "to a custom Xcode target" and then explain what that means in the first sentence?
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.
Added!
|
||
In Step 2, list item 6 use your custom target instead of the Flutter target. | ||
|
||
## How to remove Swift Package Manager integration |
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 theory no one needs to do these steps unless there's a horrible bug in our SwiftPM integration. If you want to use CocoaPods to download native dependencies, you can disable the SwiftPM feature (the SwiftPM integration will still be there but it won't add any native dependencies to your project).
src/content/packages-and-plugins/swift-package-manager/for-plugin-authors.md
Outdated
Show resolved
Hide resolved
src/content/packages-and-plugins/swift-package-manager/for-plugin-authors.md
Outdated
Show resolved
Hide resolved
It is currently only available on the [`master` channel][]. | ||
Flutter will continue to support CocoaPods until further notice. | ||
|
||
Swift Package Manager adoption will be gradual. |
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 we don't know how the qualify this, not sure we need to say this. I get the sense we want to migrate the ecosystem faster than slower (but, not recklessly)
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.
Ah did you read this as: "Feel free to take your time, no rush on this migration"?
The intent behind this sentence was slightly different: plugin authors should not make plugins that only support SwiftPM. This would break users that haven't updated their projects yet. Plugin should support both CocoaPods and SwiftPM until further notice.
I'll rephrase to make this clearer :)
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 tweaked this intro, let me know if it's clearer now.
Swift Package Manager adoption will be gradual. | ||
|
||
Flutter recommends that Flutter plugins support _both_ Swift Package Manager | ||
and CocoaPods until further notice. |
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 that's not easy to do, should we link to guidance for how to support both?
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.
This guidance does make your plugin support both package managers. I'll add a blurb to clarify this.
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 tweaked this intro, let me know if it's clearer now.
src/content/packages-and-plugins/swift-package-manager/index.md
Outdated
Show resolved
Hide resolved
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.
Hi, @loic-sharma! Thanks so much for this PR. I have reviewed a chunk of it, but some pages have the same text (and therefore require the same edits). Let me know when you are ready for me to take another look.
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
:::note | ||
Flutter will fallback to CocoaPods for dependencies that do not support Swift | ||
Package Manager yet. | ||
::: |
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.
:::note | |
Flutter will fallback to CocoaPods for dependencies that do not support Swift | |
Package Manager yet. | |
::: | |
:::secondary Plugin authors | |
A Flutter app can have a dependencies from both CocoaPods and | |
SwiftPM at the same time. However, mixing dependencies from both | |
package managers can cause issues so, ideally, all iOS plugin authors | |
add SwiftPM support ASAP. | |
::: |
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.
This isn't quite right. A Flutter app can have a dependencies from both CocoaPods and SwiftPM at the same time. However, mixing dependencies from both package managers can cause issues so ideally everyone adds SwiftPM support ASAP.
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.
Additional context: an app could have a dependency that only supports SwiftPM and another dependency that only supports CocoaPods. We have to use both package managers in this scenario.
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 defer to you on the wording...
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
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.
Thank you so much for tackling this!
- title: For app developers | ||
permalink: /packages-and-plugins/swift-package-manager/for-app-developers |
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'm not sure app developers would think to go into Packages & plugins
Maybe this should move into Platform integration
? Though it would make sense under iOS and macOS, and we don't have a shared category. Whatever you and the tech writers think works best.
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.
oh, good idea!
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.
Sorry for the slow response, I'd like to test if I can link to this page twice: once from the packages & plugin section and once from the platform integration section. Will loop back soon!
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,84 @@ | |||
Once you [turn on Swift Package Manager][] support, the Flutter CLI tries to | |||
migrate your project to add Swift Package Manager integration. | |||
This makes your project download the Swift packages that your Flutter |
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.
maybe a bit more clear to say "the Flutter tooling downloads the Swift packages" ?
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 agree this sentence is a little opaque. I was hoping to hand-wavy explain why your project needs to be migrated without going too deep in the weeds. I'll see if I can add a little more detail here.
Swift packages are downloaded by Xcode, not the Flutter tool.
The process is roughly:
- The Flutter tool downloads pub packages
- The Flutter tool generates a Swift package that depends on each iOS/macOS plugin
- Xcode's build step resolves packages. This starts with the generated Swift package, and then downloads each iOS/macOS plugin's dependencies.
The "Swift Package Manager integration" is your project's dependency on the Swift package that is generated by step 2. The Flutter tool migrates your Xcode project to add this dependency.
This makes your project download the Swift packages that your Flutter | ||
plugins depend on. | ||
|
||
However, the Flutter CLI might be unable to migrate your project if you've |
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.
Do we mean "even if you've modified it significantly" ?
Note: "even" 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.
We can migrate projects unless they've received heavy modifications.
We match do "match and replace" in your Xcode project to migrate it. This should work fine if your project is based off Flutter's templates. However, our matching logic can break if you've modified your Xcode project. The bigger your modifications, the more likely our matching logic breaks.
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 guess I'm wondering if we need the "significantly" qualifier?
ideas:
"The Flutter CLI attempts to migrate your project to Swift Package Manager, even if you have made changes to . If the Flutter CLI tool is unable to migrate your project (for example, if there are unexpected modifications to Foo or Bar), then the Flutter CLI tool will ."
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.
Ah gotcha, I dropped the "significantly" qualifier and switched to wording similar to what you suggested.
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
src/_includes/docs/swift-package-manager/migrate-macos-project-manually.md
Outdated
Show resolved
Hide resolved
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 : I suggested changes to one file. Review and accept/decline and apply those you accept to the other pages. Thanks!
Flutter is migrating to [Swift Package Manager][] to manage iOS and macOS native | ||
dependencies. | ||
This is an experimental feature that might change in the future. | ||
It is currently only available on the [`main` channel][]. | ||
Flutter will continue to support CocoaPods until further notice. |
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.
issue: Condition, then instruction per GSG.
Keep the documentation timeless per GSG.
Flutter is migrating to [Swift Package Manager][] to manage iOS and macOS native | |
dependencies. | |
This is an experimental feature that might change in the future. | |
It is currently only available on the [`main` channel][]. | |
Flutter will continue to support CocoaPods until further notice. | |
To manage iOS and macOS native dependencies, | |
Flutter is migrating to [Swift Package Manager][] . | |
Flutter's support of SPM as described in this guide is under development. | |
The implementation might change in the future. | |
SPM support can be found on the [`main` channel][] only. | |
Flutter continues to support CocoaPods. |
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.
Normally I agree that "condition, then instruction" is better, but I think it makes the first sentence choppy. I personally prefer the original first sentence. How strongly do you feel about this?
I updated the remaining sentences!
macOS. | ||
|
||
If you find a bug in Flutter's Swift Package Manager support, | ||
please [open an issue][]. |
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.
issue: Remove please per GSG.
please [open an issue][]. | |
[open an issue][]. |
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.
This feels curt to me, but updated :(
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
|
||
[flutter#146957]: https://github.com/flutter/flutter/issues/146957 | ||
|
||
## How to add Swift Package Manager integration to a project manually |
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.
suggestion: Remove manually. If the reader is doing something, then it's manual by definition.
## How to add Swift Package Manager integration to a project manually | |
## How to add Swift Package Manager integration to a project |
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
src/content/packages-and-plugins/swift-package-manager/for-app-developers.md
Outdated
Show resolved
Hide resolved
1. **Access to the Swift package ecosystem**. | ||
Flutter plugins can use the growing ecosystem of [Swift packages][]! | ||
2. **Simplifies Flutter installation**. | ||
Swift Package Manager is bundled with Xcode. | ||
In the future, you won’t need to install Ruby and CocoaPods to target iOS or | ||
macOS. |
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.
issue:
- Use parallel structure in your list sentences.
- Remove the exclamation point per GSG.
- Keep the documentation timeless.
- Use present tense.
1. **Access to the Swift package ecosystem**. | |
Flutter plugins can use the growing ecosystem of [Swift packages][]! | |
2. **Simplifies Flutter installation**. | |
Swift Package Manager is bundled with Xcode. | |
In the future, you won’t need to install Ruby and CocoaPods to target iOS or | |
macOS. | |
1. **Provides access to the Swift package ecosystem**. | |
Flutter plugins can use the growing ecosystem of [Swift packages][]! | |
1. **Simplifies Flutter installation**. | |
Xcode includes Swift Package Manager. | |
Targeting iOS or macOS doesn't require Ruby and CocoaPods. |
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.
This sounds good but I tweaked the last sentence:
- Targeting iOS or macOS doesn't require Ruby and CocoaPods.
+ You don't need to install Ruby and CocoaPods if your project uses
+ Swift Package Manager.
Let me know what you think!
Plugins that don't support CocoaPods won't be usable by projects that haven't | ||
migrated to Swift Package Manager yet. | ||
Plugins that don't support Swift Package Manager can cause problems for projects | ||
that have migrated. |
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.
It might be nice to explicitly say here that we expect to remove support for CocoaPods at some point in the future, so adding SPM support will future-proof plugins. That will make it more clear why a plugin author should do this work.
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.
Agreed.
@atsansone What would be the best way to state this while following the timeless GSG?
Flutter expects to remove support for CocoaPods. Adding Swift Package Manager support future-proofs your plugins.
I think this would be a valuable sentence to add, but it goes against the GSG guidance.
- title: For app developers | ||
permalink: /packages-and-plugins/swift-package-manager/for-app-developers |
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.
oh, good idea!
src/_includes/docs/swift-package-manager/how-to-enable-disable.md
Outdated
Show resolved
Hide resolved
This makes your project download the Swift packages that your Flutter | ||
plugins depend on. | ||
|
||
However, the Flutter CLI might be unable to migrate your project if you've |
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 guess I'm wondering if we need the "significantly" qualifier?
ideas:
"The Flutter CLI attempts to migrate your project to Swift Package Manager, even if you have made changes to . If the Flutter CLI tool is unable to migrate your project (for example, if there are unexpected modifications to Foo or Bar), then the Flutter CLI tool will ."
|
||
{% include docs/swift-package-manager/how-to-enable-disable.md %} | ||
|
||
## How to add Flutter to an existing app (add-to-app) |
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.
this was a surprising header in this file, and it was surprising to see this first before "how to add SPM to a project".
Consider:
- How to add SPM to a full Flutter app
- How to migrate to SPM for a Flutter add-to-app scenario
Not yet supported, follow this bug, etc...
In this way, the headers rhyme and are clear about their scenarios. WDYT?
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.
This is excellent feedback. The guide was misleading: hopefully no one needs to do the manual steps. I restructured the page and added a guide dedicated to the auto migration. I also renamed these headers to align better. See: #10827 (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 - i was able to get the pedometer
sample up and running with these instructions.
@sfshaza2 @atsansone @sethladd Hey there, I re-structured the "For app developers page": Summary of changes:
This was in response to Seth's comment here: #10827 (comment) Please let me know what you think! |
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 - thank you!
@loic-sharma, thanks for all of these updates and hanging in there! I'm going to land this. If there are further tweaks, they can be handled in another PR. |
Flutter iOS/macOS is migrating to Swift Package Manager for native dependencies. This is an experimental feature this isn't ready yet for app developers. However, plugin authors should add Swift Package Manager support to their packages.
The faster plugin authors add SwiftPM support, the sooner we can drop CocoaPods (and make it easier to install Flutter iOS!). There's ~10K Flutter iOS plugins that'll need to migrate, so we really need the plugin migration docs to be as easy to follow as possible. Any and all feedback is appreciated! :)
This is based off @vashworth's guide.
Question for reviewers: What do you think of the doc structure? Should we rearrange things to make it clearer that some sections are to be followed when things go wrong? Or is the current structure clear enough?
Preview URLs:
Part of flutter/flutter#126005
Presubmit checklist