Skip to content

feat: SPM compatibility - #779

Open
hejsztynx wants to merge 5 commits into
@kacperzolkiewski/upgrade-examplefrom
@ksienkiewicz/feat-spm-compatibility
Open

feat: SPM compatibility#779
hejsztynx wants to merge 5 commits into
@kacperzolkiewski/upgrade-examplefrom
@ksienkiewicz/feat-spm-compatibility

Conversation

@hejsztynx

@hejsztynx hejsztynx commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Mainly, it was needed to change the iOS imports structure, as SPM and CocoaPods have different preferences.

Every change in the apps/example is just for testing purposes and will not be committed in the merge. The react-native-image-picker functionality 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-html release into a fresh RN 0.87 bare-bone example app and applied the ios changes - it works there as well.

Test Plan

Run the example app with SPM

In the apps/example directory:

  1. first build the app normally with CocoaPods, with yarn ios, verify it works
  2. in react-native-config.js set automaticPodsInstallation to false
  3. remove the react-native-image-picker dependency from package.json and reinstall dependencies
  4. run npx react-native spm scaffold, Package.swift should not be changed by that
  5. in the root Package.swift add "apps" and "docs" to the exclude list. 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)
  6. we run npx react-native spm --deintegrate to remove CocoaPods from this app
  7. we can finally run the build with yarn ios

More info: RN blog post

Compatibility

OS Implemented
iOS
Android
Web

Copilot AI lite review requested due to automatic review settings August 19, 2026 10:27
mediaType: 'photo',
selectionLimit: 1,
});
const response: any = undefined;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Stripped react-native-image-picker functionalities for testing purposes only. This will be removed before merging

Copilot AI left a comment

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.

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.swift and 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.

Comment thread apps/example/src/hooks/useEditorState.ts
Comment thread Package.swift
Comment thread react-native-spm-prefix.h Outdated
@hejsztynx
hejsztynx marked this pull request as draft August 19, 2026 10:33
@hejsztynx
hejsztynx force-pushed the @ksienkiewicz/feat-spm-compatibility branch from e07a47d to 0470f9b Compare August 19, 2026 12:18
@hejsztynx
hejsztynx marked this pull request as ready for review August 19, 2026 12:22

@szydlovsky szydlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, looks and works good (tested both cases).

Comment thread Package.swift
@hejsztynx

Copy link
Copy Markdown
Collaborator Author

Marking this PR as draft, as it's worth adding SPM builds on the CI

@hejsztynx
hejsztynx marked this pull request as draft August 27, 2026 15:25
@hejsztynx

Copy link
Copy Markdown
Collaborator Author

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

@hejsztynx
hejsztynx force-pushed the @ksienkiewicz/feat-spm-compatibility branch from 083f84a to a953992 Compare August 28, 2026 10:07
@hejsztynx
hejsztynx marked this pull request as ready for review August 28, 2026 10:24
Copilot AI review requested due to automatic review settings August 28, 2026 10:24

Copilot AI left a comment

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.

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 (response is always undefined), 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];

Comment thread Package.swift
Copilot AI review requested due to automatic review settings August 28, 2026 13:55
@hejsztynx
hejsztynx force-pushed the @ksienkiewicz/feat-spm-compatibility branch from a953992 to 614e35e Compare August 28, 2026 13:55

Copilot AI left a comment

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.

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 response to undefined, so the “select image from library” flow will never work. If react-native-image-picker must 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;

Comment thread docs/docs/misc/compatibility.mdx
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.

3 participants