Repository navigation
feat(ios): add experimental Package.swift for React Native SPM mode #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thomson-t
merged 1 commit into
workstation/spm-migration
from
thomson-t/spm-06-package-swift
Oct 6, 2026
+110
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // swift-tools-version: 6.0 | ||
| // Experimental: for React Native's Swift Package Manager mode (React Native 0.87 or later), which | ||
| // React Native itself marks as not for production. CocoaPods apps do not use this file. | ||
| // | ||
| // The ReactNative and React-GeneratedCode packages are the local packages React Native's autolinker | ||
| // generates for each app, at these paths relative to this package, the same layout other React | ||
| // Native libraries use. Revisit them when React Native publishes a remote Swift package. | ||
|
|
||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "ReactNativeMparticle", | ||
| // React Native's autolinker requires iOS 15; the mParticle SDK declares the same. | ||
| platforms: [.iOS(.v15)], | ||
| products: [ | ||
| .library(name: "ReactNativeMparticle", targets: ["ReactNativeMparticle"]), | ||
| ], | ||
| dependencies: [ | ||
| .package(name: "ReactNative", path: "../../../../xcframeworks"), | ||
| .package(name: "React-GeneratedCode", path: "../../../ios"), | ||
| // Same URLs as the mParticle kits use, so SwiftPM unifies them into one package identity. | ||
| .package(url: "https://github.com/mParticle/mparticle-apple-sdk", "9.2.2"..<"10.0.0"), | ||
| .package(url: "https://github.com/ROKT/rokt-contracts-apple.git", "2.0.0"..<"3.0.0"), | ||
| ], | ||
| targets: [ | ||
| // A separate target: SwiftPM cannot mix Swift and Objective-C++ in one target. | ||
| .target( | ||
| name: "RNMParticleSwift", | ||
| dependencies: [.product(name: "RoktContracts", package: "rokt-contracts-apple")], | ||
| path: "ios/RNMParticle/Swift" | ||
| ), | ||
| .target( | ||
| name: "ReactNativeMparticle", | ||
| dependencies: [ | ||
| "RNMParticleSwift", | ||
| .product(name: "ReactHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), | ||
| .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), | ||
| .product(name: "mParticle-Apple-SDK", package: "mparticle-apple-sdk"), | ||
| .product(name: "RoktContracts", package: "rokt-contracts-apple"), | ||
| ], | ||
| path: ".", | ||
| sources: [ | ||
| "ios/RNMParticle/RNMPRokt.h", | ||
| "ios/RNMParticle/RNMPRokt.mm", | ||
| "ios/RNMParticle/RNMPRoktSwift.h", | ||
| "ios/RNMParticle/RNMPSDKImports.h", | ||
| "ios/RNMParticle/RNMParticle.h", | ||
| "ios/RNMParticle/RNMParticle.mm", | ||
| "ios/RNMParticle/RoktEventManager.h", | ||
| "ios/RNMParticle/RoktEventManager.mm", | ||
| "ios/RNMParticle/RoktLayoutManager.m", | ||
| "ios/RNMParticle/RoktNativeLayoutComponentView.h", | ||
| "ios/RNMParticle/RoktNativeLayoutComponentView.mm", | ||
| "ios/RNMParticle/RoktPlaceholderRegistry.h", | ||
| "ios/RNMParticle/RoktPlaceholderRegistry.m", | ||
| ], | ||
| publicHeadersPath: "ios", | ||
| // Without RCT_NEW_ARCH_ENABLED the TurboModule and Fabric code compiles out, and the app | ||
| // crashes looking up the RoktNativeLayout component. | ||
| cSettings: [.define("RCT_NEW_ARCH_ENABLED", to: "1"), .headerSearchPath("ios/RNMParticle")], | ||
| cxxSettings: [ | ||
| .define("RCT_NEW_ARCH_ENABLED", to: "1"), | ||
| .headerSearchPath("ios/RNMParticle"), | ||
| .define("DEBUG", .when(configuration: .debug)), | ||
| .define("NDEBUG", .when(configuration: .release)), | ||
| ], | ||
| linkerSettings: [.linkedFramework("UIKit"), .linkedFramework("Foundation"), .linkedFramework("CoreGraphics")] | ||
| ), | ||
| ], | ||
| cxxLanguageStandard: .cxx20 | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| /** | ||
| * The podspec compiles every file under ios/ by glob, but Package.swift lists the Objective-C++ | ||
| * target's sources by hand, and CI does not build that manifest. Keep the two in step. | ||
| */ | ||
| const root = path.join(__dirname, '..', '..'); | ||
|
|
||
| it('lists every ios/RNMParticle source in Package.swift', () => { | ||
| const manifest = fs.readFileSync(path.join(root, 'Package.swift'), 'utf-8'); | ||
| const listed = new Set( | ||
| [...manifest.matchAll(/"(ios\/RNMParticle\/[^"]+\.(?:h|m|mm))"/g)].map( | ||
| match => match[1] | ||
| ) | ||
| ); | ||
| const onDisk = fs | ||
| .readdirSync(path.join(root, 'ios', 'RNMParticle'), { recursive: true }) | ||
| .map(String) | ||
| .filter(file => /\.(h|m|mm)$/.test(file)) | ||
| .map(file => `ios/RNMParticle/${file}`); | ||
|
|
||
| expect([...listed].sort()).toEqual(onDisk.sort()); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.