Duplicate RevenueCat Swift packages
Fix Xcode package errors when a cross-platform RevenueCat SDK and another dependency both add the RevenueCat iOS SDK
If Xcode can't resolve Swift packages in an app that uses RevenueCat's React Native, Expo, Flutter, Capacitor, Cordova, or Unity SDK, use this article to find and remove the extra copy of the RevenueCat iOS SDK.
These SDKs include the RevenueCat iOS SDK through the purchases-hybrid-common package, which depends on purchases-ios-spm at the exact version each SDK release is tested with. The errors below appear when your project, or another package in it, also adds the RevenueCat iOS SDK.
Xcode reports multiple similar targets in purchases-ios-spm and purchases-ios
Xcode fails to resolve packages with this error:
multiple similar targets 'ReceiptParser', 'RevenueCat', 'RevenueCatUI' and 1 others appear in package 'purchases-ios-spm' and 'purchases-ios'
purchases-ios and purchases-ios-spm are two repositories that contain the same RevenueCat iOS SDK. Swift Package Manager treats them as different packages, so the same targets appear twice.
Cause: You added purchases-ios to your project
In Xcode, select your project in the Project navigator and open the Package Dependencies tab. If it lists purchases-ios, your project depends on it directly. Select purchases-ios and click – to remove it.
Your native code can still use RevenueCat without it: add import RevenueCat to your Swift files. If you installed the UI package, import RevenueCatUI works the same way. Your RevenueCat SDK already links these modules.
Cause: Another package depends on purchases-ios
If your project doesn't list purchases-ios directly, another package depends on it. Check the Package.swift of the packages listed under Package Dependencies in the Project navigator, and ask that package's maintainer to depend on purchases-ios-spm.git instead.
Until the package changes, add a Swift Package Manager mirror so Xcode fetches purchases-ios-spm wherever a package asks for purchases-ios:
-
Create a file named
mirrors.jsonwith this content:{"object": [{"original": "https://github.com/RevenueCat/purchases-ios","mirror": "https://github.com/RevenueCat/purchases-ios-spm"},{"original": "https://github.com/RevenueCat/purchases-ios.git","mirror": "https://github.com/RevenueCat/purchases-ios-spm"}],"version": 1}Keep both entries. Swift Package Manager matches each URL as the package writes it, with or without
.git. -
Save the file in the workspace or project you open in Xcode:
- Workspace:
YourApp.xcworkspace/xcshareddata/swiftpm/configuration/mirrors.json - Project:
YourApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/configuration/mirrors.json
Xcode ignores the project's file when you open the workspace. If your team or CI opens both, save the file in both locations.
- Workspace:
-
Reopen the project, then choose File > Packages > Resolve Package Versions.
-
Commit
mirrors.jsonso teammates and CI use the same mirror.
The mirror applies to every package in your project. purchases-ios-spm only publishes releases, so a package that requires purchases-ios at a branch or commit can't resolve through the mirror. Its version requirement must also allow the version your RevenueCat SDK uses.
Xcode can't resolve a purchases-ios-spm version
Xcode fails to resolve packages with an error like this one, showing the versions in your project:
Dependencies could not be resolved because root depends on 'purchases-ios-spm' 5.98.0.
'purchases-ios-spm' 5.99.0 is required because 'purchases-hybrid-common' 20.1.0 depends on 'purchases-ios-spm' 5.99.0 and root depends on 'purchases-hybrid-common' 20.1.0.
Cause: Your project requires a different RevenueCat iOS SDK version
Each release of a RevenueCat cross-platform SDK requires one exact version of purchases-ios-spm. If your project's Package Dependencies tab lists purchases-ios-spm, remove it. Your RevenueCat SDK still includes it, and your native code can still import RevenueCat.
If you added a mirror for another package, check that package's version requirement for purchases-ios instead.