How to Seamlessly Shift from CocoaPods to Swift Package Manager in Flutter

<h2>Introduction</h2> <p>Flutter's upcoming stable release (version 3.44) makes Swift Package Manager (SwiftPM) the default dependency manager for iOS and macOS apps. This change bids farewell to CocoaPods, which is now in maintenance mode and will become read-only on December 2, 2026. For app developers, the transition is mostly automatic, but plugin authors must take proactive steps to ensure their packages remain compatible. This guide walks you through everything you need to know—from updating your environment to troubleshooting potential hiccups—so you can move forward without missing a beat.</p><figure style="margin:20px 0"><img src="https://picsum.photos/seed/3812040698/800/450" alt="How to Seamlessly Shift from CocoaPods to Swift Package Manager in Flutter" 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> version 3.44 or later (check with <code>flutter --version</code>)</li> <li><strong>Xcode</strong> (latest stable version recommended)</li> <li>An existing Flutter project that targets iOS or macOS</li> <li>Ruby (optional, for fallback if you temporarily need CocoaPods)</li> <li>A <strong>GitHub account</strong> for filing issues if you encounter problems</li> <li>Basic familiarity with the command line and <code>pubspec.yaml</code> editing</li> </ul> <h2 id="step1">Step 1: Update Your Flutter SDK to 3.44 or Later</h2> <p>If you haven't already, upgrade to the latest stable Flutter release. Run:</p> <pre><code>flutter upgrade</code></pre> <p>Verify the installation with <code>flutter --version</code>. This step ensures the CLI includes the automatic migration logic for Swift Package Manager. Note that the change takes effect only for projects built with version 3.44+.</p> <h2 id="step2">Step 2: Refresh Your Project Dependencies</h2> <p>Navigate to your project directory and run:</p> <pre><code>flutter pub get</code></pre> <p>This command reads <code>pubspec.yaml</code> and fetches the latest versions of your dependencies. Pay attention to any warnings printed in the console. Flutter will list plugins that haven't yet adopted Swift Package Manager. Those plugins will continue to work via a temporary fallback to CocoaPods, but they won't receive updates after the CocoaPods registry closes.</p> <h2 id="step3">Step 3: Build or Run Your App for iOS or macOS</h2> <p>Trigger a build or run using the Flutter CLI:</p> <pre><code>flutter run -d ios</code></pre> <p>or for macOS:</p> <pre><code>flutter run -d macos</code></pre> <p>During this process, the CLI automatically converts your Xcode project to use Swift Package Manager (SwiftPM) for all dependencies that support it. You'll see output indicating that CocoaPods is being replaced with Swift package references. If all goes well, your app will compile and run without any additional configuration.</p> <h2 id="step4">Step 4: Verify the Integration in Xcode</h2> <p>Open your project's <code>.xcworkspace</code> file in Xcode. Navigate to <strong>File &gt; Project Settings</strong> and then to the <strong>Package Dependencies</strong> tab. You should see a list of packages managed by Swift Package Manager. Also check that the <code>Podfile</code> is no longer present or is empty. If you see both CocoaPods and SwiftPM entries, it may indicate a partial migration—review the warnings from Step 2.</p> <h2 id="step5">Step 5: For Plugin Authors – Adopt Swift Package Manager</h2> <p>If you maintain a Flutter plugin with iOS or macOS code, you must add Swift Package Manager support before December 2026. Here's how:</p> <ol> <li><strong>Add a <code>Package.swift</code> file</strong> at the root of your iOS/macOS plugin folder. This file defines the package's name, products, targets, and dependencies.</li> <li><strong>Move your source files</strong> to comply with Swift package conventions (e.g., <code>Sources/PluginName/</code>). If you already migrated during the 2025 pilot, you must add <code>FlutterFramework</code> as a dependency in <code>Package.swift</code>—this is a new requirement for the final transition.</li> <li><strong>Test your plugin</strong> with a sample Flutter app using SwiftPM. Run <code>flutter build ios --no-cocoa-pods</code> to force SwiftPM usage.</li> <li>Submit your updated plugin to <strong>pub.dev</strong>. Packages without SwiftPM support will receive lower pub.dev scores, so migration is strongly encouraged.</li> </ol> <h2 id="step6">Step 6: Opt Out Temporarily If Needed</h2> <p>If SwiftPM causes a breaking issue in your project, you can temporarily disable it. Open your <code>pubspec.yaml</code> and under the <code>flutter</code> section, add:</p> <pre><code>flutter: config: enable-swift-package-manager: false</code></pre> <p>This reverts to using CocoaPods for all dependencies. <strong>Important:</strong> This is a temporary workaround. If you use it, please file a bug report using the <a href="https://github.com/flutter/flutter/issues/new?template=BUG_REPORT.md">Flutter GitHub issue template</a>. Include error logs, a list of your plugins and versions, and your Xcode project files. This feedback helps the Flutter team resolve issues before CocoaPods support is fully removed.</p> <h2 id="tips">Tips for a Smooth Migration</h2> <ul> <li><strong>Backup your project</strong> before making changes—especially if you need to opt out temporarily. Use version control (git) to track modifications.</li> <li><strong>Check plugin compatibility</strong> early. Visit <a href="https://pub.dev">pub.dev</a> and look for a SwiftPM badge or mention in the README. If a critical plugin hasn't migrated, reach out to its maintainer or consider alternatives.</li> <li><strong>Monitor Flutter releases</strong> and changelogs. The team will announce deprecation warnings and final removal dates.</li> <li><strong>For plugin authors</strong>, prioritize migration before December 2026. The automatic fallback in Flutter will eventually disappear, leaving your package non-functional for iOS/macOS builds.</li> <li><strong>Stay engaged with the community</strong>—file issues, share your experiences, and help improve the migration tooling.</li> </ul> <p>Moving from CocoaPods to Swift Package Manager is a forward-looking change that aligns Flutter with Apple's modern dependency ecosystem. While it requires some attention from plugin maintainers, app developers will find the transition nearly effortless. By following these steps and keeping the tips in mind, you'll ensure your Flutter projects remain healthy and up-to-date.</p>
Tags: