Commit cf6a627
Derive an SPM library's Swift name from its podspec, not its npm name
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.
The podspec already carries the truth and is already parsed, so resolution now
reads it: spm.name, then podspec header_dir, then the podspec name, then
toSwiftName(npm name) for a library that ships no podspec. A prefix Swift cannot
spell is normalized to the identifier SwiftPM would compile it as, with a
warning, rather than silently reverting to the npm name.
A reserved name or two deps landing on one name is a hard error naming spm.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 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.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9682967 commit cf6a627
12 files changed
Lines changed: 924 additions & 537 deletions
File tree
- packages/react-native/scripts/spm
- __docs__
- __tests__
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
355 | 404 | | |
356 | 405 | | |
357 | 406 | | |
| |||
490 | 539 | | |
491 | 540 | | |
492 | 541 | | |
| 542 | + | |
493 | 543 | | |
494 | 544 | | |
495 | 545 | | |
| |||
0 commit comments