Repository navigation
feat(react-native): support full Swift Package Manager integration - #4505
Conversation
Replay incident risk checkThis diff touches code involved in past incidents. This is a heads-up, not a verdict: read the matched sections of INCIDENTS.md and answer their review questions before merging. For a judgment on whether this diff has the same failure mode, run the |
|
Size Change: 0 B Total Size: 19.3 MB ℹ️ View Unchanged
|
Prompt To Fix All With AI### Issue 1
examples/example-rn-spm/README.md:6
**Document the tested SPM command**
The README specifies `npx react-native spm -- deintegrate`, while CI validates `npx react-native spm add --deintegrate --yes`, so following the fixture documentation does not reproduce the tested conversion and invokes the CLI with different arguments.
```suggestion
with `npx react-native spm add --deintegrate --yes` before building it.
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "ci: allow current PostHog packages in Sw..." | Re-trigger Greptile |
🦔 ReviewHog reviewed this pull requestFound 0 must fix, 0 should fix, 1 consider. Published 1 finding (view the review). |
|
ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
There was a problem hiding this comment.
ReviewHog Report
Feature
Issues: 1 issue
Files (6)
packages/react-native-plugin/ios/Package.swiftpackages/react-native-plugin/ios/PosthogReactNativePlugin.swiftpackages/react-native-plugin/posthog-react-native-plugin.podspecpackages/react-native-plugin/scripts/check-spm-manifest.mjspackages/react-native-plugin/package.json.changeset/react-native-full-spm.md
What were the main changes
- Add a hand-written SwiftPM Package.swift with separate Swift implementation target (PosthogReactNativePlugin) and Objective-C++ registration bridge target (PosthogReactNativePluginBridge), since SwiftPM cannot compile Swift and Objective-C++ in one target
- Mark PosthogReactNativePlugin class and its overridden RCTEventEmitter methods
publicso the Swift package's separate bridge target can subclass/access it across module boundaries - Resolve posthog-ios via SwiftPM at the same minimum version (3.69.2) used by the podspec, pinned to Swift 5 language mode to match CocoaPods integration
- Narrow podspec source_files glob now that Package.swift lives alongside the plugin sources and must be excluded from CocoaPods builds
- Add check-spm-manifest.mjs validation script (run via test:unit) asserting the podspec and Package.swift posthog-ios version floors match and required package/product names and Swift language mode are preserved
Problem
React Native 0.87 can use Swift Package Manager for the full iOS native dependency graph, but
@posthog/react-native-plugincannot be packaged by React Native's automatic scaffolder. The plugin mixes Swift and Objective-C++, which SwiftPM cannot compile in one target. This prevents CocoaPods-free React Native projects from linking the PostHog native module.Changes
posthog-iosthrough SwiftPM at the same minimum version used by the podspec.PosthogReactNativePluginObjective-C class.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi. The package uses two SwiftPM targets because Swift and Objective-C++ cannot share one target. The React Native SDK remains JavaScript-only, while its optional native plugin owns the Swift package. Validation included plugin tests, lint, JavaScript builds, manifest and tarball checks, React Native 0.87 SwiftPM conversion, and Debug and Release simulator builds.