You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SPM] Add Swift Package Manager support for iOS #8
Flutter has been migrating to Swift Package Manager as the primary mechanism for managing iOS and macOS native dependencies since Flutter 3.24. SPM will be the default for all Flutter apps starting from the next stable release (3.44), and CocoaPods support will eventually be deprecated and removed.
Currently, flutter_env_native only ships a .podspec file and no Package.swift, which causes the Flutter CLI to emit the warning below. Flutter does fall back to CocoaPods for plugins that do not yet support SPM, so builds are not broken today — but the warning states explicitly that this will become a hard error in a future Flutter release, at which point iOS builds will fail for all users of this plugin.
The following plugins do not support Swift Package Manager for ios:
- flutter_env_native
This will become an error in a future version of Flutter. Please contact the plugin maintainers to request Swift Package Manager adoption.
Affected Platforms
iOS
macOS (if applicable — e.g. sign_in_with_apple ships a macOS target)
Reproduction Steps
Enable SPM in your Flutter environment:
flutter config --enable-swift-package-manager
Add this plugin to pubspec.yaml and run flutter pub get.
Run the app:
flutter run
Observe the following warning in terminal output:
The following plugins do not support Swift Package Manager for ios:
- <plugin_name>
This will become an error in a future version of Flutter.
Expected Behavior
The plugin ships a valid Package.swift at ios/Package.swift (and optionally macos/Package.swift) alongside the existing .podspec, so that both CocoaPods and SPM are supported during the transition period and no warning is emitted.
Migration Guide
The Flutter team has published an official migration guide for plugin authors:
Adding a Package.swift to the ios/ (and macos/) directory of the plugin.
Restructuring source files under Sources/<plugin_name>/ to comply with SPM conventions.
Keeping the existing .podspec intact so CocoaPods users are not affected.
Running the example app with SPM enabled to verify the integration.
Both CocoaPods and SPM can coexist during the transition — this is explicitly supported and encouraged by the Flutter team.
Why This Matters
Flutter's SPM integration gives plugins access to the growing Swift package ecosystem and simplifies installation since SPM is bundled with Xcode — removing the need for Ruby and CocoaPods entirely.
Flutter will eventually deprecate and then remove CocoaPods support. Adding SPM support now future-proofs the plugin.
SwiftPM is expected to be the default for all Flutter apps in the next stable release (3.44).
Additional Notes
Flutter currently falls back to CocoaPods for dependencies that do not support SPM yet, so existing apps are not immediately broken.
For permission_handler_apple specifically: there is already [a WIP pull request (#1440)]([WIP] Add Swift Package Manager support Baseflow/flutter-permission-handler#1440) exploring this migration. That PR moves source files to an SPM-compliant structure under ios/permission_handler_apple/Sources/, adds a Package.swift with environment-based permission defines, updates the podspec to reference the new file locations, and adds CI matrix testing for both CocoaPods and SPM — it may be worth picking that work up and getting it merged.
For questions, the Flutter team can be reached on the #hackers-ios channel on Flutter's Discord, or via a GitHub issue on the main Flutter repository.
Right now my builds still work because Flutter intelligently manages both SPM and CocoaPods dependencies in parallel — plugins without a Package.swift are automatically handled by a fallback Podfile, while SPM-capable plugins are resolved through SPM.
Swift Package Manager support needed
Flutter has been migrating to Swift Package Manager as the primary mechanism for managing iOS and macOS native dependencies since Flutter 3.24. SPM will be the default for all Flutter apps starting from the next stable release (3.44), and CocoaPods support will eventually be deprecated and removed.
Currently,
flutter_env_nativeonly ships a .podspec file and no Package.swift, which causes the Flutter CLI to emit the warning below. Flutter does fall back to CocoaPods for plugins that do not yet support SPM, so builds are not broken today — but the warning states explicitly that this will become a hard error in a future Flutter release, at which point iOS builds will fail for all users of this plugin.Affected Platforms
sign_in_with_appleships a macOS target)Reproduction Steps
pubspec.yamland runflutter pub get.Expected Behavior
The plugin ships a valid
Package.swiftatios/Package.swift(and optionallymacos/Package.swift) alongside the existing.podspec, so that both CocoaPods and SPM are supported during the transition period and no warning is emitted.Migration Guide
The Flutter team has published an official migration guide for plugin authors:
In short, the migration involves:
Package.swiftto theios/(andmacos/) directory of the plugin.Sources/<plugin_name>/to comply with SPM conventions..podspecintact so CocoaPods users are not affected.Both CocoaPods and SPM can coexist during the transition — this is explicitly supported and encouraged by the Flutter team.
Why This Matters
Additional Notes
permission_handler_applespecifically: there is already [a WIP pull request (#1440)]([WIP] Add Swift Package Manager support Baseflow/flutter-permission-handler#1440) exploring this migration. That PR moves source files to an SPM-compliant structure underios/permission_handler_apple/Sources/, adds aPackage.swiftwith environment-based permission defines, updates the podspec to reference the new file locations, and adds CI matrix testing for both CocoaPods and SPM — it may be worth picking that work up and getting it merged.#hackers-ioschannel on Flutter's Discord, or via a GitHub issue on the main Flutter repository.Package.swiftare automatically handled by a fallback Podfile, while SPM-capable plugins are resolved through SPM.Flutter Version
Thank you for maintaining this plugin —t's widely used and keeping it forward-compatible would be much appreciated! Happy to help test if needed.