Sreeweb
Back to Blogs
Illustration of Flutter project workflow showing the migration path from CocoaPods dependency manager to Swift Package Manager with Xcode integration, represented in flat vector design with blue, green, and accent colors on a light background.
5 May 2026 Samrat Khan

Flutter SPM Migration: Complete Step-by-Step Guide (2026)

If your Flutter iOS project still runs on CocoaPods, there are now three deadlines converging on you at once. Firebase stops publishing to CocoaPods in October 2026. Flutter 3.44 ships with SPM as the default—meaning new projects won't need CocoaPods at all. And the CocoaPods trunk goes permanently read-only on December 2, 2026—no new pods, no updates, nothing. This guide walks through the exact migration steps, including the two version requirements most tutorials miss, and what actually happens when you run a package that hasn't migrated yet.

Before You Touch Anything: Two Requirements That Will Break Your Build

Most SPM migration guides skip these. Don't find out the hard way mid-migration.

Flutter 3.44 or higher is required. SPM support technically exists from Flutter 3.24, but 3.44 is where it becomes the stable default. On older versions you'll hit incomplete migrations, missing package resolutions, and build failures that are annoying to debug. Check your version first:

flutter --version

If you're below 3.44, upgrade before doing anything else:

flutter upgrade

Minimum iOS Deployment Target must be 15.0 or higher in Xcode. SPM strictly enforces that your app's minimum iOS version is equal to or higher than what its packages require. Firebase, and many other modern Swift packages, target iOS 15+. If your Xcode project still targets iOS 12 or 13, you'll hit this error the moment SPM tries to resolve dependencies:

Target Integrity: The package product 'FirebaseCore' requires minimum platform version 15.0 for the iOS platform, but this target supports 12.0

Fix it before migrating. In Xcode: click the Runner project in the Project Navigator → select the Runner target → go to General tab → find Minimum Deployments → set iOS to 15.0. Then regenerate the project config:

flutter build ios --config-only

With both requirements confirmed, you're ready.

Step 1: Enable Swift Package Manager

From your project root, run:

flutter config --enable-swift-package-manager

This is the switch that tells Flutter to use SPM instead of CocoaPods for iOS dependency resolution. Without it, everything else in this guide does nothing.

Step 2: Delete Podfile.lock and the Pods Folder

While still in the project root, remove the CocoaPods artifacts:

cd ios

rm -rf Podfile.lock Pods

Or delete them from the file explorer in VS Code. You want a clean slate before the next step.

Step 3: Deintegrate CocoaPods from Xcode

Still inside the ios folder, run:

pod deintegrate

What this actually does: pod deintegrate removes the CocoaPods build phases from your Xcode project files. It strips the Pods project reference from your workspace, clears the CocoaPods-generated build settings from project.pbxproj, and disconnects Xcode from the CocoaPods build system entirely. It does not delete the Podfile itself—that stays in place as a reference. Think of it as surgically unhooking CocoaPods from Xcode without touching anything else.

Step 4: Open Your iOS Project in Xcode

In VS Code's file explorer, right-click the ios folder and open it in Xcode. Or from the terminal:

open ios/Runner.xcworkspace

If Xcode warns about the workspace file being modified or missing Pods references, dismiss it. That's expected—you just deintegrated CocoaPods.

Step 5: Add Firebase via Xcode Package Dependencies

In Xcode, go to File → Add Package Dependencies. A dialog opens with a search bar in the top right.

Paste this URL:

https://github.com/firebase/firebase-ios-sdk

Press Enter. Xcode fetches the repository. When the Firebase package appears, click Add Package. Xcode then asks which Firebase products to include—select what your app actually uses (FirebaseCore, FirebaseAuth, FirebaseFirestore, etc.) and click Add Package again.

Once added, the left-side Project Navigator shows the packages under Package Dependencies. That confirms they're resolved and ready.

For packages other than Firebase: repeat the same process—paste the GitHub URL for that Swift package, select products, add to the Runner target.

Step 6: Clean Everything and Run

Go back to your project root (not the ios folder) and run the full clean sequence:

flutter clean

rm pubspec.lock

flutter pub cache clean

flutter pub get

Now run the project from VS Code or the terminal:

flutter run

Flutter will not invoke pod install this time. SPM handles the native iOS dependencies. The build succeeds, the app launches, and when you look inside your ios folder—no Podfile.lock, no Pods directory. CocoaPods is gone.

What Happens with Packages That Don't Support SPM Yet

Here's what the official docs bury in a warning but don't explain clearly: you can keep using CocoaPods-only packages after migrating to SPM, and your build will still work.

Say you use geolocator, and it hasn't been updated in 10 months and has no Package.swift file. Add it to pubspec.yaml, run flutter pub get, then flutter run. Flutter detects that geolocator only supports CocoaPods. It auto-generates a minimal Podfile for that dependency only and runs pod install just for it. You'll see a Podfile and Pods folder come back—but open Podfile.lock and check what's in there. Firebase is nowhere in it. Firebase is managed by SPM. geolocator is handled by CocoaPods. They run in parallel without conflict.

The practical takeaway: migrate what you can now. Let Flutter's fallback handle the rest. The ecosystem is moving fast—packages that are CocoaPods-only today will add SPM support over the next few months. Keep an eye on each package's GitHub for a Package.swift file appearing in the ios/ or darwin/ directory. That's the signal that SPM support has landed.

If the Build Fails: Lexical Errors and Dependency Issues

If you hit a build failure—especially lexical errors, unresolved symbols, or dependency version conflicts—run this full debug sequence in order. Don't skip steps.

flutter clean

flutter pub cache clean

flutter pub get

flutter pub outdated

flutter pub upgrade --major-versions

What each command does: flutter clean wipes the local build cache and compiled artifacts. flutter pub cache clean clears the global pub cache, forcing a fresh download of all packages. flutter pub get re-resolves and fetches dependencies from scratch. flutter pub outdated lists every package with a newer version available, including major versions your current constraint excludes. flutter pub upgrade --major-versions updates all packages to the latest major version, which often brings SPM support that wasn't in the version you were pinned to.

Run the project again after completing the sequence. This clears the vast majority of post-migration build issues.

Error: "Target Integrity — requires minimum platform version 15.0, but this target supports 12.0"

You missed the deployment target update in the prerequisites. Go back to Xcode → Runner target → General → Minimum Deployments → set to iOS 15.0, then run flutter build ios --config-only before trying again.

Error: "Module not found" or "Framework not found"

The package you added in Xcode wasn't linked to the Runner target. In Xcode, open Build Phases → Link Binary With Libraries and check whether the package product is listed. If it's missing, click the + button and add it manually.

Build hangs on first SPM resolution

Normal on the first run—SPM is downloading and compiling packages fresh. Give it 3–5 minutes. If it stalls past that, clear Xcode's derived data and retry:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

The CI/CD Side

If you run GitHub Actions, Bitrise, or any CI pipeline for iOS builds, remove the pod install step. SPM resolution is handled automatically during flutter build ios. Your CI runner needs macOS with Xcode 14 or later (which ships with SPM built in)—no Ruby, no CocoaPods installation step required.

Before (CocoaPods):

cd ios && pod install && cd ..

After (SPM):

# Nothing needed — SPM resolves during flutter build ios

If some of your packages still fall back to CocoaPods, the Podfile gets auto-generated during the build and pod install runs automatically for those packages. You don't need to add it back manually.

Three Deadlines Worth Keeping on Your Calendar

October 2026: Firebase stops publishing new SDK versions to CocoaPods. Projects on CocoaPods get frozen on the last-published Firebase version—no features, no security patches, no updates.

Flutter 3.44 (shipping soon): SPM becomes the default for all new Flutter iOS and macOS projects. Existing projects continue to work, but the ecosystem's center of gravity has shifted.

December 2, 2026: CocoaPods trunk goes permanently read-only. No new pods, no updates to existing pods. Any dependency that hasn't shipped an SPM version by then is stuck forever at whatever version existed on that date.

Five months is enough time to migrate without pressure. Don't burn it.

Sources: Flutter Official Documentation — docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers | Firebase CocoaPods Deprecation — firebase.google.com/docs/ios/cocoapods-deprecation | Flutter Team Blog — blog.flutter.dev (April 2026, "Saying goodbye to CocoaPods") | CocoaPods Official Blog — blog.cocoapods.org | GitHub Flutter Issues #163186, #178627 — github.com/flutter/flutter

Frequently asked questions

What is Swift Package Manager (SPM) and why is Flutter switching to it?
Swift Package Manager is Apple's native dependency manager, built directly into Xcode. Flutter is switching because Apple has deprecated CocoaPods in favor of SPM, and SPM eliminates the need for Ruby and external tooling. It's faster, simpler, and future-proof.
Do I have to migrate to SPM right now, or can I wait?
You can wait, but shouldn't. Firebase stops publishing new versions to CocoaPods in October 2026, and Flutter 3.44 will make SPM the default. Migrating now gives you time to test and adjust before the deadline.
What if I have packages that don't support SPM yet?
Flutter automatically falls back to CocoaPods for packages that haven't migrated. You'll see a Podfile generated just for those dependencies, while SPM packages are managed separately. It works, but the best practice is to update or replace legacy packages over time.
Will my app run slower after migrating to SPM?
No—it will likely be faster. SPM eliminates the CocoaPods build overhead and folder bloat. Build times typically improve by 10-20% after migration.
Can I undo the SPM migration if something goes wrong
Yes. Run flutter config --no-enable-swift-package-manager to disable SPM, then restore your Podfile and run pod install. Flutter will revert to CocoaPods on the next build.
Do I need to update all my Flutter plugins to use SPM?
No. Flutter intelligently manages both SPM and CocoaPods dependencies. Plugins don't need to be updated immediately, though the ecosystem is gradually migrating. Check each plugin's GitHub for SPM support.
How does SPM migration affect CI/CD pipelines?
Remove pod install steps from your CI scripts—SPM resolution happens automatically during the Xcode build. You'll need macOS with Xcode 14+ (which supports SPM), but no additional tools.
Why does my build fail immediately after enabling SPM?
The most common cause is a mismatched iOS deployment target. Swift Package Manager strictly requires your app's minimum iOS version to be equal to or higher than what its dependencies need. Set your Xcode deployment target to iOS 15.0 or higher under the Runner target's General tab, then run flutter build ios --config-only.
What does pod deintegrate actually do?
It removes CocoaPods' integration from your Xcode project files — stripping out CocoaPods-generated build phases, clearing pod-related build settings from project.pbxproj, and disconnecting the Pods project from your workspace. It does not delete your Podfile. Think of it as unhooking CocoaPods from Xcode without removing any source files.
What should I do if I hit a lexical error or build failure after migrating?
Run this sequence in order: flutter clean → flutter pub cache clean → flutter pub get → flutter pub outdated → flutter pub upgrade --major-versions. This clears stale caches, re-resolves dependencies, and updates packages that may have added SPM support in newer versions.