## Related terms

- mobile\-sdk
- campaign

See the [glossary](/glossary.md) for definitions.

---

# Migrating to Swift Package Manager (Flutter)

Starting with version 3.1.0, the Synerise Flutter SDK supports Swift Package Manager. When Swift Package Manager is enabled in your app, Flutter integrates the plugin through it, and the plugin brings the native SDK (`SyneriseSDK`) from the [synerise-ios-sdk](https://github.com/Synerise/synerise-ios-sdk) package.

Swift Package Manager support requires **Flutter 3.41 or later**. It is enabled by default in **Flutter 3.44** and later.

For the installation of the plugin, see [Installation and configuration (Flutter)](/developers/mobile-sdk/installation-and-configuration/flutter).

## Staying on CocoaPods

If you can't migrate now, disable Swift Package Manager. The plugin is then integrated through CocoaPods, and your current Podfile works without changes. For the settings, see [Checking and changing the integration](/developers/mobile-sdk/installation-and-configuration/flutter#checking-and-changing-the-integration).

## Who should migrate

You should migrate if both of the following are true:

- Your app uses Swift Package Manager.
- Your `ios/Podfile` contains `pod 'SyneriseSDK'` in your app's main target or in extension targets.

If Swift Package Manager is disabled, you don't need any changes. The plugin is integrated through CocoaPods.

## Why the build fails after the update

In version 3.0.x, the plugin was integrated through CocoaPods even with Swift Package Manager enabled. Starting with version 3.1.0, it is integrated through Swift Package Manager and brings `SyneriseSDK` itself. A `SyneriseSDK` pod is then a second copy of the same framework, and the build fails with the following error:

```plaintext
Multiple commands produce '.../Frameworks/SyneriseSDK.framework'
```

## Migration steps

1. Remove all `pod 'SyneriseSDK'` lines from `ios/Podfile`.  
    Empty extension target blocks can stay.
2. If your app has notification extensions, add the native SDK to them through Swift Package Manager (see [Adding the SDK to notification extensions](#adding-the-sdk-to-notification-extensions)).
3. Build the app with `flutter build ios` or `flutter run`.  
    Flutter updates the remaining pods automatically, so you don't need to run the `pod install` command.

## Adding the SDK to notification extensions

Notification extensions (Notification Service Extension, Notification Content Extension) use `SyneriseSDK` directly, so they need it as their own dependency. For the extension code and push notification setup, see [Configuring push notifications (iOS)](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension).

1. In Xcode, open your project.
2. Open the dependency manager.
3. In the search field, enter `https://github.com/Synerise/synerise-ios-sdk`
4. Set **Dependency Rule** to **Exact Version**.
5. Enter the native SDK version used by the plugin (for example, **6.1.2** for plugin 3.1.0).  
    The plugin defines this version as `syneriseSdkVersion` in its `ios/synerise_flutter_sdk/Package.swift` file.
6. In **Add to project**, select your project.
7. Click **Add Package**.
8. In the **Choose Package Products** window, add the `SyneriseSDK` product to your extension target.
9. For each additional extension:
    1. Select the extension target.
    2. Go to **General > Frameworks and Libraries** and click **+**.
    3. Add the `SyneriseSDK` product.
10. In every extension, make sure that `SyneriseSDK` is set to **Do Not Embed**.


<div class="admonition admonition-important"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

- Do not add the `SyneriseSDK` product to your app's main target. The plugin provides it.
- The version in Xcode must be the same as the version used by the plugin. Otherwise, Swift Package Manager fails with the following error:
    ```plaintext
    Dependencies could not be resolved because 'synerise_flutter_sdk' depends on 'synerise-ios-sdk' 6.1.2 and root depends on 'synerise-ios-sdk' <your version>.
    ```
- A missing package in an extension does not always cause a build error. A successful build does not guarantee that the extension is configured correctly, so always add the package explicitly.

</div></div></div>


## Xcode setup tips

- Extension products (`.appex`) must be in the **Embed Foundation Extensions** build phase of your app's main target, not in **Embed Frameworks**. iOS does not recognize an extension embedded in the `Frameworks` folder.
- If Xcode reports a dependency cycle after you add an extension, move the **Embed Foundation Extensions** build phase above the **Thin Binary** phase in your app's main target.
- If **Copy only when installing** is enabled in the **Embed Foundation Extensions** build phase, extensions are embedded only in archive builds. To test rich push notifications in that case, install the app from an archive (for example, through TestFlight or `flutter build ipa`), not with `flutter run`. When the option is disabled (default), `flutter run` embeds extensions too.

## Updating the plugin later

When a plugin update changes the native SDK version, update the `synerise-ios-sdk` package in Xcode to the same **Exact Version**. Until you do, the build fails with the `Dependencies could not be resolved` error described in [Adding the SDK to notification extensions](#adding-the-sdk-to-notification-extensions).

## Troubleshooting

| Error | Cause | Solution |
|---|---|---|
| `Multiple commands produce '.../Frameworks/SyneriseSDK.framework'` | The app uses Swift Package Manager and `ios/Podfile` contains `pod 'SyneriseSDK'`. | Remove `pod 'SyneriseSDK'` from `ios/Podfile` and add the SDK to extensions through Swift Package Manager. See [Migration steps](#migration-steps). |
| `Dependencies could not be resolved because 'synerise_flutter_sdk' depends on 'synerise-ios-sdk' X and root depends on 'synerise-ios-sdk' Y.` | The `synerise-ios-sdk` version added in Xcode is different from the version used by the plugin. | In Xcode, set the package to **Exact Version** X. |
| An error about `../FlutterFramework` (package cannot be accessed or doesn't exist) | Swift Package Manager is enabled on Flutter older than 3.41. | Disable Swift Package Manager with the `flutter config --no-enable-swift-package-manager` command (works on all Flutter versions) or upgrade Flutter to 3.41 or later. |
| Warning: `Please contact the plugin maintainers to request Swift Package Manager adoption.` | Another plugin in your app (for example, an older Firebase version) does not support Swift Package Manager. Flutter integrates that plugin through CocoaPods. | No action is required for the Synerise plugin. It has supported Swift Package Manager since version 3.1.0. |
