Conversation
PR SummaryMedium Risk Overview Updates Adds native unit test suites covering Rokt event mapping, configuration generation, and Swift bridging selector availability, and enables them in CI workflows. Reviewed by Cursor Bugbot for commit 3b0b440. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The checked-in RNMParticle Xcode target does not compile the new Swift implementations referenced by its Objective-C++ sources.
Review effort: Balanced
Findings: 1
What changed in this PR
Moves Rokt-typed iOS logic into Swift to support future Swift Package Manager integration while preserving the Objective-C++ bridge.
Changes:
- Adds Swift event, configuration, and embedded-view adapters.
- Updates Objective-C++ callers and CocoaPods settings.
- Adds characterization tests to both CI modes.
| File | Description |
|---|---|
.github/workflows/pull-request.yml |
Runs new iOS tests. |
react-native-mparticle.podspec |
Configures Swift and module support. |
ios/RNMParticle/RNMPRoktSwift.h |
Declares the Swift bridge API. |
ios/RNMParticle/RNMPSDKImports.h |
Restricts RoktContracts imports to Objective-C. |
ios/RNMParticle/RNMPRokt.mm |
Uses Swift config and view adapters. |
ios/RNMParticle/RoktEventManager.mm |
Delegates event mapping to Swift. |
ios/RNMParticle/RoktNativeLayoutComponentView.h |
Exposes the embedded view as UIView. |
ios/RNMParticle/RoktNativeLayoutComponentView.mm |
Creates embedded views through Swift. |
ios/RNMParticle/Swift/RNMPRoktEventMapper.swift |
Maps Rokt events and side effects. |
ios/RNMParticle/Swift/RNMPRoktConfigFactory.swift |
Builds Rokt configuration objects. |
ios/RNMParticle/Swift/RNMPRoktViews.swift |
Creates and identifies embedded views. |
ios/RNMParticle.xcodeproj/project.pbxproj |
Adds the bridge header, but omits Swift sources. |
sample/ios/MParticleSampleTests/RNMPRoktEventMapperTests.m |
Characterizes event payloads and ordering. |
sample/ios/MParticleSampleTests/RNMPRoktConfigFactoryTests.m |
Tests configuration conversion. |
sample/ios/MParticleSampleTests/RNMPRoktSwiftTests.m |
Verifies bridge selectors and types. |
sample/ios/MParticleSample.xcodeproj/project.pbxproj |
Registers the new tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0a31cef to
78250f6
Compare
78250f6 to
8d92742
Compare
The merge-base changed after approval.
8d92742 to
6c464f0
Compare
| # The Rokt-typed code is Swift (ios/RNMParticle/Swift); Objective-C++ reaches it through the | ||
| # hand-written RNMPRoktSwift.h. Private headers keep C++ and React headers out of the module's | ||
| # umbrella header, which the Swift code's module would otherwise fail to build. | ||
| s.swift_version = '5.0' |
There was a problem hiding this comment.
Declared swift_version too low for code features
Low Severity
The podspec declares swift_version = '5.0', but the Swift files use the optional binding shorthand (guard let map, if let viewName, if let callback, if let height, let placement) introduced in SE-0345, which requires Swift 5.7. CocoaPods uses this value for compatibility checking, so it would incorrectly allow installation on Xcode 13 (Swift 5.5/5.6), where the code would fail to compile. The value needs to be '5.7' or higher.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 6c464f0. Configure here.
Under Swift Package Manager, Objective-C++ files cannot reach another target's generated Swift header, so they cannot use the RoktContracts types. Event mapping (RNMPRoktEventMapper), config building (RNMPRoktConfigFactory) and the embedded view (RNMPRoktViews) are now Swift. The .mm adapters reach them through the hand-written RNMPRoktSwift.h, which uses only Foundation and UIKit types, and no .mm file imports RoktContracts. The podspec adds swift_version, DEFINES_MODULE and private headers, plus the Swift include path for packages in Swift Package Manager mode. Characterization tests for every Rokt event type and for the config mapping were written against the Objective-C first, and pass unchanged against the Swift. A drift test checks every selector the header declares. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
RCTViewComponentView's initWithFrame: leaves plain ViewProps in _props.
In a debug build of React Native, the first updateProps asserts that a
subclass has replaced them, so the app crashes with
NSInternalInconsistencyException ("`RCTViewComponentView` subclasses
(and `RoktNativeLayoutComponentView` particularly) must setup `_props`
instance variable with a default value in the constructor.") as soon as
a RoktLayoutView mounts. Release builds of React Native only log the
failed assert, so release builds, and any app that links the
release-flavoured prebuilt React Native frameworks, do not crash.
Start from RoktNativeLayoutShadowNode::defaultSharedProps() in
initWithFrame:, the same way the superclass starts from
ViewShadowNode::defaultSharedProps(), and add a test that the view's
initial props are RoktNativeLayoutProps. The test checks the
props type directly, so it fails whichever React Native flavour the
sample links.
The omission predates this series: 3.4.0 has it too.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
6c464f0 to
3b0b440
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3b0b440. Configure here.
| -only-testing:MParticleSampleTests/RNMParticleDuplicateSDKTests \ | ||
| -only-testing:MParticleSampleTests/RNMPRoktEventMapperTests \ | ||
| -only-testing:MParticleSampleTests/RNMPRoktConfigFactoryTests \ | ||
| -only-testing:MParticleSampleTests/RNMPRoktSwiftTests \ |
There was a problem hiding this comment.
New props test class missing from CI test list
Medium Severity
The new RoktNativeLayoutComponentViewPropsTests class, which validates the debug-crash props fix, is never run in CI. It lives in RoktNativeLayoutComponentViewSizingTests.mm but is a separate XCTestCase subclass. Because xcodebuild -only-testing: opts in by class name, only RoktNativeLayoutComponentViewSizingTests runs — RoktNativeLayoutComponentViewPropsTests is silently skipped. A future regression in the _props initialization would not be caught.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3b0b440. Configure here.



Why
React Native is moving apps to Swift Package Manager, and in that setup this package's Objective-C++ files cannot see the Rokt types they use today (the embedded view, events and config). The next pull request, an experimental package manifest for React Native's own Swift Package Manager mode, needs that code to live somewhere that can see them. Once this lands, all Rokt-typed logic is in Swift, and the Objective-C++ files only pass plain views and dictionaries through. Apps see no difference: the same events reach JavaScript, with the same contents, in the same order.
Programme
Part of the plan to support Swift Package Manager in this package before the CocoaPods central repository becomes read-only on 2026-12-02 (CocoaPods announcement). This is the fifth of eight pull requests, all merging into the
workstation/spm-migrationbranch, which merges intomainonce the series is complete, and shipping together in one release; the plan record is internal and cannot be linked here.What changes
Before:
RoktEventManager.mmmapped every Rokt event type to its JavaScript payload,RNMPRokt.mmbuilt the Rokt config and checked for embedded views, and the Fabric view created aRoktEmbeddedViewdirectly. All of them imported the RoktContracts headers.After: that logic is in three Swift classes in
ios/RNMParticle/Swift/:RNMPRoktEventMapper: event to payload, plus the callback and height side events;RNMPRoktConfigFactory: dictionary to config;RNMPRoktViews: creates and recognises the embedded view.The Objective-C++ files reach them through one hand-written header,
RNMPRoktSwift.h, which uses only Foundation and UIKit types; the generated Swift header can't be reached from Objective-C++ under Swift Package Manager. No.mmfile references RoktContracts any more, and the import header now gives RoktContracts to.mfiles only. The Fabric view'sroktEmbeddedViewproperty is typedUIView. The podspec gainsswift_version,DEFINES_MODULE, private headers (so C++ and React headers stay out of the module), and, in Swift Package Manager mode, the Swift include path for the packages.The tests were written first, against the original Objective-C, and pass unchanged against the Swift port:
CI runs the three new test classes in both legs. No documentation change is needed; the changelog is generated by the release-draft workflow.
This pull request also fixes a crash that predates the series (3.4.0 has it). The Fabric view kept the plain
ViewPropsits superclass starts with, so debug builds of React Native threwNSInternalInconsistencyException("RCTViewComponentViewsubclasses (andRoktNativeLayoutComponentViewparticularly) must setup_propsinstance variable with a default value in the constructor.") as soon as aRoktLayoutViewmounted. Release builds of React Native only log that check.initWithFrame:now starts fromRoktNativeLayoutShadowNode::defaultSharedProps(), as the superclass does withViewShadowNode::defaultSharedProps(), and a new test checks the view's initial props type. The fix is its own commit on this branch.Start reading at
RNMPRoktSwift.h, thenRoktEventManager.mm(the event adapter), then the Swift files.Linked work
Depends on: the Expo config plugin option (branch
thomson-t/spm-04-expo-spm) and the pull requests below it in this series; merge those first.Unblocks: the experimental
Package.swiftfor React Native's Swift Package Manager mode (branchthomson-t/spm-06-package-swift).Rollout
Path: this merges into
workstation/spm-migration, notmain, so nothing reachesmainor a release until the whole series has merged there and that branch is merged intomain. It then ships in the next release. It is live for every iOS app on that release.Feature flags: none.
Turning it off: a published version cannot be recalled. Reverting this pull request and releasing again restores the Objective-C mapping in the next version.
What we watch: this repository's issues, for Rokt events missing or changed in JavaScript, embedded placements that stop resizing, and iOS build errors mentioning Swift.
Risks
pre_installdynamic-framework hook failpod install("Swift podreact-native-mparticledepends uponmParticle-Apple-SDK-ObjC, which does not define modules"); contained because the nativemParticle-Apple-SDKpod already fails the same way in that setup, so the hook, oruse_frameworks!, is already required; we would see that error reported against that release by an app that had worked before.cacheAttributesvalue is not a string, the config factory drops the wholecacheAttributesmap, where the Objective-C passed such values through unchecked (and they would have crashed when read); not addressed further, because the JavaScript type allows only strings; we would see cache attributes ignored.Risk class: higher — this rewrites how every Rokt event and config reaches the SDK on iOS. Behaviour is pinned by tests written against the old code.
Who
Written by: an automated coding agent (Claude Code), at an engineer's request, following the internal Swift Package Manager migration plan and its proof of concept.
Code reviewed before opening: an independent review agent reviewed the change before it was committed.
Design reviewed before opening: the requesting engineer approved the plan's Swift-first layering, with hand-written Objective-C headers for the Swift classes.
Decision this implements: the requesting engineer's approval of the migration plan on 2026-09-28; the record is internal and cannot be linked.
Checked: on 2026-09-28, with Xcode 27.0 on an iOS 26.5 simulator, the sample app (React Native 0.84, New Architecture):
fmtdependency, which does not build with Xcode 27.RoktLayoutViewmounted; with the fix it mounts the view and keeps running.Not checked: the Old Architecture at runtime; tvOS. CI, which builds with Xcode 16, passed on this pull request.
Size
Hand-written: about 535 lines added and 210 removed in 17 files; 303 of the added lines are tests, and the Swift and adapter code is about 230.
Generated: none.
Why one pull request: the tests pin the old behaviour and must land with the port they guard, and the adapters cannot switch to Swift one file at a time without leaving an Objective-C++ file that still needs the Rokt headers. The props fix rides along because this is the pull request in the series that changes the Fabric view.
Notes for reviewers
Why hand-written headers. Under Swift Package Manager, Swift and Objective-C++ must be separate targets, and an Objective-C++ file can only reach another target's generated
-Swift.hwith C++ modules, which break React Native's headers. The mParticle SDK'sMPRokt.honly forward-declaresRoktEmbeddedView,RoktConfigandRoktEvent, so pointers to them still type-check in.mmfiles without the RoktContracts headers.The characterization test's spy.
RNMPRoktEventMapperTestsswaps the event manager's class for a subclass that recordssendEventWithName:body:instead of sending. The subclass adds no instance variables, so swapping the class of an existing instance is safe.A clamp worth knowing.
CacheConfigraises a zero duration to its 90-minute maximum. A config test now pins that, since the JavaScript wrapper sends 0 when the duration is missing.🤖 Generated with Claude Code