feat: SPM compatibility - #779
Conversation
| mediaType: 'photo', | ||
| selectionLimit: 1, | ||
| }); | ||
| const response: any = undefined; |
There was a problem hiding this comment.
Stripped react-native-image-picker functionalities for testing purposes only. This will be removed before merging
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds Swift Package Manager (SPM) scaffolding support and updates iOS headers/import paths to build cleanly under SPM while keeping CocoaPods compatibility.
Changes:
- Added
Package.swiftand an SPM “prefix header” to emulate CocoaPods’ prefix-header behavior. - Updated iOS header imports to use local and codegen header paths (vs module-style includes).
- Adjusted podspec header search paths to support the new include strategy.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| react-native-spm-prefix.h | Adds a forced-include prefix header for SPM builds (Foundation/UIKit). |
| package.json | Publishes Package.swift and the prefix header in the npm package. |
| ios/internals/EnrichedTextViewShadowNode.h | Switches to local + codegen include paths for SPM compatibility. |
| ios/internals/EnrichedTextInputViewShadowNode.h | Switches to local + codegen include paths for SPM compatibility. |
| ios/internals/EnrichedTextInputViewComponentDescriptor.h | Updates includes to local + codegen paths. |
| ios/internals/EnrichedTextComponentDescriptor.h | Updates includes to local + codegen paths. |
| ios/interfaces/LinkRegexConfig.h | Updates Props include to the generated codegen path. |
| ios/EnrichedTextView.mm | Updates imports to local/component descriptor + generated codegen headers. |
| ios/EnrichedTextInputView.mm | Updates imports to local/component descriptor + generated codegen headers. |
| apps/example/src/hooks/useEditorState.ts | Modifies image-picker logic (currently stubbed). |
| ReactNativeEnrichedHtml.podspec | Expands HEADER_SEARCH_PATHS to include the repo root for quoted includes. |
| Package.swift | Introduces an SPM package definition for the library target. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e07a47d to
0470f9b
Compare
szydlovsky
left a comment
There was a problem hiding this comment.
Overall, looks and works good (tested both cases).
|
Marking this PR as draft, as it's worth adding SPM builds on the CI |
After some discussion, that requires a lot of tampering in the repo and maybe it's not doing for now, as SPM is still experimental |
083f84a to
a953992
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
apps/example/src/hooks/useEditorState.ts:218
- This change turns local image selection into a silent no-op (
responseis alwaysundefined), so the example UI will never insert a picked image. If the example modifications are truly not intended to ship (per PR description), they should be removed from the PR; otherwise make the behavior explicitly disabled (e.g., warn + return) to avoid misleading dead code.
const response: any = undefined;
if (response?.assets?.[0] === undefined) return;
const asset = response.assets[0];
a953992 to
614e35e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
apps/example/src/hooks/useEditorState.ts:216
- The example app currently hard-disables local image picking by setting
responsetoundefined, so the “select image from library” flow will never work. Ifreact-native-image-pickermust be removed for SPM testing, it’s better to make the dependency optional at runtime and provide a clear fallback (or remove/disable the UI entry point) so the example remains functional when the dependency is present.
const response: any = undefined;
if (response?.assets?.[0] === undefined) return;
Summary
Mainly, it was needed to change the iOS imports structure, as SPM and CocoaPods have different preferences.
Every change in the
apps/exampleis just for testing purposes and will not be committed in the merge. Thereact-native-image-pickerfunctionality got stripped, as it doesn't support SPM.SPM works with the internal example app. I also simulated a non-local environment by installing the recently published
react-native-enriched-htmlrelease into a fresh RN 0.87 bare-bone example app and applied theioschanges - it works there as well.Test Plan
Run the example app with SPM
In the
apps/exampledirectory:yarn ios, verify it worksreact-native-config.jssetautomaticPodsInstallationtofalsereact-native-image-pickerdependency frompackage.jsonand reinstall dependenciesnpx react-native spm scaffold,Package.swiftshould not be changed by thatPackage.swiftadd"apps"and"docs"to theexcludelist. This is needed as we physically have example apps within the library source code and don't want to try to resolve source there to compile; otherwise SPM would get confused (duplicated resources, infinite symlink loops)npx react-native spm --deintegrateto remove CocoaPods from this appyarn iosMore info: RN blog post
Compatibility