Skip to main content
Skip to navigation

Migrate the iOS SDK from Carthage to Swift Package Manager

Move the RevenueCat iOS SDK from Carthage to Swift Package Manager

AIAsk AIChatGPTClaude

Move the RevenueCat iOS SDK from Carthage to Swift Package Manager (SPM), keeping your current SDK version during the migration.

1. Note your current SDK version​

Find the purchases-ios version in Cartfile.resolved, for example 5.98.0. Use that exact version in step 4 so the migration doesn't also upgrade the SDK.

Commit your project first, so you can review or undo the changes. Then, for every target that uses RevenueCat, including extensions:

  1. Open General > Frameworks, Libraries, and Embedded Content in Xcode.
  2. Remove the entries pointing to RevenueCat.xcframework, RevenueCatUI.xcframework, and ReceiptParser.xcframework under Carthage/Build, where present. Older integrations may use .framework instead.
  3. Note which products each target used; you'll add them back through SPM.

If you have a carthage copy-frameworks build phase, remove those frameworks from its input/output lists or .xcfilelist files. Delete the phase only if no other frameworks need it.

3. Remove RevenueCat from Carthage​

If RevenueCat is your only Carthage dependency​

  1. Delete Cartfile, Cartfile.resolved, and Carthage/.
  2. Remove Carthage/Build entries from each target's Framework Search Paths.
  3. Remove Carthage steps from your build scripts.

If your app still needs other Carthage dependencies​

  1. Remove purchases-ios from Cartfile and Cartfile.resolved. Editing the lockfile directly preserves your other resolved versions.
  2. Delete Carthage/Checkouts/purchases-ios.
  3. Delete RevenueCat's build products from Carthage/Build: RevenueCat.xcframework, RevenueCatUI.xcframework, ReceiptParser.xcframework, and .purchases-ios.version, where present. Regular frameworks live in platform subdirectories such as Carthage/Build/iOS.

Keep the Carthage search paths and build steps for your other dependencies. Remove the old RevenueCat build products so those paths can't resolve a stale copy.

4. Add the RevenueCat Swift package​

  1. In Xcode, select File > Add Package Dependencies and enter:
https://github.com/RevenueCat/purchases-ios-spm.git
  1. Select Exact Version and enter the version from step 1.

  2. Click Add Package. Add RevenueCat to your app target, plus RevenueCatUI or ReceiptParser if the target used them. Leave the other products set to None. Don't link RevenueCat_CustomEntitlementComputation alongside RevenueCat.

    Package products with RevenueCat and RevenueCatUI selected

  3. Click Add Package again.

  4. For each additional target, open General > Frameworks, Libraries, and Embedded Content, click +, and add the package products you noted in step 2.

Use purchases-ios-spm.git consistently. If another dependency already uses purchases-ios.git, align its package URL first: referencing both repositories causes duplicate-target errors. The RevenueCat AdMob adapter uses purchases-ios-spm.git.

5. Check imports​

Swift imports remain import RevenueCat and import RevenueCatUI.

For Objective-C files importing RevenueCat headers, use:

@import RevenueCat;

6. Build and verify​

  1. Select Product > Clean Build Folder, then build Debug and your release archive.
  2. Confirm that targets link RevenueCat's Swift package products, with no references to its old files under Carthage/Build. Keep the new package products linked.
  3. Run your existing purchase flow in your test environment. If you use RevenueCatUI, also open any paywall or Customer Center your app uses.
  4. Commit the project changes and Xcode's Package.resolved.

To upgrade the SDK later, change its version requirement under Package Dependencies, then resolve packages again.

Troubleshooting​

The build fails with duplicate RevenueCat modules or symbols​

A Carthage copy of the SDK is still in your project. Check that no target links a RevenueCat framework, that no carthage copy-frameworks phase lists one, and that Carthage/Build no longer contains them.

Package resolution reports a conflicting target name​

An error saying that multiple packages declare targets with a conflicting name means your project references both purchases-ios.git and purchases-ios-spm.git. Switch every reference to purchases-ios-spm.git.

Package resolution fails or doesn't finish​

Select File > Packages > Reset Package Caches, then build again. If the error persists, quit and reopen Xcode.

Next steps​

See the iOS install guide for your new setup, or the iOS migration guides before upgrading to another major SDK version.

Was this page helpful?