Mastersam07 / Mastersam07/flutter_env_native

[SPM] Add Swift Package Manager support for iOS

Open
#8 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
13
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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_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

  1. Enable SPM in your Flutter environment:
    flutter config --enable-swift-package-manager
    
  2. Add this plugin to pubspec.yaml and run flutter pub get.
  3. Run the app:
    flutter run
    
  4. 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:

📖 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

In short, the migration involves:

  • 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)](https://github.com/Baseflow/flutter-permission-handler/pull/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.

Flutter Version

flutter --version
Flutter 3.44.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 924134a44c (5 days ago) • 2026-05-29 12:13:22 -0400
Engine • hash 39b1f7043775b9578bbb26a1676e79c4e31c8b5e (revision c416acfeb8) (6 days ago) • 2026-05-27
20:19:31.000Z
Tools • Dart 3.12.1 • DevTools 2.57.0


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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing iOS .podspec and the migration guide, then review WIP pull request #1440 for the proposed Sources/ layout and Package.swift configuration. Preserve CocoaPods support, add the iOS SPM package, and run the example app with SPM enabled to verify that the warning is gone; assess macOS support if applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, ios, swift
Domain
build-system, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.