Skip to content

feat(ios): add Swift Package Manager support - #74

Merged
floco-af merged 2 commits into
appandflow:mainfrom
chrfalch:spm-support
Nov 13, 2026
Merged

floco-af merged 2 commits into
appandflow:mainfrom
chrfalch:spm-support

Conversation

@chrfalch

Copy link
Copy Markdown
Contributor

Summary

React Native 0.88 can build iOS libraries with Swift Package Manager (SwiftPM) instead of CocoaPods. react-native-ease has no Package.swift, so apps that use SwiftPM cannot use it.

This PR adds SwiftPM support. CocoaPods users see no change, and no source file changes.

  1. Package.swift: the manifest that React Native's SwiftPM autolinking uses. It builds the ios/ folder and defines RCT_NEW_ARCH_ENABLED=1, because CocoaPods gets that define from install_modules_dependencies.
  2. spm-headers/RCTFabricComponentsPlugins.h: a one-line header that re-exports <React/RCTFabricComponentsPlugins.h>. ios/EaseView.mm imports it with quotes. CocoaPods finds it through its header search paths, but SwiftPM does not.
  3. package.json: the Swift package name (swiftpmConfig.name, Ease, the same as the podspec) and the new files in files.

Test Plan

  • New React Native 0.88.1 app, set up for SwiftPM with npx react-native spm add --deintegrate, with react-native-ease from this branch.
  • Without this change, spm add fails: Package.swift is missing for library "react-native-ease".
  • xcodebuild Debug and Release, iOS simulator: both BUILD SUCCEEDED.
  • Release build, without Metro: the app renders an EaseView with a rotated colored box. The native view renders, not an "Unimplemented component" placeholder.
  • Lint and the Jest tests pass.
  • Not covered: tvOS. The podspec lists tvOS; this manifest is iOS only.

@vercel

vercel Bot commented Nov 12, 2026

Copy link
Copy Markdown

@chrfalch is attempting to deploy a commit to the appandflow Team on Vercel.

A member of the Team first needs to authorize it.

@floco-af floco-af 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.

Thanks @chrfalch, this is a clean, contained change. CocoaPods users are untouched (no source changes), and swiftpmConfig.name matches the podspec name.

What I checked (static review, no native build on my side):

  • Compared Package.swift with what React Native 0.88.1's react-native spm scaffold emits (scripts/spm/scaffold-package-swift.js). Tools version, .iOS("15.1"), cxxLanguageStandard: .cxx20, the four header products, path: "." and the relative ../../../../xcframeworks / ../../../ios paths (resolved from build/generated/autolinking/libs/Ease) all line up.
  • files in package.json includes Package.swift and spm-headers, and ios/ and Ease.podspec were already shipped. unusedRootEntries excludes everything else at the package root.
  • ios/EaseView.mm only imports RCTFabricComponentsPlugins.h with quotes, so the shim header is what is needed. No other quoted imports need handling.

Notes / questions (none are blockers):

  1. The manifest hardcodes the local xcframeworks path (../../../../xcframeworks). RN's scaffold also has a "remote" mode that depends on a .package(url: ..., exact: ...) package instead. If an app uses that mode, this hand-written manifest will not resolve. Is local mode the only supported setup in 0.88, or should this be called out in the docs?
  2. tvOS: the podspec lists it but this manifest is iOS only (as the PR says). Worth a line in the README, or a follow-up.
  3. DEBUG/NDEBUG are set in cxxSettings only. That works for .mm, but add them to cSettings too if a plain .m/.c file is ever added under ios/.
  4. A short README note on SwiftPM usage (npx react-native spm add) would help. Also, the CI doesn't build the SwiftPM path, so it can regress silently.

Validation: I could not run the SwiftPM build myself, so I'm relying on your reported Debug/Release builds on RN 0.88.1 and the render check. The only check on the PR is Vercel, which is failing because it needs team authorization and is unrelated to the change.

@chrfalch

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review.

  1. Remote mode: React Native does not support it yet, so local mode is the only setup. I will update the manifest when remote mode ships.
  2. tvOS: the README now says that the SwiftPM setup supports iOS only, and that tvOS needs CocoaPods.
  3. DEBUG/NDEBUG: all sources under ios/ are .mm today, but cSettings now has the same defines, so a future .m file builds the same way.
  4. README: added a short SwiftPM section under Installation. A CI job for the SwiftPM build can come in a later PR.

Changes are in eb0a9df.

@floco-af floco-af 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.

Thanks @chrfalch. I checked eb0a9df against the earlier notes: cSettings now carries the same DEBUG/NDEBUG defines as cxxSettings, and the README has a SwiftPM section that states iOS only and points tvOS users to CocoaPods. The diff is only those two files, and it matches your description. Remote mode and CI coverage are fine as follow-ups. Still no native build on my side (no Xcode on this host), so the Debug/Release builds you reported remain the validation. Nothing further from me; the rest is up to the maintainers.

@floco-af
floco-af merged commit 6a5f1a8 into appandflow:main Nov 13, 2026
6 of 7 checks passed
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.

2 participants