Skip to content

Add Swift Package Manager support #195

Closed

Description

@abdallahshaban557

Hello,

Flutter is migrating to Swift Package Manager. Please add Swift Package Manager support to your plugin.

SwiftPM will be the default for all Flutter apps in the next stable release (3.44). To ensure your plugin remains compatible and prevents build failures for your users, please migrate to SwiftPM

Flutter will eventually deprecate and then remove support for CocoaPods. Adding Swift Package Manager support future-proofs your plugins.

How to add Swift Package Manager support to your plugins

You can find the migration guide here: 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

If you run into issues or have questions, please reach out to the Flutter team. You can send a message to the #hackers-ios channel on Flutter's discord or open a GitHub issue.

Thank you for your wonderful contributions to the Flutter ecosystem!

Why is Flutter migrating to Swift Package Manager?

CocoaPods is now in maintenance mode.

Swift Package Manager support is one of Flutter's most requested features: flutter#33850.

Flutter's Swift Package Manager integration has several benefits:

  1. Access to the Swift package ecosystem. Flutter plugins can use the growing ecosystem of Swift packages.
  2. Simplifies Flutter installation. Swift Package Manager is bundled with Xcode. In the future, you won't need to install Ruby and CocoaPods to target iOS or macOS.

Activity

  1. amrgetment commented on May 19, 2026

    @amrgetment

    This warning is currently shown on Flutter 3.44.0 and is expected to become an error in the first Flutter release after 3.44.0.

    Flutter Swift Package Manager warning

  2. GeorgePagMezzi commented on May 22, 2026

    @GeorgePagMezzi

    This is pretty important for us as well as we will be unable to move to newer flutter versions if this does not get supported.

  3. GeorgePagMezzi commented on Jun 26, 2026

    @GeorgePagMezzi

    Any updates on this?

  4. vitormf commented on Jul 7, 2026

    @vitormf

    @sunitaprajapati89 @MichaelGHSeg @neelkanth-kaushik
    I see SPM support is already merged and just pending a release, but the last one was 7 months ago. Do you have any idea when the next release might go out?

    Asking because Cocoapods is no longer in development. Flutter explicitly says support will be removed in a future release and lists Segment as an unsupported library, so this is becoming a bit of a blocker for us.

  5. MichaelGHSeg commented on Jul 8, 2026

    @MichaelGHSeg
    Contributor

    Some new company-wide security requirements have significantly slowed us down. We're trying to get a release out soon. In the meantime, for a less than ideal workaround, you could direct your dependency to our git repo:

    segment_analytics:
        git:
          url: https://github.com/segmentio/analytics_flutter
          ref: ee4e5b4
          path: packages/core
    

    or fork our repo yourself if you want more control.

  6. lazytesting commented on Jul 23, 2026

    @lazytesting

    @MichaelGHSeg any news on this?

  7. MichaelGHSeg commented on Jul 30, 2026

    @MichaelGHSeg
    Contributor

    Thanks for your patience. We finally got the green light to do a release, it should be available now. Let us know if there are any issues.

  8. lazytesting commented on Jul 30, 2026

    @lazytesting
  9. Anderzzon commented on Aug 5, 2026

    @Anderzzon

    We still get the warning that this plugin doesn't support SPM. It would also be great if you could update to the latest version of flutter_fgbg

  10. ArthurMassonBit commented on Aug 11, 2026

    @ArthurMassonBit

    Hi @MichaelGHSeg,
    Running on the iOS 26.3 simulator and an iOS 26.4.2 physical device, with segment_analytics: 1.1.12 the warning still appears, and the package is only running via CocoaPods.

    Image
    • Also, it would be great if you could update the flutter_fgbg dependency. (According to the changelogs, SPM it's available in flutter_fgbg: 0.8.0)

    Could you please take a look?
    Thanks!

  11. sunitaprajapati89 commented on Aug 12, 2026

    @sunitaprajapati89
    Contributor

    Hey,
    Regarding segment_analytics still showing the SPM warning on 1.1.12:

    The Package.swift was included in the 1.1.12 release, so the warning should be resolved once your local pub cache reflects the latest version. Please try the following:

    flutter pub upgrade segment_analytics
    flutter pub get
    If the warning persists, clear your pub cache and retry:

    flutter pub cache clean
    flutter pub get
    Also double-check your pubspec.lock to confirm segment_analytics is resolving to 1.1.12 and not an older cached version.

    Regarding flutter_fgbg SPM support:

    You're right that flutter_fgbg: 0.8.0 adds SPM support. However, upgrading to it requires Dart SDK ^3.8.0 (Flutter 3.44+), which is a significant bump from our current minimum of >=3.2.0. Making that change would drop support for users on Flutter versions below 3.44.

    We'd like to address this — could you let us know which Flutter version you're targeting? That will help us decide the right time to make this a hard requirement. In the meantime, the warning is non-fatal and the package continues to build correctly via CocoaPods.

    We'll track bumping flutter_fgbg to ^0.8.0 alongside a future minimum Flutter version update.

  12. Anderzzon commented on Aug 12, 2026

    @Anderzzon

    Thanks. I confirmed this is not a cache or version-resolution issue.

    pubspec.lock resolves segment_analytics 1.1.12 from pub.dev.

    Flutter 3.44.9 expects the manifests at:

    • ios/segment_analytics/Package.swift
    • macos/segment_analytics/Package.swift

    However, 1.1.12 publishes them as ios/Package.swift and macos/Package.swift. Flutter therefore does not detect SPM support and continues integrating the plugin through CocoaPods.

    The manifests also appear to need:

    • Library product name segment-analytics rather than segment_analytics
    • A FlutterFramework package and target dependency
    • Sources located within the nested Swift package structure

    This is confirmed by Segment being absent from Flutter’s generated SPM manifest while still appearing in Podfile.lock.
    Clearing the pub cache simply downloads the same package layout again.

  13. sunitaprajapati89 commented on Aug 12, 2026

    @sunitaprajapati89
    Contributor

    Could you test with this in your pubspec.yaml?

    segment_analytics:
    git:
    url: https://github.com/segmentio/analytics_flutter.git
    ref: feat/test-spm-support-core
    path: packages/core

    Run flutter pub get and let us know if the SPM warning is gone on Flutter 3.44.9.

  14. Anderzzon commented on Aug 12, 2026

    @Anderzzon

    Hi!
    Thanks, I tested this now but segment_analytics is still reported as not supporting SPM.

    I tested to fix this locally and the working structure was:
    packages/core/ios/segment_analytics/Package.swift
    packages/core/ios/segment_analytics/Classes/*.swift

    The manifest also required:

    • Library product named segment-analytics
    • A FlutterFramework package dependency
    • FlutterFramework added as a target dependency
    • Target path set to Classes

    With these changes:

    • segment_analytics disappeared from Flutter’s SPM warning
    • It was added to FlutterGeneratedPluginSwiftPackage
    • It was removed from Podfile.lock
    • The build succeeded

    Your current test branch fixes the product name, but still needs the nested package/source structure and FlutterFramework dependency.

  15. sunitaprajapati89 commented on Aug 13, 2026

    @sunitaprajapati89
    Contributor

    Hi,

    could you test if the SPM warning is gone on Flutter 3.44.9 with the changes pushed now?

  16. Anderzzon commented on Aug 13, 2026

    @Anderzzon

    Hi,
    Yes, the new version worked!

  17. Anderzzon commented on Aug 13, 2026

    @Anderzzon

    I created a new issue for flutter_fgbg to keep track on that:
    #212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions