Migrate from CocoaPods to Swift Package Manager or Carthage
Install the Braintree iOS SDK with Swift Package Manager or Carthage.
Braintree stopped publishing all Braintree iOS SDK modules and PopupBridge for iOS to CocoaPods on November 1, 2026. The final releases with CocoaPods support are Braintree iOS SDK 7.13.1 and PopupBridge for iOS 3.2.0. Existing applications continue to build against previously published pods. To receive new features, bug fixes, and security patches, migrate to Swift Package Manager or Carthage.
The CocoaPods team has announced that CocoaPods is in maintenance mode and set December 2, 2026 as the date the CocoaPods Trunk becomes permanently read-only. For details, see Support and maintenance plans and the Trunk read-only plan.
If you use the PayPal Commerce iOS SDK and want to install its dependencies yourself, see Installation without CocoaPods. Use this guide to migrate the Braintree iOS SDK.
Replace the Braintree pods in your Podfile with Swift Package Manager or Carthage, and confirm that your app builds. This guide applies to Braintree iOS SDK v7. If you use v6, migrate to Braintree iOS SDK v7 or see the Braintree iOS SDK v6 setup guide. Your imports and API calls don't change. Only the installation and linking steps change.
Choose an installation method
Use Swift Package Manager unless your project has a reason to use another method.
| Method | Best for | Notes |
|---|---|---|
| Swift Package Manager | Most projects | Recommended method. |
| Carthage | Projects that already use Carthage | Requires Carthage 0.38.0 or later and the --use-xcframeworks option. Long-term Carthage support isn't guaranteed. |
Prerequisites
Before you begin, be sure you have:
- A backup or committed copy of your project, so you can revert changes.
- A deployment target of iOS 16.0 or later.
- A Podfile that lists the Braintree pods your app uses.
- The Enable Modules build setting set to YES, if your app contains Objective-C code.
- Xcode 16.2 or later and Swift 5.10 or later.
- Working knowledge of Xcode and either Carthage or Swift Package Manager, depending on your installation method.
Remove CocoaPods from your project
Complete these steps before you install the SDK with a new method.
- Note the Braintree pods in your Podfile. Use the following table to find the matching Swift Package Manager libraries. Other pods map by name. For example,
Braintree/ApplePaymaps toBraintreeApplePay. For the full list of libraries, see Choose your Braintree libraries.Pod Swift Package Manager libraries BraintreeBraintreeCard,BraintreeCore, andBraintreePayPalBraintree/DataCollectorBraintreeDataCollectorBraintree/VenmoBraintreeVenmo - Remove the Braintree entries from your Podfile.
If your Podfile still lists other pods: Run pod install, and then continue to Install the SDK. The remaining pods still use CocoaPods.
If Braintree was your only pod: Complete the following steps.
- Run
pod deintegrate. - Confirm in Xcode that your project no longer includes the following items. Remove any that remain.
- The [CP] Check Pods Manifest.lock build phase.
- The [CP] Embed Pods Frameworks and [CP] Copy Pods Resources build phases.
- The
Pods_TARGET-NAME.frameworkreference under Frameworks, Libraries, and Embedded Content. - The
.xcconfigincludes that point toPods/Target Support Files/Pods-TARGET-NAME/under Build Settings > Configurations. - The
Pods.xcodeprojreference in your workspace. - The
Podfile,Podfile.lock, andPodsdirectory.
- Open the
.xcodeprojfile instead of the.xcworkspacefile.
The exact items vary by project. Build your app. Errors about missing Braintree modules are expected until you install the libraries in the next section. No CocoaPods errors appear.
Install the SDK
Follow the steps for the installation method you chose.
Choose your Braintree libraries
Select the libraries for the payment methods and features that you use. Both methods use the same libraries. The Notes column lists the other libraries and third-party XCFrameworks that each library needs. Swift Package Manager and Carthage resolve these dependencies for you.
| Library | Covers | Notes |
|---|---|---|
BraintreeAmericanExpress | American Express | Dependencies: BraintreeCore. |
BraintreeApplePay | Apple Pay | Dependencies: BraintreeCore. |
BraintreeCard | Credit cards | Dependencies: BraintreeCore. |
BraintreeCore | Networking for HTTP and GraphQL, configuration, authorization, and analytics | Dependencies: none. All other libraries depend on it. |
BraintreeDataCollector | Device data collection for fraud detection | Dependencies: BraintreeCore and PPRiskMagnes. |
BraintreeLocalPayment | Local payment methods | Dependencies: BraintreeCore, BraintreeDataCollector, and PPRiskMagnes. |
BraintreePayPal | PayPal | Dependencies: BraintreeCore, BraintreeDataCollector, and PPRiskMagnes. |
BraintreePayPalMessaging | PayPal Messaging | Dependencies: BraintreeCore and PayPalMessages. |
BraintreeSEPADirectDebit | SEPA Direct Debit | Dependencies: BraintreeCore. |
BraintreeShopperInsights | Shopper Insights | Dependencies: BraintreeCore. |
BraintreeThreeDSecure | 3D Secure | Dependencies: BraintreeCard, BraintreeCore, CardinalMobile, and PPRiskMagnes. |
BraintreeUIComponents | PayPal and Venmo payment buttons, and card fields | Dependencies: BraintreeCard, BraintreeCore, BraintreeDataCollector, BraintreePayPal, BraintreeVenmo, and PPRiskMagnes. |
BraintreeVenmo | Venmo | Dependencies: BraintreeCore. |
Install with Swift Package Manager
- In Xcode, select File > Add Package Dependencies.
- Enter
https://github.com/braintree/braintree_iosas the package URL. - Select a version rule, and then select Add Package.
- Select the Braintree libraries that you chose, and add them to your app target.
Swift Package Manager resolves the third-party binaries that the libraries need. In your source files, import the libraries you added. The following example imports BraintreeCore, BraintreeCard, and BraintreePayPal:
- Swift
import BraintreeCore
import BraintreeCard
import BraintreePayPalBuild your app. The build succeeds and the imports resolve.
Install with Carthage
- Add the following line to your
Cartfile:- Cartfile
github "braintree/braintree_ios" - Run the following command. Carthage adds an XCFramework for each Braintree library, and for each third-party dependency, to the
Carthage/Builddirectory:- Bash
carthage update --use-xcframeworks - In Xcode, select your app target, and then select the General tab.
- Under Frameworks, Libraries, and Embedded Content, select +.
- Select Add Other > Add Files, and then select the XCFrameworks in the
Carthage/Builddirectory that match your libraries. Include the third-party XCFrameworks that Carthage downloaded for them. - Set Embed to Embed & Sign for each XCFramework that you added.
Build your app. The build succeeds and import BraintreeCore compiles.
Verify your integration
Run your app and complete a test transaction in the Braintree sandbox. A successful test returns a single-use token from the SDK. For test card numbers, see Testing and go live.
Troubleshoot migration issues
If your build fails after you migrate, find your symptom in this section.
Carthage doesn't create XCFrameworks
Cause: You ran carthage update without the --use-xcframeworks option, or your Carthage version is earlier than 0.38.0.
Fix: Update Carthage to 0.38.0 or later, and then run carthage update --use-xcframeworks.
Verification: The Carthage/Build directory contains an XCFramework for each Braintree library.
Build fails with a missing module error
Cause: The Braintree library isn't added to your app target.
Fix: In Xcode, select your app target, select the General tab, and confirm that the library appears under Frameworks, Libraries, and Embedded Content. Add the library if it's missing.
Verification: Build your app. The build succeeds.
Build fails with duplicate symbol errors
Cause: The Braintree pods are still linked in your project alongside the new installation.
Fix: Remove the Braintree entries from your Podfile, run pod install or pod deintegrate, and then clean the build folder in Xcode.
Verification: Build your app. The build succeeds without duplicate symbol errors.
App crashes on launch with a library not loaded error
Cause: You installed with Carthage, and your app doesn't embed a dynamic framework, such as PPRiskMagnes. The app builds, but it can't find the framework at launch and logs dyld: Library not loaded.
Fix: Embed the framework. Under Frameworks, Libraries, and Embedded Content, set Embed to Embed & Sign for the framework.
Verification: Run your app. The app launches without a dyld: Library not loaded error.