Migrate from Cocoapods to SPM

Migrate an existing MXO Capacitor iOS project from CocoaPods to Swift Package Manager.

MXO Capacitor SDK 4.1.0 and later include SPM support. This page describes how to migrate your existing MXO Capacitor iOS project from Cocoapods to Swift Package Manager (SPM).

After migration, your app continues to use the MXO Capacitor SDK from npm. The native MXO iOS SDK is resolved automatically at build time. See the Capacitor documentation for more details.

  1. Upgrade to MXO Capacitor SDK 4.1.0.

    Run the following command:

    npm install @medallia/mxo-capacitor-js-sdk@4.1.0
  2. Run the Capacitor SPM migration assistant.

    Run the following command:

    npx cap spm-migration-assistant

    This removes Cocoapods from your iOS project and creates the Capacitor SPM configuration (CapApp-SPM and debug.xcconfig).

  3. Connect Capacitor to your Xcode project.

    Open your iOS project in Xcode:

    npx cap open ios

    Select the App target, open the Package Dependencies tab, click +, choose Add Local..., select ios/App/CapApp-SPM, and add the package.

  4. Attach the Capacitor debug configuration.

    In Xcode, select the App target, open the Info tab, click Add Configuration File..., select ios/debug.xcconfig, and choose xcconfig.

  5. Add the MXO resource bundle to your app.

    Select the App target, open the Build Phases tab, and under Copy Bundle Resources, click +.

    Add MedalliaMXOBundle.bundle from the resolved MXO iOS SDK package (under SourcePackages/checkouts/mxo-ios-sdk/MedalliaMXO.embeddedframework/).

  6. Sync and build.

    Run the following commands:

    npm run build
    npx cap sync ios

    Build and run your app from Xcode, or deploy to your device or simulator.

Your iOS project now uses Swift Package Manager instead of Cocoapods. The Podfile and App.xcworkspace are removed, and dependencies are managed through CapApp-SPM/Package.swift.