Kotlin Tooling Cocoapods Spm Migration
Migrate KMP projects from CocoaPods (kotlin("native.cocoapods")) to Swift Package...
Install
npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-cocoapods-spm-migration -g -a claude-code -y- Repository
- Kotlin/kotlin-agent-skills1.1k
- Category
- Mobile
- Updated
- 5d ago
- License
- Apache-2.0
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Migrate KMP projects from CocoaPods (kotlin("native.cocoapods")) to Swift Package Manager (swiftPMDependencies DSL), replaces pod() with swiftPackage(), transforms cocoapods.* imports to swiftPMImport.*, and reconfigures the Xcode project.
CocoaPods to SwiftPM Migration for KMP
Migrate Kotlin Multiplatform projects from kotlin("native.cocoapods") to swiftPMDependencies {} DSL.
Requirements
- Kotlin: 2.4.0-Beta2 or later (first public release with
swiftPMDependenciessupport, available on Maven Central) - Xcode: 16.4 or 26.0+
- iOS Deployment Target: 16.0+ recommended
Migration Overview
IMPORTANT: Keep the cocoapods {} block and plugin active until Phase 6. The migration adds swiftPMDependencies {} alongside the existing CocoaPods setup first, reconfigures Xcode, and only then removes CocoaPods.
| Phase | Action |
|---|---|
| 1 | Analyze existing CocoaPods configuration |
| 2 | Update Gradle configuration (repos, Kotlin version) |
| 3 | Add swiftPMDependencies {} alongside existing cocoapods {} |
| 4 | Transform Kotlin imports |
| 5 | Reconfigure iOS project and deintegrate CocoaPods |
| 6 | Remove CocoaPods plugin from Gradle |
| 7 | Verify Gradle build and Xcode project build |
| 8 | Write MIGRATION_REPORT.md |
Phase 1: Pre-Migration Analysis
1.0 Verify the project builds
Before starting migration, identify the module to migrate and confirm it compiles successfully.
- Find the module that uses CocoaPods, look for
build.gradle.ktsfiles containingcocoapods:
Extract the module name from the path (e.g.,grep -rl "cocoapods" --include="build.gradle.kts" ../shared/build.gradle.kts→ module name isshared). Note: multiple modules may use CocoaPods, record all of them. Typically only the module that produces the framework linked into the iOS app needsswiftPMDependencies; the others only need CocoaPods removed (Phase 6).
