[WIP] Add Swift Package Manager support #1440
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR relates to #1439
This pull request (PR) aims to implement Swift Package Manager (SPM) support while maintaining CocoaPods. It also tracks progress on streamlining the developer experience. This PR is open for discussion, welcoming new ideas and feedback on any issues or omissions.
I've implemented an SPM file and updated the podspec file to point to the new source files. I've also created the folder structure suggested by the Flutter team in their SPM migration article: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors#116-tab-panel.
To run the Example app with SPM, remove (or rename) the Podfile and execute
pod deintegrate
in the example app's iOS folder. Then, enable SPM in Flutter withflutter config --enable-swift-package-manager
and executeflutter run
with the following environment variable exports:I've chosen to activate permission modules through environment variables, similar to the approach described here: Conditionally compile code in a Flutter plugin using Swift Package Manager. This simplifies the process. A potential improvement is creating an xcconfig file containing the desired permissions as variables. This file could then be imported into the Release or Debug xcconfig files, making it a one-time setup and eliminating the need to export these variables for each run.
Here are some useful links with additional information:
Pre-launch Checklist
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.CHANGELOG.md
to add a description of the change.///
).main
.dart format .
and committed any changes.flutter analyze
and fixed any errors.