Skip to content

refactor: Move MPRokt Swift interop to core SDK for single-import#702

Closed
thomson-t wants to merge 2 commits intomainfrom
thomson-t/refactor/rokt-single-import
Closed

refactor: Move MPRokt Swift interop to core SDK for single-import#702
thomson-t wants to merge 2 commits intomainfrom
thomson-t/refactor/rokt-single-import

Conversation

@thomson-t
Copy link
Copy Markdown
Contributor

Summary

  • Move MPRokt Swift bridge extensions from the Rokt Kit (mParticle-Rokt-Swift target) into the core SDK (mParticle_Apple_SDK target) so import mParticle_Apple_SDK alone provides all MPRokt APIs in Swift
  • Delete MPRokt+SwiftInterop.swift from the Kit — no longer needed since the bridge lives in the core SDK
  • Restore original method names (events instead of subscribeToPlacementEvents) — no API rename needed
  • Update MIGRATING.md to reflect single-import experience
  • Update example apps to demonstrate the single-import pattern
  • Point Kit Package.swift to main branch

Motivation

After the 9.0 merge, Swift callers needed two imports (import mParticle_Apple_SDK + import mParticle_Rokt_Swift) to access MPRokt methods that use RoktContracts types (RoktEvent, RoktConfig, etc.). This happened because MPRokt.h forward-declares these types, and Swift's ObjC importer can't resolve forward-declared types from another module.

The core SDK already @_exported imports both mParticle_Apple_SDK_ObjC and RoktContracts, so placing the Swift bridge extension there gives Swift consumers access to all MPRokt APIs with a single import. ObjC consumers are unaffected — the Swift extension methods are not @objc and don't interfere with the ObjC method dispatch.

Test plan

  • xcodebuild build for iOS Simulator passes with MPRokt+Swift.swift in the core SDK target
  • trunk check passes on all modified files
  • Build the Rokt Kit package to confirm it compiles without MPRokt+SwiftInterop.swift
  • Verify SPM-Swift-Example builds and import mParticle_Apple_SDK alone provides selectPlacements, events, globalEvents, registerPaymentExtension, selectShoppableAds
  • Run ObjC and Swift unit test suites

thomson-t and others added 2 commits April 6, 2026 14:53
…erience

Swift consumers previously needed two imports to access MPRokt APIs that use
RoktContracts types: `import mParticle_Apple_SDK` and `import mParticle_Rokt_Swift`.
This moves the bridge extensions into the core SDK target so a single
`import mParticle_Apple_SDK` provides all MPRokt methods in Swift.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Revert to placeholder keys to pass mparticle-api-key-check lint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomson-t thomson-t requested a review from a team as a code owner April 6, 2026 18:54
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 6, 2026

PR Summary

Medium Risk
Medium risk because it changes how MPRokt APIs are surfaced to Swift (new bridging extensions and restored method names), which could impact compilation/behavior for existing Swift integrations if the selector bridging is incorrect.

Overview
Moves the Swift bridging for MPRokt into the core SDK by adding MParticle/Sources/mParticle_Apple_SDK/MPRokt+Swift.swift, so Swift callers can access selectPlacements, events, globalEvents, registerPaymentExtension, and selectShoppableAds via import mParticle_Apple_SDK.

Removes the kit-side Swift interop source from the Rokt kit project and updates migration docs and examples to use the original events naming (dropping the Swift-only subscribeToPlacementEvents workaround) and demonstrate event logging for overlay/bottomsheet placements.

Updates the Rokt kit Package.swift to track the mParticle Apple SDK main branch, and adjusts the SPM example Xcode projects’ package/product dependencies accordingly.

Reviewed by Cursor Bugbot for commit 01bfd40. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

📦 SDK Size Impact Report

Measures how much the SDK adds to an app's size (with-SDK minus without-SDK).

Metric Target Branch This PR Change
App Bundle Impact 1.75 MB 1.75 MB +N/A
Executable Impact 896 bytes 896 bytes +N/A
XCFramework Size 6.38 MB 6.38 MB +N/A

➡️ SDK size impact change is minimal.

Raw measurements

Target branch (main):

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1880,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1796,"sdk_executable_impact_bytes":896,"xcframework_size_kb":6532}

This PR:

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1880,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1796,"sdk_executable_impact_bytes":896,"xcframework_size_kb":6532}

Comment on lines +3 to 5
import mParticle_Apple_SDK_ObjC
import RoktContracts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need these imports here as they are already visible from mParticleAppleSDKExports.swift

@thomson-t thomson-t closed this Apr 6, 2026
@thomson-t thomson-t deleted the thomson-t/refactor/rokt-single-import branch April 6, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants