Swift Package Manager (SPM) in Flutter
SkillDev toolsUse when migrating iOS and macOS Flutter plugin dependencies from CocoaPods to Swift Package Manager (SPM).
Use Swift Package Manager (SPM) in Flutter in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Swift Package Manager (SPM) in Flutter and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Swift Package Manager (SPM) in Flutter skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by dhruvanbhalara/skills in skills/flutter/flutter-spm/SKILL.md and read by Ahel’s review.
Introduced in Flutter 3.44
Swift Package Manager is the default dependency manager for iOS and macOS applications in Flutter, replacing CocoaPods. This modern integration improves compilation speeds and simplifies native package dependency trees.
Contents
- Project Configuration
- Managing Dependencies
- CI/CD Caching Strategies
- Troubleshooting & Conflict Resolution
Project Configuration
In Flutter 3.44+, newly generated iOS and macOS platforms are configured to use SPM out of the box.
Key Changes
- No
PodfileorPodfile.lock: The iOS directory no longer requires CocoaPods. - Xcode Workspace Integration: Native dependencies are managed directly via Xcode's Package Dependencies.
- Flutter Plugins: Plugins with native Swift code declare their SPM configurations inside their
pubspec.yamlorPackage.swiftfiles, which Flutter automatically integrates into the runner target.
Managing Dependencies
Adding a Swift Package
To add a native package directly to the iOS Runner:
- Open
ios/Runner.xcworkspacein Xcode. - Select File > Add Package Dependencies...
- Enter the package URL (e.g.,
https://github.com/Alamofire/Alamofire) and select target version. - Link the package to the
Runnertarget.
For Plugin Authors
To define an SPM dependency for a Flutter plugin, use the swift_packages field in pubspec.yaml:
flutter:
plugin:
platforms:
ios:
pluginClass: MyPlugin
swift_packages:
- name: Alamofire
url: https://github.com/Alamofire/Alamofire.git
version: 5.9.0
CI/CD Caching Strategies
SPM dependencies are stored outside the project workspace. To optimize CI build times (e.g., in GitHub Actions), cache the following directories:
- SPM Cache Directory:
~/Library/Caches/org.swift.swiftpm - Xcode DerivedData:
~/Library/Developer/Xcode/DerivedData
GitHub Actions Caching Example
- name: Cache Swift Package Manager Dependencies
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-spm-${{ hashFiles('**/pubspec.yaml', 'ios/Runner.xcodeproj/project.pbxproj') }}
restore-keys: |
${{ runner.os }}-spm-
Troubleshooting & Conflict Resolution
Package Resolution Failure
If SPM dependencies fail to resolve during CLI builds:
# 1. Clean the project
flutter clean
# 2. Resolve package dependencies manually via Xcode CLI
xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner
Version Conflicts
If multiple plugins request incompatible versions of the same Swift Package:
- Open the project in Xcode.
- Navigate to Runner > Package Dependencies.
- Manually override the package dependency rule to enforce a unified, compatible version.
Signals
- GitHub stars
- 30
- Forks
- 4
- Last commit
- Aug 2026
Advanced
- Item type
- skill
- Key
flutter-spm- Source
- github.com/dhruvanbhalara/skills
github.com/dhruvanbhalara/skills
Related picks
Skill · emilkowalski
The pick for Swiftswift-concurrency-expert
Skill · davila7
The pick for Swiftdeveloping-genkit-dart
Skill · evanca
The pick for Dartwrite-dart
Skill · cfug
The pick for Dartflutter-auto-route-navigation
Skill · hoangnguyen0403
The pick for Fluttererror-tracking-flutter
Skill · posthog
The pick for Flutter