-
Notifications
You must be signed in to change notification settings - Fork 358
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 support #1276
Comments
I followed the instructions in the migration guide and got these XCode errors after performing step Here is what the PR looked like at that point: |
Oops the instructions were incorrect. The files in I sent a docs fix here: flutter/website#11029 |
This was caught by @brianquinlan while migrating the `cupertino_http` plugin. Review URL: https://flutter-docs-prod--pr11029-brian-feedback-9wffzaxo.web.app/packages-and-plugins/swift-package-manager/for-plugin-authors#how-to-add-swift-package-manager-support-to-an-existing-flutter-plugin Part of: dart-lang/http#1276 (comment) ## Presubmit checklist - [x] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
Sorry for the long delay - some unrelated changes needed to be made before I could make progress on this. I don't understand how the header files should be organized. I initially placed all of my headers in "darwin/cupertino_http/Sources/cupertino_http/include/cupertino_http". The worked for top level includes but it did not work for includes in the "dart-sdk" directory (with the podspec build):
I didn't understand the phrase in the documentation: "You should consider whether you want all of your headers to be public." When do my headers need to be public vs. non-public? What do I do if I don't want my headers to be public? Since, AFAIK, I don't need any of my headers to be public, I assumed that the includes should be in the same directory as the sources. That is the current state of #1288. But it can't seem to find any headers (with the podspec build):
@loic-sharma Please advise ;-) |
Thanks for the feedback! I'll take a closer look at this tomorrow, but some initial responses:
I'll investigate tomorrow!
If a header contains APIs that are meant to be called by code outside of your plugin, it must be public. If a header contains APIs that are only internal for the plugin, ideally the header file would be non-public. However, it's very common for CocoaPod packages to just make all their headers public. This isn't ideal, folks could start using your internal APIs in unexpected ways; changing your implementation could be an unintentional breaking change. However, converting public header files to non-public is technically also a breaking change.
Thanks that's good feedback. I'll expand that section! |
@brianquinlan I checked out #1288, and I got different build errors than the one you reported above. I was able to fix the build errors I ran into using this patch: diff --git a/pkgs/cupertino_http/darwin/cupertino_http.podspec b/pkgs/cupertino_http/darwin/cupertino_http.podspec
index 9e09c66..5bd2846 100644
--- a/pkgs/cupertino_http/darwin/cupertino_http.podspec
+++ b/pkgs/cupertino_http/darwin/cupertino_http.podspec
@@ -12,6 +12,7 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http'
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'TODO' => 'use-valid-author' }
+ s.source = { :http => 'https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http' }
s.source_files = 'cupertino_http/Sources/cupertino_http/**/*'
s.ios.dependency 'Flutter'
diff --git a/pkgs/cupertino_http/darwin/cupertino_http/Package.swift b/pkgs/cupertino_http/darwin/cupertino_http/Package.swift
index 017f286..7da45e8 100644
--- a/pkgs/cupertino_http/darwin/cupertino_http/Package.swift
+++ b/pkgs/cupertino_http/darwin/cupertino_http/Package.swift
@@ -32,8 +32,9 @@ let package = Package(
],
cSettings: [
// TODO: Update your plugin name.
- .headerSearchPath("include")
- .headerSearchPath("include/cupertino_http")
+ //.headerSearchPath("include"),
+ .headerSearchPath("include/cupertino_http"),
+ .unsafeFlags(["-fno-objc-arc"]),
]
)
] Here's my fork with this patch applied: loic-sharma@12c1867 With this patch, the following steps work as expected:
Could you try that patch and let me know if that fixes your build issues? If it doesn't, could you share: what steps you're using to get that build error, which Flutter SDK version you're on, which Xcode version you're on. Also, feel free to drop something on my calendar if you want to hack on this together :) |
@loic-sharma That does fix my build issues and the CocoaPods build works fun. Unfortunately, the Swift Package Manager version fails at runtime.
The Objective-C code is being built because, if I introduce a syntax error, the run fails and I see an error message. Using CocoaPods:
I can't find an equivalent file with the swift build. |
Hello,
Flutter is migrating to Swift Package Manager. Please add Swift Package Manager support to your plugin.
Flutter will eventually deprecate and then remove support for CocoaPods. Adding Swift Package Manager support future-proofs your plugins.
How to add Swift Package Manager support to your plugins
You can find the migration guide here: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors#how-to-add-swift-package-manager-support-to-an-existing-flutter-plugin
If you run into issues or have questions, please reach out to the Flutter team. You can ping me at @loic-sharma, send a message to the #hackers-ios channel on Flutter’s discord, or open a GitHub issue.
Thank you for your wonderful contributions to the Flutter ecosystem!
Why is Flutter migrating to Swift Package Manager?
Swift Package Manager support is one of Flutter’s most requested features: flutter#33850.
Flutter's Swift Package Manager integration has several benefits:
The text was updated successfully, but these errors were encountered: