Repository navigation
Description
#1232 added SwiftPM support (shipped in 2.2.0). This tracks the gap that review surfaced, plus four smaller findings.
The gap
ci.yml validates native code by compiling the CocoaPods example app (pod-install + xcodebuild, NewArch and OldArch). Nothing compiles the SwiftPM package, so nothing exercises Package.swift, spm-headers/, or spm-support/.
spm-support/SwiftHeaderPin.swift was written to be that guard, but it cannot be one on its own:
- it catches renames, removals and type changes of the mirrored API, but not additions;
- nothing in this repo ever compiles it — under CocoaPods it is outside the podspec's
ios/**/*.{h,m,mm,swift}glob, and no CI job builds the SwiftPM target.
Concrete failure: add var imageColor: NSString? to FabricViewImplementationProtocol and set _view.imageColor in ios/NewArch/MenuView.mm. CI is green, because Xcode generates react_native_menu-Swift.h for the CocoaPods build. spm-headers/react_native_menu-Swift.h does not have the property, so every SwiftPM consumer fails with *"property 'imageColor' not found on object of type 'UIView '". The first person to find out is a downstream user.
Why there is no end-to-end build yet
A real swift build of this package is not possible at the currently pinned React Native:
Package.swiftresolves.package(path: "../../../../xcframeworks")and.package(path: "../../../ios"), which only exist inside React Native's SwiftPM autolinking layout (<app>/ios/build/generated/autolinking/libs/<pkg>);react-native@0.81.1innode_moduleshas no SwiftPM autolinking at all — no consumer of theswiftpmConfigkey feat(ios): add Swift Package Manager support #1232 added topackage.json, and no xcframeworks pipeline.
So end-to-end SwiftPM verification is effectively blocked behind #1238 (react-native-test-app 5) -> #1249 (React Native 0.88).
Findings from the review of #1232
- Header drift has no guard (above) — medium.
- The mirrored
@interfaces flatten their superclasses.FabricMenuViewImplementation : UIButton/FabricActionSheetView : UIViewrather thanMenuViewImplementation/ActionSheetView, and the pin's(UIButton & FabricViewImplementationProtocol).Typecheck accepts anyUIButtonsubclass, so the divergence is invisible to it. ObjC++ reaching a member declared on the shared base but not on the protocol would build under CocoaPods and fail under SwiftPM. Checked:MenuView.mmtoday reaches only protocol members and UIKit ones, so this is latent. The dropped@available(iOS 14.0, *)onFabricMenuViewImplementationis the same class of drift. -
sources: ["ios"]on the ObjC target discovers by extension over the wholeios/subtree with no directory whitelist, unlike the Swift target. Reproduced: with a strayios/build/Stray.mmpresent,swift package describereports it compiled intoReactNativeMenuObjC. A consumer using this as a path dependency with stale codegen or a legacy Xcode build location underios/gets those files compiled in. -
try!in the manifest (3 sites). A manifest that traps reports a Swift fatal error instead of a SwiftPM diagnostic. Note: I could not reproduce an actual trap — a dangling symlink underios/did not throw fromsubpathsOfDirectoryorresourceValueson Swift 6.0.2 — so this is hygiene against a latent hazard (an unreadable path, or a file removed between the listing and the stat), not a demonstrated bug. - The
__has_includefallback is an ordering assumption.ios/NewArch/MenuView.mmneeds<react_native_menu/react_native_menu-Swift.h>to be absent under SwiftPM so theelsebranch picks upspm-headers/react_native_menu-Swift.h. ButReactNativeMenuObjCdepends on thereact_native_menuSwift target, and SwiftPM does expose a Swift target's generated compatibility header to dependent C-family targets. Which header wins is-Iordering, not an invariant; a Swift/SwiftPM version bump could silently switchMenuView.mmonto the generated header, which per the file's own comment cannot compile there.
Plan
Now, without an SPM build: a spm CI job running mechanical checks on the manifest and the mirrored header, plus the three code fixes. See the PR linked below.
When RN 0.88 lands (#1249): add a job that actually resolves and compiles the package through RN's SwiftPM autolinking, which is what closes the first and last findings properly.
Activity