Repository navigation
Add Swift Package Manager manifest (React Native 0.87 SwiftPM) - #723
Merged
Merged
Conversation
Generated with RN 0.87.1's `react-native spm scaffold` from the podspec and validated with `swift package dump-package` (swift-tools-version 6.0). The two React path dependencies resolve through RN 0.87's autolinking alias at app resolve time (same shape react-native-safe-area-context ships); they do not resolve in a bare clone. CocoaPods users are unaffected. Needed for React Native 0.87 SwiftPM autolinking, where autolinked native libraries without a manifest fail the package resolve.
Package.swift: - Define RCT_NEW_ARCH_ENABLED. SwiftPM autolinking is New Architecture only, but nothing defined it, so RNViewShot compiled without its TurboModule code and only ran through the legacy interop layer. - Drop the scaffolder markers so `react-native spm scaffold` treats the manifest as self-managed instead of regenerating it per cache slot. - Declare ios/PrivacyInfo.xcprivacy as a resource (parity with the podspec's resource_bundles) rather than relying on implicit detection. - Scope the target to ios/, exclude RNViewShot.xcodeproj. - Remove the prefix header and unsafeFlags: the React headers already pull in Foundation/UIKit. - Keep iOS 15.0: 15.1 fails against RN's generated Autolinked aggregate. CI: new build-ios-spm job packs the library, installs it in a fresh RN 0.87.1 app switched to SwiftPM, builds Release for the simulator, and asserts Package.swift ships in the tarball, the autolinker uses it as self-managed, the privacy manifest is bundled, and getTurboModule: is compiled in. Ignore SwiftPM's .build/ and .swiftpm/ in git and npm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is focused, matches React Native’s SwiftPM contract, and its targeted CI job passes.
Review effort: Balanced
Findings: None
What changed in this PR
Adds SwiftPM support for React Native 0.87 autolinking while preserving CocoaPods behavior.
Changes:
- Adds a self-managed SwiftPM manifest with TurboModule and privacy-resource support.
- Adds an end-to-end SwiftPM iOS build check.
- Ignores SwiftPM build artifacts.
| File | Description |
|---|---|
Package.swift |
Defines the iOS SwiftPM package and dependencies. |
.github/workflows/ci.yml |
Tests packaging, autolinking, building, resources, and TurboModule symbols. |
.gitignore |
Excludes local SwiftPM artifacts. |
.npmignore |
Excludes SwiftPM artifacts from npm packages. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gre
marked this pull request as ready for review
October 7, 2026 12:59
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #722: keeps @serpixel's commit as-is and adds a follow-up commit on top.
Why
RN 0.87's SwiftPM autolinking hard-fails for any autolinked library without a
Package.swift. Reproduced on a fresh RN 0.87.1 app withreact-native-view-shot@6.1.0:CocoaPods users are unaffected; the podspec stays the source of truth there.
Follow-up changes on top of #722
RCT_NEW_ARCH_ENABLED. SwiftPM autolinking is New Architecture only, but nothing defined it, soRNViewShot.mmcompiled without its TurboModule code (getTurboModule:/NativeRNViewShotSpecabsent from the object file) and only worked through the legacy interop layer.AUTO-SCAFFOLDEDmarkers. With them,react-native spm scaffoldtreats the file as its own and regenerates it in consumers'node_moduleswhenever the cache slot changes. Without them, the autolinker reports it asSelf-managed.ios/PrivacyInfo.xcprivacyas a resource, matching the podspec'sresource_bundles(it was only picked up implicitly before).ios/, excludeRNViewShot.xcodeproj, and remove the prefix header andunsafeFlags(not needed).iOS 15.0:15.1fails against RN's generatedAutolinkedaggregate..build/and.swiftpm/in git and npm.Tests
New CI job,
Build iOS App (SwiftPM). It packs the library, installs it in a fresh RN 0.87.1 app switched to SwiftPM, builds Release for the simulator, and asserts that:Package.swiftships in the npm tarballgetTurboModule:is compiled inVerified locally as well: Debug and Release simulator builds of a fresh RN 0.87.1 SwiftPM app,
captureRefreturns a valid PNG at runtime, and the job steps were replayed from scratch.🤖 Generated with Claude Code