Migrate from Cocoapods to SPM
Support for SPM (iOS)The IDWise React Native SDK supports Swift Package Manager (SPM) on iOS. Here's how to move your React Native app's iOS build from CocoaPods to SPM.
Requirements
| Requirement | Version |
|---|---|
| idwise-react-native-sdk | 7.1.0 or later |
| React Native | 0.75 or later |
| Xcode | 15.3 or later |
| iOS deployment target | 15.6 or later |
1. Update the SDK
yarn add idwise-react-native-sdk@latestnpm install idwise-react-native-sdk@latest2. Turn on Swift Package Manager
Check your React Native version with npx react-native --version.
| React Native version | What to do |
|---|---|
| 0.75 or later | Add the setting below as the first line of ios/Podfile. |
| Below 0.75 | SPM isn't supported. Keep using CocoaPods. |
ENV['IDWISE_USE_SPM'] = '1'3. Set the iOS deployment target
In ios/Podfile, set the platform to 15.6 or later:
platform :ios, '15.6'4. Remove the IDWise source from your Podfile
In ios/Podfile, you can delete this line:
source 'https://github.com/idwise/ios-sdk'Keep source 'https://cdn.cocoapods.org/' and the rest of the Podfile. React Native and other libraries still use CocoaPods.
5. Install
cd ios
pod install
cd ..
npx react-native run-iosThe SDK adds the IDWise Swift package to your Xcode project, and Xcode downloads it on the first build. During pod install you'll see:
[IDWise] Linked Swift package IDWise to app target YourApp6. Check that SPM is in use
Open ios/YourApp.xcworkspace in Xcode. idwise-ios-sdk should appear under Package Dependencies.
Commit the files that changed, including ios/Podfile, ios/Podfile.lock, ios/YourApp.xcodeproj/project.pbxproj and ios/YourApp.xcworkspace/xcshareddata/swiftpm/Package.resolved.
Expo
Set IDWISE_USE_SPM to 1 in your build environment instead of editing the Podfile:
IDWISE_USE_SPM=1 npx expo prebuild --clean
IDWISE_USE_SPM=1 npx expo run:ios{ "build": { "production": { "env": { "IDWISE_USE_SPM": "1" } } } }Troubleshooting
| Problem | Fix |
|---|---|
| "The package product requires minimum platform version 15.6" | Set the deployment target to 15.6 (step 3). |
| The app still installs IDWise through CocoaPods | Make sure ENV['IDWISE_USE_SPM'] = '1' is the first line of ios/Podfile, then run pod install again. |
| "IDWISE_USE_SPM needs React Native 0.75 or newer" | Your React Native version is older than 0.75. Upgrade React Native, or keep using CocoaPods. |
| The app crashes at launch: "Library not loaded: @rpath/IDWiseSDK.framework" | Add idwise_spm_post_install(installer) after react_native_post_install(...) in the post_install block. |
| CI fails to resolve packages | Allow the build machine to reach github.com. |
Need to go back?
- Remove
ENV['IDWISE_USE_SPM'] = '1'fromios/Podfile. - Add
source 'https://github.com/idwise/ios-sdk'back toios/Podfile, together withsource 'https://cdn.cocoapods.org/'. - Run the install steps again.
The IDWise SDK switches back to CocoaPods and removes the Swift package automatically.
Updated 5 minutes ago
