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

RequirementVersion
idwise-react-native-sdk7.1.0 or later
React Native0.75 or later
Xcode15.3 or later
iOS deployment target15.6 or later

1. Update the SDK

yarn add idwise-react-native-sdk@latest
npm install idwise-react-native-sdk@latest

2. Turn on Swift Package Manager

Check your React Native version with npx react-native --version.

React Native versionWhat to do
0.75 or laterAdd the setting below as the first line of ios/Podfile.
Below 0.75SPM 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-ios

The 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 YourApp

6. 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

ProblemFix
"The package product requires minimum platform version 15.6"Set the deployment target to 15.6 (step 3).
The app still installs IDWise through CocoaPodsMake 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 packagesAllow the build machine to reach github.com.

Need to go back?

  1. Remove ENV['IDWISE_USE_SPM'] = '1' from ios/Podfile.
  2. Add source 'https://github.com/idwise/ios-sdk' back to ios/Podfile, together with source 'https://cdn.cocoapods.org/'.
  3. Run the install steps again.

The IDWise SDK switches back to CocoaPods and removes the Swift package automatically.


Did this page help you?