Migrating from CocoaPods to Swift Package Manager in Flutter: A Step-by-Step Guide

By

Introduction

Flutter is making a major shift: starting with the upcoming stable release (version 3.44), Swift Package Manager (SwiftPM) will become the default dependency manager for iOS and macOS apps. This means no more wrestling with Ruby installations or CocoaPods just to run your Flutter app on Apple devices. CocoaPods has entered maintenance mode and its registry will be permanently read-only on December 2, 2026. While existing builds will still work, no new versions or pods will be added after that date.

Migrating from CocoaPods to Swift Package Manager in Flutter: A Step-by-Step Guide

To ensure your apps continue receiving dependency updates and to unlock the larger Swift package ecosystem, Flutter is transitioning to Apple's supported solution: Swift Package Manager. This guide walks you through everything you need to know, whether you're an app developer or a plugin author.

What You Need

Step 1: Let the Flutter CLI Handle the Migration (App Developers)

For most app developers, the migration is automatic. When you run or build your iOS or macOS app, the Flutter CLI will update your Xcode project to use Swift Package Manager. There's no manual step required—just use the usual flutter run or flutter build ios commands.

Behind the scenes, Flutter scans your pubspec.yaml for dependencies and converts them to Swift Package Manager equivalents when possible. If all your plugins have already adopted SwiftPM, you're done. The CLI will produce a clean build without any CocoaPods involvement.

Dealing with Unsupported Plugins

If any of your plugins haven't adopted Swift Package Manager yet, Flutter will print a warning listing exactly which dependencies are unsupported. In that case, the framework will temporarily fall back to CocoaPods for those specific plugins. This ensures your build still works now, but be aware: CocoaPods support will eventually be removed entirely.

If a critical plugin breaks your build because it lacks Swift package support, you have two options:

Step 2: Temporarily Disable SwiftPM (If Necessary)

If Swift Package Manager causes a breaking issue in your project, you can disable it and return to CocoaPods for now. Open your pubspec.yaml file and locate the flutter section. Add or edit the config block as follows:

flutter:
  config:
    enable-swift-package-manager: false

After making this change, run flutter clean and rebuild. Please note that this is a temporary workaround. CocoaPods will be completely removed in the future, so you should plan to migrate soon. If you opt out, please file a bug report using the Flutter GitHub issue template with these details:

This helps the Flutter team resolve issues before CocoaPods is fully deprecated.

Step 3: Migrate Your Plugin (Plugin Developers)

If you maintain an iOS or macOS Flutter plugin, you must add Swift Package Manager support as soon as possible. Currently, about 61% of the top 100 iOS plugins have migrated. The remaining 39% need to update so app developers aren't stuck relying on a deprecated tool. To encourage adoption, packages without SwiftPM support now receive lower pub.dev scores until they migrate.

How to Add Swift Package Manager Support

  1. Create a Package.swift file in your plugin's root directory. This file defines your Swift package, its targets, and dependencies.
  2. Move your source files to match the standard Swift package structure. Typically, place shared code under Sources/ and tests under Tests/.
  3. If you migrated during the 2025 pilot, you need to complete one new step: add FlutterFramework as a dependency in your Package.swift file. This ensures your Swift package can link against the Flutter runtime.
  4. Test your plugin by running a sample Flutter app that depends on it. Ensure the build uses SwiftPM and doesn't fall back to CocoaPods.

For detailed instructions, refer to the official Flutter migration docs for plugin developers. They contain the exact syntax for Package.swift and best practices for organizing your code.

Tips for a Smooth Transition

By following these steps, you can smoothly transition from CocoaPods to Swift Package Manager, ensuring your Flutter projects remain up-to-date and compatible with the future of Apple ecosystem development.

Tags:

Related Articles

Recommended

Discover More

Will Exelixis Stock Double Again by 2031? A Comprehensive Q&AExclusive: 'Fast16' Malware – US-Linked Cyber Sabotage Tool Silently Crippled Iran Before Stuxnet, Researchers RevealApple Quietly Retires Entry-Level Mac Mini, Raises Starting Price to $799 with Doubled StorageThe Inside Story Behind Zcash's 30% Surge: 10 Key InsightsHow to Identify and Prevent Credential Theft from Malicious PyPI Packages