Skip to content

Swift Package Manager integration

Milan Parađina edited this page Jul 6, 2026 · 1 revision

Swift Package Manager Integration

Starting from plugin version 8.5.0, the iOS side of the Mobile Messaging Cordova plugin supports Swift Package Manager (SPM) as the dependency manager, in addition to the existing CocoaPods integration.

CocoaPods will still be fully supported until December 2nd, 2026, when they will be scheduled to become permanently read-only. If you are not ready to migrate or your toolchain requires cordova-ios v7, you can continue using CocoaPods and will receive all plugin updates as before. Until then, no action is required. After December 2nd, the iOS side of the plugin will only be updated with Swift Package Manager.


Background

The plugin now ships both a Package.swift manifest (for SPM) and a <podspec> block in plugin.xml (for CocoaPods). Which one is used depends entirely on your version of cordova-ios:

cordova-ios version Dependency manager used
v7.x CocoaPods (<podspec>)
v8.x and above Swift Package Manager (Package.swift)
  • No changes to your config.xml or plugin configuration are needed, as the correct path is selected automatically at cordova platform add ios time.
  • In case Swift Package Manager is not available in application, CocoaPods will be used.

Prerequisites for SPM

To use SPM you need:

  • cordova-ios v8.0.0 or higher
  • Xcode 16 or higher
  • NodeJS 20.17 or higher
  • iOS deployment target 15.0 or higher (set in your config.xml)

The official release notes for Cordova iOS v8 can be found here.


Migrating from CocoaPods to SPM

1. Update the packages

In your project's package.json, update the cordova-ios and the com-infobip-plugins-mobilemessaging plugin version:

"devDependencies": {
    "cordova-ios": "^8.0.0",
    "com-infobip-plugins-mobilemessaging": "^8.5.0" // or above
}

Then install:

npm install

2. Ensure your config.xml has the correct deployment target

<platform name="ios">
    <preference name="SwiftVersion" value="5.0" />
    <preference name="deployment-target" value="15.0" />
</platform>

3. Re-add the iOS platform

In case the application was using cordova-ios@7.x.x previously, the iOS platform needs to be removed and re-added to the project. Remove and re-add the iOS platform so cordova-ios v8 sets up SPM instead of CocoaPods:

cordova platform remove ios
cordova platform add ios

During cordova platform add ios, messages from SPM resolving packages instead of CocoaPods running pod install will be shown, along with the Notification Service Extension (NSE) being added to the new project. The MobileMessaging SDK and its dependencies are fetched via SPM from the mobile-messaging-sdk-ios repository.

4. Open and build

Open the generated App.xcworkspace in Xcode and build normally. No Podfile or pod install is involved.


What changes with SPM

CocoaPods (cordova-ios v7) SPM (cordova-ios v8+)
Dependency resolution pod install at prepare time Xcode resolves packages at build time
Lockfile Podfile.lock Package.resolved
Workspace structure Pods/ directory alongside the project packages/ directory inside the platform folder

Notification Service Extension

If you use the Notification Service Extension (for delivery improvements and rich push), the setup is the same regardless of which dependency manager you use. The IOS_EXTENSION_APP_GROUP configuration in the application's config.xml file needs to be set, and the plugin handles the rest automatically.

With CocoaPods, the extension pod is added to the Podfile. With SPM, the extension dependency is resolved through the same Package.swift.


Staying on CocoaPods

If you are not ready to migrate, simply keep cordova-ios v7 in your project. No changes to the plugin are needed. The <podspec> block remains in plugin.xml and CocoaPods will continue to be used exactly as before.

"devDependencies": {
    "cordova-ios": "^7.1.1"
}

The plugin will receive updates, including new features and bug fixes with the CocoaPods integration, until the official CocoaPods Trunk becomes permanently read-only. After that period, the iOS part of the plugin will receive regular updates only via Swift Package Manager.


Troubleshooting

SPM package resolution fails

Ensure you have a stable internet connection when running cordova platform add ios for the first time, as Xcode needs to fetch packages from GitHub.

Deployment target warning

If you see a warning about deployment target being too low (e.g. 11.0), ensure your config.xml has deployment-target set to 15.0 or higher inside <platform name="ios">.

Still seeing CocoaPods being used after upgrading cordova-ios

Run a full platform remove/add to ensure the platform directory is regenerated with the new cordova-ios version:

cordova platform remove ios
cordova platform add ios

Clone this wiki locally