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
{{ message }}
Repository navigation
Commit 0d7aeb7
Browse filesBrowse the repository at this point in the historyBrowse files
Document how a library's SPM Swift name is derived and overridden
The derivation rule, the `spm.name` override and the names React Native
reserves were only discoverable from the autolinker's source or from the error a
collision produces. Write them down where a library author looks: the scoped
package case that surprises people (`@scope/react-native` derives `ReactNative`,
and gets its scope back as `ScopeReactNative`), the two reasons to set
`spm.name` and its charset, the reserved names in one table, what happens when
two libraries derive the same name — who moves, who stays, and when the build
fails anyway — and the npm `files` requirement that makes the override reach
consumers at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|`name`| The target's name and its header prefix. A valid Swift identifier, not [reserved](#names-react-native-reserves), and not already taken by another module or an autolinked library. |
368
+
|`path`| The module's directory, relative to the app root. |
369
+
|`exclude`| Paths inside `path` to keep out of the target, like a podspec's `exclude_files`. Name a directory with a trailing `/`. |
370
+
|`sources`| Glob allowlist replacing automatic discovery, like a podspec's `source_files`. Without it, every `.h/.m/.mm/.c/.cpp/.swift` file under `path` is compiled, minus `exclude` and the directories the autolinker always skips (`android/`, `test/`, `tests/`, `__tests__/`, `__mocks__/`, `jest/`, `node_modules/`). |
371
+
372
+
Names must be unique because wrapper directories are keyed by name: two entries
373
+
resolving to one name — or an entry matching an autolinked library — would share
374
+
a directory, and the losing module would silently not be built. So a clash fails
375
+
the build with a rename instruction instead.
376
+
377
+
### This is an app surface
378
+
379
+
`spm.modules` is read from the app's own `react-native.config.js` only — entries
380
+
in a dependency's config are ignored, so a library cannot declare its native
381
+
code this way. A library ships its own `Package.swift`, or has one scaffolded
382
+
from its podspec — see
383
+
[community packages without a `Package.swift`](#community-packages-without-a-packageswift).
384
+
385
+
### Limits
386
+
387
+
-**One target.**`spm add` attaches the `Autolinked` aggregate to a single app
388
+
target (`--productName` picks it when the project has several), and modules
389
+
reach only that target. Known gap: rn-tester's test targets
390
+
(`RNTesterUnitTests`, `RNTesterIntegrationTests`) get their own pods under
391
+
CocoaPods, and `spm.modules` has no equivalent for them yet.
392
+
-**One language per module.** SwiftPM cannot mix Swift and Objective-C/C++ in
393
+
one target; a module that does fails the build. Split it per language, or ship
394
+
a hand-written `Package.swift` with a target for each.
395
+
-**No third-party Swift packages.** Add those in Xcode (File → Add Package
396
+
Dependencies…); React Native does not need to know. Pods you keep are still
0 commit comments