-
Notifications
You must be signed in to change notification settings - Fork 11
Swift Package Manager integration
Starting from plugin version 10.0.0, the iOS side of the Mobile Messaging Flutter 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 CocoaPods Trunk is scheduled to become permanently read-only. If you are not ready to migrate, 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.
The plugin now ships both a Package.swift manifest (for SPM, under ios/infobip_mobilemessaging/) and a .podspec (for CocoaPods, ios/infobip_mobilemessaging.podspec). Which one Flutter's tooling picks depends on whether Swift Package Manager support is enabled for your Flutter installation and whether your app's ios/ project still has a Podfile:
| Configuration | Dependency manager used |
|---|---|
SPM disabled and ios/Podfile present |
CocoaPods |
SPM enabled and Package.swift available |
Swift Package Manager |
- Flutter added native SPM support starting with Flutter 3.24.0. It is opt-in per Flutter installation via
flutter config.- With Flutter
v3.44.0and above, SPM is the default dependency manager for iOS, unless explicitly disabled.
- With Flutter
- If a
Podfilealready exists in your app'sios/folder and SPM is enabled, Flutter will keep using CocoaPods along with the available Swift Packages to avoid breaking existing projects with mixed native dependencies. - To completely move to SPM you need to remove the
Podfile(see migration steps below), but it is not required.
To use SPM you need:
- Flutter 3.24.0 or higher
- Xcode 16 or higher
- iOS deployment target 15.0 or higher
flutter config --enable-swift-package-managerThis is a global Flutter tooling setting (stored in your Flutter config), not a per-project setting.
In your pubspec.yaml, make sure you're on plugin version 10.0.0 or above:
dependencies:
infobip_mobilemessaging: ^10.0.0 # or aboveflutter pub get-
If you need to raise the minimum deployment target, set it in Xcode's Runner target build settings (
IPHONEOS_DEPLOYMENT_TARGET) and set it to15.0or higher. -
After changing the deployment target, run the following command from the application:
flutter build ios --config-onlyIf all of your iOS dependencies already support Swift Package Manager, the legacy Cocoapods artifacts can be removed:
cd ios
rm -f Podfile Podfile.lock
rm -rf Pods
pod deintegrate
cd ..flutter pub get
flutter build iosflutter pub get regenerates ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage, which now references this plugin's Package.swift instead of a .podspec. flutter build (or opening the project in Xcode) triggers Xcode to resolve the SPM graph, fetching MobileMessaging and its dependencies from mobile-messaging-sdk-ios.
-
Open
ios/Runner.xcodeprojif only Swift Package Manager dependencies are used in the application -
Open
ios/Runner.xcworkspaceif both Swift Package Manager and Cocoapods dependencies are used in the application -
Once the project is opened, go to
Runner > AppDelegate.swiftwhere theMobileMessagingPluginApplicationDelegateis located, and change the import fromMobileMessagingtoinfobip_mobilemessaging.
The AppDelegate.swift should now look like this:
import UIKit
import Flutter
import infobip_mobilemessaging
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
MobileMessagingPluginApplicationDelegate.install()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}- After modifying the Swift file, run the project.
To integrate the Notification Service Extension for Rich Notifications and better delivery reporting on iOS with Swift Package Manager, following the guide here.
Just like the CocoaPods integration (where MobileMessaging/WebRTCUI is only added when $WebRTCUIEnabled is set in the Podfile), the SPM integration does not download or link WebRTCUI by default. To enable it, set the INFOBIP_WEBRTCUI_ENABLED environment variable to 1 (or true) in the environment that resolves the package, before running flutter pub get / flutter build ios:
export INFOBIP_WEBRTCUI_ENABLED=1
flutter build iosSince this is read at package-manifest resolution time (not app runtime), it must be exported in the shell/CI environment — Xcode scheme "Environment Variables" don't apply. If you resolve packages by opening Runner.xcworkspace/.xcodeproj directly in Xcode's GUI, export the variable and launch Xcode from that same shell (open -a Xcode .), or run launchctl setenv INFOBIP_WEBRTCUI_ENABLED 1 and relaunch Xcode.
If you toggle the flag after the package has already been resolved, clear the cached resolution first (flutter clean, delete ios/.build/Package.resolved, or use Xcode's File > Packages > Reset Package Caches).
If you are not ready to migrate, disable the SPM flag and keep the existing ios/Podfile in your project:
# disable the SPM flag
flutter config --no-enable-swift-package-manager
# fetch the dependencies
flutter pub get
# build the iOS project
flutter build iosNo changes to the plugin are needed, as the .podspec remains published and CocoaPods will continue to be used exactly as before.
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.
Ensure you have a stable internet connection the first time Xcode resolves packages (either via flutter build ios or opening the project directly), since it needs to fetch packages from GitHub.
If you are getting the error above when using the dependency in the the example (or your) application, this usually means that support for Swift Package Manager was not enabled in the Flutter configuration. Simply run the following command to enable it:
flutter config --enable-swift-package-managerAfter enabling it, run the flutter build ios command again.
If you are seeing the error: FlutterGeneratedPluginSwiftPackage has a lower minimum deployment target, ensure that the IPHONEOS_DEPLOYMENT_TARGET flag on the Runner target (and on the MobileMessagingNotificationServiceExtension target, if present) is set to 15.0 or higher.
If you do not want to modify the flag manually, simply run the command:
flutter build ios --config-onlyNavigate to the ios folder and run the following command:
pod deintegrateThis will remove the Pods manifests, frameworks and xcconfig files.
After running the command, reopen the Runner project and run the application.