Repository navigation
feat(ios): add Swift Package Manager support - #74
Conversation
|
@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
left a comment
There was a problem hiding this comment.
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.swiftwith what React Native 0.88.1'sreact-native spm scaffoldemits (scripts/spm/scaffold-package-swift.js). Tools version,.iOS("15.1"),cxxLanguageStandard: .cxx20, the four header products,path: "."and the relative../../../../xcframeworks/../../../iospaths (resolved frombuild/generated/autolinking/libs/Ease) all line up. filesinpackage.jsonincludesPackage.swiftandspm-headers, andios/andEase.podspecwere already shipped.unusedRootEntriesexcludes everything else at the package root.ios/EaseView.mmonly importsRCTFabricComponentsPlugins.hwith quotes, so the shim header is what is needed. No other quoted imports need handling.
Notes / questions (none are blockers):
- 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? - 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.
DEBUG/NDEBUGare set incxxSettingsonly. That works for.mm, but add them tocSettingstoo if a plain.m/.cfile is ever added underios/.- 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.
|
Thanks for the careful review.
Changes are in eb0a9df. |
floco-af
left a comment
There was a problem hiding this comment.
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.
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.
Package.swift: the manifest that React Native's SwiftPM autolinking uses. It builds theios/folder and definesRCT_NEW_ARCH_ENABLED=1, because CocoaPods gets that define frominstall_modules_dependencies.spm-headers/RCTFabricComponentsPlugins.h: a one-line header that re-exports<React/RCTFabricComponentsPlugins.h>.ios/EaseView.mmimports it with quotes. CocoaPods finds it through its header search paths, but SwiftPM does not.package.json: the Swift package name (swiftpmConfig.name,Ease, the same as the podspec) and the new files infiles.Test Plan
npx react-native spm add --deintegrate, with react-native-ease from this branch.spm addfails:Package.swift is missing for library "react-native-ease".xcodebuildDebug and Release, iOS simulator: both BUILD SUCCEEDED.EaseViewwith a rotated colored box. The native view renders, not an "Unimplemented component" placeholder.