1. List what you have
Podfile that is not a plain pod 'Name', 'version' line: post_install hooks, use_frameworks!, build settings changed for specific pods, and :path or :git pods. Each of those needs its own replacement.
2. Find the Swift package for each pod
For each pod, open the project’s repository and look for aPackage.swift at the root, or a section on Swift Package Manager in its README. Three outcomes:
- Has a package. Note the repository URL and the product name(s). Product names can differ from pod names, and one pod can map to several products.
- Has no package, but is small. Copy the source into your project, keeping its license file.
- Has no package and is a binary SDK. Ask the vendor for an XCFramework. You can add an XCFramework to the target directly or wrap it in a local package with a
binaryTarget.
3. Remove CocoaPods from the project
From the folder that contains thePodfile:
pod deintegrate removes the CocoaPods build phases, the Pods framework references and the .xcconfig includes from your .xcodeproj. Keep the Podfile until the migration is done so you can look up what was there. From now on, open the .xcodeproj, not the workspace. If your project had its own workspace for other reasons, delete only the CocoaPods entry from it instead.
4. Add the packages
In Xcode: File > Add Package Dependencies, paste the repository URL, choose a version rule, and add the products to the app target (and to extension targets that used the pod). Start with the version you had inPodfile.lock and upgrade later, so a build failure points at the migration and not at an upgrade.
Packages are recorded in the project file and pinned in Package.resolved (inside the .xcodeproj or workspace). Commit Package.resolved, the same way you committed Podfile.lock.
5. Fix what the build tells you
Common errors after the switch:No such module 'X': the product name differs from the pod’s module name, or the product was added to the wrong target.- Duplicate symbols: the same library is linked twice, often once as a package and once as a leftover framework in Link Binary With Libraries. Remove the leftover.
- Missing resources (images, nibs, bundles): code that looked up resources with
Bundle(for:)or by bundle name may needBundle.modulein the package, or a new release of the library. - Settings that lived in
post_install: move them to the target’s build settings or an.xcconfigfile you own.
6. Check the build on CI
Run the same commands your CI runs, from a clean checkout:Podfile.lock (for example to decide when to run pod install) should now read Package.resolved.
Check it on a Mac
Every step above ends in an Xcode build, which needs macOS. With box,box build builds the branch on a real Mac from any system, and box exec runs commands such as pod deintegrate or xcodebuild -resolvePackageDependencies there. See Build and Exec.
Related: CocoaPods trunk is read-only, Fix “xcodebuild: command not found” on Linux CI, Cut GitHub Actions macOS minutes.