You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Derive an SPM library's Swift name from its podspec, and give SwiftPM config a home
An autolinked library's SwiftPM target name is also its header import prefix,
so deriving it from the npm package name was wrong for most of the ecosystem
(react-native-svg publishes RNSVG, not ReactNativeSvg) and wrong silently — no
error, just headers nobody can import under the expected name.
A package's SwiftPM settings now live in `swiftpmConfig` in its package.json,
following codegenConfig's conventions: `name`, `dependencies`,
`autolinkingPlugin` and `scaffold` for a library, `modules` and `denyPlugins`
for an app. The `spm` block in react-native.config.js is deprecated — still
read, so nothing breaks, but it warns once per file and package.json wins field
by field.
A name resolves from `swiftpmConfig.name`, then the deprecated `spm.name`, then
the podspec's `header_dir` or name, then the npm name. The podspec is thereby
transitional rather than permanent: `spm scaffold` records the name it derived
as `swiftpmConfig.name` in the library's package.json, so the next run needs no
podspec to name it. It never overwrites a name the library already declares,
never records a name guessed from the npm name, and reports what it did.
A prefix Swift cannot spell is normalized to the identifier SwiftPM would
compile it as, with a warning. A reserved name or two deps landing on one name
is a hard error naming swiftpmConfig.name as the fix; the scope-borrowing that
auto-corrected collisions is removed, since a name the build invents is a name
no #import can predict. Collision checks key on SwiftPM's c99 name, so
react-native-svg and react_native_svg no longer pass and then compile as one
module.
Name resolution reads the two podspec fields it needs with the regex parser, so
it adds no `pod ipc spec` spawn, and the full read is memoized on the resolved
path so one run reads a podspec once across name resolution, header search paths
and scaffolding.
rn-tester and the Apple test library move to the new location.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|`Package.swift is missing for library "<name>"` (exit 2) | The dep ships no SwiftPM support. `npx react-native spm scaffold`, then re-run setup; persist with `patch-package`. See [Community packages without a Package.swift](#community-packages-without-a-packageswift)|
571
+
|`SPM Swift name collision`| Two libraries resolved to one Swift name, or one took a name React Native reserves. Set `swiftpmConfig.name` in the library's package.json — see [Library names](#library-names)|
0 commit comments