Mastering the Shift: How to Migrate Your Flutter Project from CocoaPods to Swift Package Manager
<h2>Introduction</h2>
<p>Flutter's upcoming stable release (version 3.44) marks a major milestone: <strong>Swift Package Manager (SwiftPM)</strong> becomes the default dependency manager for iOS and macOS apps, replacing the long-standing CocoaPods. This change eliminates the need to manage Ruby and CocoaPods installations and opens the door to Apple's native package ecosystem. CocoaPods will enter maintenance mode and its registry becomes read-only on December 2, 2026; while existing builds remain functional, no new updates will be published after that date. To keep your Flutter apps up‑to‑date and future‑proof, migration to SwiftPM is essential. This guide walks you through every step—whether you're an app developer or a plugin maintainer—so the transition is smooth and your projects stay healthy.</p><figure style="margin:20px 0"><img src="https://picsum.photos/seed/1106264489/800/450" alt="Mastering the Shift: How to Migrate Your Flutter Project from CocoaPods to Swift Package Manager" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px"></figcaption></figure>
<h2>What You Need</h2>
<ul>
<li><strong>Flutter SDK</strong> – the latest stable version (3.44 or later). Update via <code>flutter upgrade</code>.</li>
<li><strong>Xcode</strong> – version 14 or higher (SwiftPM integration is tight).</li>
<li><strong>macOS</strong> – to build iOS and macOS apps.</li>
<li><strong>Basic knowledge</strong> of Flutter project structure and <code>pubspec.yaml</code>.</li>
<li><strong>Plugin developers</strong>: a <code>Package.swift</code> understanding helps; for already‑migrated plugins, you must add the Flutter framework dependency.</li>
</ul>
<h2 id="app-developers">Step-by-Step Migration for App Developers</h2>
<h3>Step 1: Understand the Transition Timeline</h3>
<p>Before touching any configuration, know the key dates: CocoaPods goes read‑only on December 2, 2026, and Flutter will eventually remove fallback support. Starting with Flutter 3.44, SwiftPM is the default – but the CLI still <em>temporarily</em> uses CocoaPods for plugins that haven’t migrated yet. Your goal is to get all your dependencies onto SwiftPM before the cut‑off.</p>
<h3>Step 2: Run Your App Normally – Let the CLI Do the Heavy Lifting</h3>
<p>The easiest path: simply execute <code>flutter run</code> or <code>flutter build ios</code> for your project. The Flutter CLI automatically updates your Xcode project to use Swift Package Manager. Behind the scenes, it scans your dependencies and adapts the workspace. <strong>Important:</strong> always commit your project files before running to review changes safely.</p>
<h3>Step 3: Check for Warnings About Unsupported Plugins</h3>
<p>During the build process, Flutter prints a clear warning listing every plugin that still relies on CocoaPods. For those plugins, the CLI temporarily falls back to CocoaPods so your app still compiles. However, this fallback will <em>not</em> be available forever. If you see such warnings, you have two options:</p>
<ul>
<li><strong>Option A:</strong> Wait for the plugin maintainer to adopt SwiftPM – they receive a lower pub.dev score until they do, which encourages updates.</li>
<li><strong>Option B:</strong> Find an alternative plugin that already supports SwiftPM. File an issue with the unmaintained plugin’s repo to request migration.</li>
</ul>
<h3>Step 4: (Optional) Disable SwiftPM If You Hit a Breaking Issue</h3>
<p>If SwiftPM introduces a bug that blocks your build, you can temporarily revert to CocoaPods. Open your <code>pubspec.yaml</code>, locate the <code>flutter</code> section, and add this configuration block:</p>
<pre><code>flutter:
config:
enable-swift-package-manager: false</code></pre>
<p>This opt‑out is a safety net – but please report the issue using the <a href="https://github.com/flutter/flutter/issues/new?template=bug_report.md">Flutter GitHub issue template</a>. Include error details, a list of your plugins and versions, and copies of your Xcode project files. This helps the team resolve the problem before CocoaPods removal.</p>
<h2 id="plugin-developers">Step-by-Step Migration for Plugin Developers</h2>
<h3>Step 5: Add SwiftPM Support to Your Plugin (if you haven't already)</h3>
<p>To ensure your plugin remains usable and maintains a high pub.dev score, you must add Swift Package Manager support. Currently, about 61% of the top 100 iOS plugins have migrated. Here’s how:</p>
<ol>
<li>Create a <code>Package.swift</code> file at the root of your plugin’s iOS/macOS folder.</li>
<li>Define your package name, platforms (iOS 12.0+, macOS 10.14+), and dependencies.</li>
<li>Move your source files to follow the standard Swift package structure (e.g., <code>Sources/PluginName/</code>).</li>
<li>Ensure your <code>Package.swift</code> exports the necessary public interfaces.</li>
</ol>
<p>For detailed syntax, refer to the <a href="https://docs.flutter.dev/packages-and-plugins/developing-packages#add-swift-package-manager-support">Flutter migration docs for plugin developers</a>.</p>
<h3>Step 6: If You Migrated During the 2025 Pilot – Add FlutterFramework Dependency</h3>
<p>Plugins that already migrated in the early 2025 pilot now require one additional step: you must explicitly add <code>FlutterFramework</code> as a dependency in your <code>Package.swift</code>. This ensures proper linking with the Flutter engine. Add the following clause:</p>
<pre><code>.target(
name: "YourPlugin",
dependencies: [
.product(name: "FlutterFramework", package: "Flutter")
]
)</code></pre>
<p>Make sure you also include the Flutter package repository or use a local path as appropriate. Without this dependency, your plugin may fail to build under the new manager.</p>
<h2 id="tips">Tips for a Smooth Migration</h2>
<ul>
<li><strong>Start early:</strong> Don’t wait until December 2026. The earlier you migrate, the earlier you benefit from SwiftPM’s speed and tighter Xcode integration.</li>
<li><strong>Monitor your pub.dev score:</strong> If you’re a plugin maintainer, your package score drops without SwiftPM support. Keep an eye on it.</li>
<li><strong>Test on multiple Xcode versions:</strong> SwiftPM works best with Xcode 14+, but test on the version your CI uses.</li>
<li><strong>Use the Flutter CLI’s verbose mode:</strong> Run <code>flutter run --verbose</code> to see exactly which dependencies are resolved via CocoaPods fallback.</li>
<li><strong>File issues promptly:</strong> If a breaking change occurs, report it with logs. The Flutter team is actively improving the migration tooling.</li>
<li><strong>Keep backups:</strong> Before running <code>flutter pub upgrade</code> or <code>flutter build</code>, commit your <code>ios/</code> and <code>macos/</code> folders to version control.</li>
<li><strong>Join the community:</strong> Check the <a href="https://github.com/flutter/flutter/discussions">Flutter GitHub discussions</a> for common issues and solutions.</li>
</ul>
<p>By following these steps, you'll ensure your Flutter app or plugin is ready for the Swift Package Manager era—no more Ruby, no more CocoaPods headaches. Happy coding!</p>