This guide is for native iOS apps. React Native apps keep using CocoaPods. See React Native installation.
Before you start
List the Primer pods in yourPodfile. You need this list in step 2.
Also note your
PrimerSDK version. You can find it in Podfile.lock.
Step 1. Remove the Primer pods
- Open your
Podfile. - Delete the line for each Primer pod in the table above.
- Delete any
post_installcode that refers to Primer targets, such asPrimerSDKorPrimer3DS. - If your
Podfilestill has other pods, runpod install. - If no pods are left, run
pod deintegrate. This removes CocoaPods from your Xcode project.
Step 2. Choose the version
The version depends on the Primer pods in your list.Only PrimerSDK, with or without Primer3DS
Use yourPrimerSDK version, for example 2.53.1. You can use the Up to Next Major Version rule. From PrimerSDK 2.28.0, the package includes 3D Secure, so you don’t add it separately. On an older version, also add https://github.com/primer-io/primer-sdk-3ds-ios as a separate package, as described on the 3D Secure page.
Klarna, NOL Pay, ACH via Stripe or iPay88
SPM cannot make a library optional. SoPrimerSDK has a separate version for each of these libraries. That version adds the library for you.
Use the Exact Version rule. Enter your PrimerSDK version followed by the suffix for your library:
For example, for Klarna with
PrimerSDK 2.53.1, enter 2.53.1-3ds-klarna. The -3ds-nolpay, -3ds-stripe and -3ds-ipay88 versions exist from PrimerSDK 2.54.0, so on an older version, move to 2.54.0 or later first.
Follow these rules:
- Don’t add the library as a separate package. The version with the suffix already includes it, and adding both is unreliable.
- Always use Exact Version. With Up to Next Major Version, SPM picks the version without the library.
- When you update
PrimerSDK, change the version by hand. Keep the same suffix. - Each version includes one library. No version includes two. If your app needs two of these libraries, contact Primer support before you move.
Step 3. Add the package in Xcode
- In Xcode, select File > Add Package Dependencies.
- Paste
https://github.com/primer-io/primer-sdk-iosinto the search field. - Under Dependency Rule, choose the rule and version from step 2.
- Select Add Package.
- Add the
PrimerSDKproduct to your app target, then select Add Package.
Step 4. Build and test
- Build and run your app.
- In the Project navigator, check the version under Package Dependencies. If you use a library, the version ends with its suffix.
- Make a test payment with each payment method you offer.
Common errors
Duplicate symbols
Cause: Your app has the Primer pods and the Primer package at the same time. Solution: Remove every Primer pod from yourPodfile, then run pod install again. In Xcode, select Product > Clean Build Folder, then build again.
A payment method is missing
Cause: SPM resolved thePrimerSDK version without your library. This happens when the rule is not Exact Version, or when the version has no suffix.
Solution:
- Select your project, then open Package Dependencies.
- Double-click
primer-sdk-ios. - Set the rule to Exact Version and enter the version with the suffix, for example
2.53.1-3ds-klarna. - Select File > Packages > Resolve Package Versions, then build again.
Stay on CocoaPods for now
If you can’t move yet, add the Primer spec repo at the top of yourPodfile:
RUBY