Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ jobs:
working-directory: sample
run: |
rm -f yarn.lock
# Yarn 1 keeps its unpacked copy of a local .tgz under .tmp in the restored cache, keyed
# only by the file's path, so without this the sample installs an old build of this package.
rm -rf "$(yarn cache dir)/.tmp"
yarn install

- name: Run Android sample app
Expand All @@ -126,8 +129,8 @@ jobs:
- ios_deps: spm
check_name: iOS Sample App (SPM)
env:
# sample/ios/Podfile takes the mParticle SDKs from Swift Package Manager when this is 1.
MP_USE_SPM: ${{ matrix.ios_deps == 'spm' && '1' || '0' }}
# sample/ios/Podfile takes the mParticle SDKs from Swift Package Manager unless this is 1.
MP_USE_COCOAPODS: ${{ matrix.ios_deps == 'cocoapods' && '1' || '0' }}
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down Expand Up @@ -167,12 +170,29 @@ jobs:
working-directory: sample
run: |
rm -f yarn.lock
# Yarn 1 keeps its unpacked copy of a local .tgz under .tmp in the restored cache, keyed
# only by the file's path, so without this the sample installs an old build of this package.
rm -rf "$(yarn cache dir)/.tmp"
yarn install

- name: Install Ruby dependencies
working-directory: sample
run: bundle install

# A tvOS app must get the opt-out error, not silently lose this pod (see the podspec's platforms).
- name: Check that a tvOS Podfile stops with the iOS-only error
if: matrix.ios_deps == 'spm'
working-directory: sample/ios
run: |
sed -i '' "s/^platform :ios, '15.6'/platform :tvos, '15.6'/" Podfile
if bundle exec pod install > tvos-pod-install.log 2>&1; then
cat tvos-pod-install.log
echo "pod install succeeded for a tvOS target; it should stop with the iOS-only error."
exit 1
fi
git checkout -- Podfile
grep -F '[mParticle] Swift Package Manager mode is iOS only' tvos-pod-install.log || { cat tvos-pod-install.log; exit 1; }

- name: Build iOS sample app and run native unit tests
working-directory: sample/ios
run: |
Expand All @@ -186,6 +206,7 @@ jobs:
test \
-only-testing:MParticleSampleTests/RCTConvertCommerceMappingTests \
-only-testing:MParticleSampleTests/RoktNativeLayoutComponentViewSizingTests \
-only-testing:MParticleSampleTests/RoktNativeLayoutComponentViewPropsTests \
-only-testing:MParticleSampleTests/RNMParticleDuplicateSDKTests \
-only-testing:MParticleSampleTests/RNMPRoktEventMapperTests \
-only-testing:MParticleSampleTests/RNMPRoktConfigFactoryTests \
Expand Down
23 changes: 13 additions & 10 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

This document provides migration guidance for changes in `react-native-mparticle`.

## Moving an iOS app to Swift Package Manager mode
## iOS: the mParticle SDKs now come from Swift Package Manager

Optional, iOS only. The default CocoaPods setup keeps working unchanged. See [README › Swift Package Manager (opt-in)](./README.md#swift-package-manager-opt-in) for what the mode does.
**Breaking, iOS only.** React Native and this package still install with CocoaPods, but the mParticle core SDK and its kits now come from Swift Package Manager by default, linked into the app target. CocoaPods trunk becomes read-only on 2 December 2026. An app with no kits needs no change. An app that declares kit pods fails `pod install` until it moves them, or opts out. See [README › Swift Package Manager](./README.md#swift-package-manager).

1. In `ios/Podfile`, add `$RNMParticleUseSPM = true` and `require_relative '../node_modules/react-native-mparticle/ios/mparticle_spm'` above the first `target` block.
2. Remove every mParticle and Rokt pod you declared, such as `pod 'mParticle-Rokt'`, `pod 'mParticle-Apple-SDK'` or `pod 'Rokt-Widget'`.
3. Remove the mParticle, Rokt, `RoktContracts`, `RoktUXHelper` and `DcuiSchema` names from any `pre_install` hook that makes them dynamic frameworks. If the hook lists nothing else, delete it.
4. If you added mParticle or Rokt Swift packages to the app target by hand, remove them in Xcode (target › General › Frameworks, Libraries, and Embedded Content, and the project's Package Dependencies). The helper adds them back, pinned.
5. In `post_install`, after `react_native_post_install(...)`, call `mparticle_spm_post_install(installer, kits: [...])` with one entry per kit.
6. Run `pod install`. It prints each package it adds, and fails with a list of pods to remove if any would add a second copy of the SDK.
7. Build, run a Debug build once to confirm no red box, and commit the `.xcodeproj` change and `Package.resolved`.
To move a bare React Native app:

1. In `ios/Podfile`, remove every mParticle and Rokt pod you declared, such as `pod 'mParticle-Rokt'`, `pod 'mParticle-Apple-SDK'` or `pod 'Rokt-Widget'`.
2. Remove the mParticle, Rokt, `RoktContracts`, `RoktUXHelper` and `DcuiSchema` names from any `pre_install` hook that makes them dynamic frameworks. If the hook lists nothing else, delete it.
3. If you added mParticle or Rokt Swift packages to the app target by hand, remove them in Xcode (target › General › Frameworks, Libraries, and Embedded Content, and the project's Package Dependencies). `pod install` adds them back, pinned.
4. Above the first `target` block, list your kits by CocoaPods name: `$RNMParticleSPMKits = ['mParticle-Rokt']`.
5. Run `pod install`. It prints each package it adds, and fails with a list of pods to remove if any would add a second copy of the SDK.
6. Build, run a Debug build once to confirm no red box, and commit the `.xcodeproj` change and `Package.resolved`.

A Swift `AppDelegate` needs no change: `import mParticle_Apple_SDK` resolves from the Swift package.

To go back, undo these steps: remove `$RNMParticleUseSPM` and the helper call, restore your kit pods and the `pre_install` hook, remove the packages from the app target, and run `pod install`.
Expo apps need no change beyond `npx expo prebuild --clean`: the plugin maps `iosKits` to their Swift packages. A kit the plugin does not know goes in `iosSpmKits`.

To stay on CocoaPods for now, add `$RNMParticleDisableSPM = true` at the top of `ios/Podfile`, before any `target` block, and keep your pods (Expo: `"iosDependencyManager": "cocoapods"`). This is deprecated, and a Podfile with a tvOS target that uses this package must do it.

## Migrating embedded placements to placeholder names

Expand Down
Loading
Loading