feat(apple): add Swift Package Manager support#1523
Open
TheoGermain wants to merge 17 commits intoBaseflow:mainfrom
Open
feat(apple): add Swift Package Manager support#1523TheoGermain wants to merge 17 commits intoBaseflow:mainfrom
TheoGermain wants to merge 17 commits intoBaseflow:mainfrom
Conversation
…n_handler_apple/)
…ATION_ALWAYS defines
2b31e06 to
44f9287
Compare
|
@TheoGermain, should the file |
Package.swift now walks up the directory tree from its own location to find the app's Info.plist and enables each permission define when the corresponding usage description key is present. This mirrors the CocoaPods workflow: adding NSCameraUsageDescription to Info.plist is all that is needed to activate PERMISSION_CAMERA, with no extra configuration files or terminal commands. Environment variables remain supported as an explicit override (priority over Info.plist), which covers PermissionGroup.notification and criticalAlerts that have no required Info.plist key. Users must clear DerivedData once after changing Info.plist so Xcode re-evaluates the manifest: rm -rf ~/Library/Developer/Xcode/DerivedData
Replace the launchctl setenv / pre-action script approach with the new Info.plist-based mechanism: permissions are now enabled automatically when the corresponding usage description key is present in Info.plist, which is already required for any permission to work at runtime. Document the two permissions without an Info.plist key (notification, criticalAlerts) as the only case still requiring an env var.
- Add all permission usage description keys to Info.plist so the SPM Info.plist auto-detection covers all permissions out of the box - Comment out the Siri entitlement (requires a paid Apple Developer account; uncomment to test PERMISSION_ASSISTANT) - Update AppDelegate to modern FlutterImplicitEngineDelegate pattern - Bump Podfile iOS platform to 13.0 - Remove docs/superpowers/plans/2026-05-05-spm-support.md (internal planning artifact not intended for the public repo)
Author
|
Good catch, thanks! The file has been removed in the latest commit, it was an internal planning artifact that shouldn't have been included. |
Comment on lines
+5
to
+6
| <!-- | ||
| Uncomment to test PERMISSION_ASSISTANT (requires a paid Apple Developer account): |
CanadianN1nj4
approved these changes
May 7, 2026
CanadianN1nj4
left a comment
There was a problem hiding this comment.
Super great work on this! I'm sure making sure everything still worked with cocoapods and transitioning was a good amount of effort!
Great Readme's too!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
cc @TimHoogstrate for review.
Summary
Package.swifttopermission_handler_apple/ios/permission_handler_apple/for Swift Package Manager compatibility (Flutter 3.24+)ios/Classes/toios/permission_handler_apple/Sources/permission_handler_apple/(SPM-standard layout)Info.plist:Package.swiftwalks up the directory tree to find the app'sInfo.plistand enables eachPERMISSION_Xdefine when the corresponding usage description key is present. No additional configuration needed beyond what is already required for permissions to work at runtime.PermissionGroup.notificationandPermissionGroup.criticalAlerts(no requiredInfo.plistkey) are still configurable via environment variablePackage.swiftSupersedes the work started in #1440.
Closes #1439
Closes #1516
Permission defines (SPM)
Permissions activate automatically when the usage description key is present in
Info.plist:calendar(< iOS 17)NSCalendarsUsageDescriptioncalendarFullAccess(iOS 17+)NSCalendarsFullAccessUsageDescriptionremindersNSRemindersUsageDescriptioncontactsNSContactsUsageDescriptioncameraNSCameraUsageDescriptionmicrophoneNSMicrophoneUsageDescriptionspeechNSSpeechRecognitionUsageDescriptionphotosNSPhotoLibraryUsageDescriptionphotosAddOnlyNSPhotoLibraryAddUsageDescriptionlocation/locationWhenInUseNSLocationWhenInUseUsageDescriptionlocationAlwaysNSLocationAlwaysAndWhenInUseUsageDescriptionmediaLibraryNSAppleMusicUsageDescriptionsensorsNSMotionUsageDescriptionbluetoothNSBluetoothAlwaysUsageDescriptionappTrackingTransparencyNSUserTrackingUsageDescriptionassistantNSSiriUsageDescriptionnotificationandcriticalAlertsrequirelaunchctl setenv PERMISSION_NOTIFICATIONS 1(noInfo.plistkey required by iOS).After adding or removing a key, clear DerivedData once:
rm -rf ~/Library/Developer/Xcode/DerivedDataTest plan
swift package dump-packagevalidates Package.swift syntaxpod installsucceeds on example app)flutter build ios --no-codesignpassesInfo.plist(camera, microphone verified)Info.plist+ clearing DerivedData disables the permission (no dialog, returnspermanentlyDenied)Notes