Coding

Ios Cocoapods Spm Migration

Try it

Use when migrating iOS projects from CocoaPods to Swift Package Manager, or when planning a migration strategy for enterprise iOS dependencies. Covers depend...

What it does

Use when migrating iOS projects from CocoaPods to Swift Package Manager, or when planning a migration strategy for enterprise iOS dependencies. Covers dependency mapping, build settings, xcconfig translation, resource bundles, Objective-C interop, binary frameworks, and CI/CD adaptation. For iOS developers and AI coding agents involved in migration planning and execution.

The skill document

iOS CocoaPods → SPM Migration

Overview

Systematic, dependency-first approach: audit all current CocoaPods dependencies before writing any Package.swift. Map each pod individually, handle build settings per dependency, then migrate incrementally.

Never jump straight to writing a Package.swift without auditing the existing setup first.

When to Use

  • Project currently uses CocoaPods (Podfile, Pods/, *.xcworkspace)
  • Need to adopt SPM-native features (build plugins, macros, binary targets)
  • Build times impacted by CocoaPods integration phase
  • Multiple dependency managers in a single project
  • CI pipelines need simplified dependency management

When NOT to Use

  • One-off or experimental projects (migration effort exceeds benefit)
  • Pods without SPM equivalents and no viable alternative
  • Projects requiring CocoaPods-only features (resource bundles in subspecs)

Decision Framework

Current Pod has SPM support?
├─ YES → Can migrate directly
│  └─ Check: same product name? resource bundle handling?
├─ NO → Is there an SPM alternative?
│  ├─ YES → Consider replacing (evaluate API differences)
│  └─ NO → Does the pod distribute as binary framework?
│     ├─ YES → Can wrap as SPM binary target
│     └─ NO → Keep in CocoaPods (hybrid), or vendor the source

Migration Process

Each phase has a dedicated prompt template in prompts/:

1. Audit (prompts/audit.md)

Inventory current Podfile — list every pod, subspec, version requirement. Check for: resource bundles, xcconfig injections, script phases, module maps, bridging headers. Collect the full dependency tree.

2. Map (prompts/migrate.md)

Map each pod to its SPM equivalent using mappings/ database. For each: SPM URL, product name, version compatibility, special setup.

3. Build Settings Migration

Translate CocoaPods-generated settings:

  • Remove $(inherited) from HEADER_SEARCH_PATHS, FRAMEWORK_SEARCH_PATHS
  • Replace OTHER_LDFLAGS flags with SPM's automatic linking
  • Handle xcconfig files — eliminate CocoaPods-generated includes
  • Migrate script phases (Crashlytics upload, SwiftGen, etc.)

4. Configure & Verify (prompts/verify.md)

Add packages in Xcode, resolve dependencies, build. Verify: no linker errors, resource bundles load, ObjC bridging intact, all imports resolve correctly.

5. Adapt CI/CD

Update CI pipeline — remove pod install step, add xcodebuild -resolvePackageDependencies. Update cache keys. Handle binary framework distribution if applicable.

Quick Reference

CocoaPodsSPM Equivalent
pod installxcodebuild -resolvePackageDependencies
pod updateUpdate version in Package.swift or Xcode
PodfilePackage.swift (or Xcode project settings)
Pods/ directorySourcePackages/ (build artifacts)
PodspecPackage.swift manifest
use_frameworks!Default for SPM (always modules)
#import import Module or @import Module
Script phases from podsManual script phase with SourcePackages/checkouts/ path
Resource bundlesSPM resources: parameter or asset catalog

Common Mistakes

  • Skipping audit: Writing Package.swift without knowing current state
  • Ignoring xcconfig: CocoaPods-generated xcconfigs persist, causing conflicts
  • Firebase monolithic import: import Firebase doesn't exist in SPM — use per-module imports
  • CocoaLumberjack Swift module: Use CocoaLumberjackSwift product, not CocoaLumberjack
  • ObjC module maps: Some SPM packages don't generate module maps automatically
  • Resource bundles: SPM doesn't create separate resource bundles by default
  • Not cleaning DerivedData: Stale build cache causes mysterious errors
  • Binary frameworks: Pods distributed as binary need special handling as SPM binary targets

See docs/ for detailed technical documentation on each topic. See prompts/ for reusable AI prompt templates for each phase. See templates/ for Package.swift templates for different scenarios.

Related skills

Diagnose and fix iOS platform issues across lifecycle, entitlements, permissions, push, widgets, and StoreKit.

113 installs6 stars

Index of ready-to-run Swift animation code examples organized by category (Menu, Transition, Indicator, Alert, Animation, Tableview, Collectionview, UI) sour...

1 installs

iOS/macOS 应用全生命周期开发技能包。覆盖从需求分析到上架发布的完整流程,包括:工程工作流(需求澄清、PRD生成、任务拆解、Swift TDD、Bug诊断、架构改进)、政策合规监控与动态学习、智能代码生成(Swift/SwiftUI/UIKit)、UI设计系统与美学规范(12大设计法则、631配色、8点网...

1 installs

Convert Apple iWork documents (Pages .pages, Numbers .numbers, Keynote .key) into Markdown. Use whenever the user wants to read, extract, or translate the content of an iWork file into text/markdown, for example 'convert this .pages file to markdown', 'extract text from a Numbers sheet', 'read a Keynote file', or 'open a .key/.numbers/.pages and turn it into markdown'. Handles the iWork '13+ format (bundle containing Index.zip with .iwa files that wrap Snappy-framed Protobuf) with no third-party dependencies.

Use Codemod CLI whenever the user wants to migrate, upgrade, update, or refactor a codebase in a repeatable way. This includes framework migrations, library...

14 installs1 stars

Build native macOS apps with Swift 6.3, SwiftUI, SwiftData, concurrency, and on-device AI.

19 installs