Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] Add Swift Package Manager support #1440

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

engels-all-win-software
Copy link

@engels-all-win-software engels-all-win-software commented Feb 3, 2025

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 with flutter config --enable-swift-package-manager and execute flutter run with the following environment variable exports:

PERMISSION_EVENTS=1 PERMISSION_EVENTS_FULL_ACCESS=1 PERMISSION_REMINDERS=1 PERMISSION_CONTACTS=1 PERMISSION_CAMERA=1 PERMISSION_MICROPHONE=1 PERMISSION_SPEECH_RECOGNIZER=1 PERMISSION_PHOTOS=1 PERMISSION_LOCATION=1 PERMISSION_LOCATION_WHENINUSE=1 PERMISSION_NOTIFICATIONS=1 PERMISSION_MEDIA_LIBRARY=1 PERMISSION_SENSORS=1 PERMISSION_BLUETOOTH=1 PERMISSION_APP_TRACKING_TRANSPARENCY=1 PERMISSION_CRITICAL_ALERTS=1 PERMISSION_ASSISTANT=1 flutter run

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

  • I made sure the project builds.
  • [ x I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I rebased onto main.
  • I added new tests to check the change I am making, or this PR does not need tests.
  • I made sure all existing and new tests are passing.
  • I ran dart format . and committed any changes.
  • I ran flutter analyze and fixed any errors.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant