Commit 9dda3a4
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>1 parent 92cd588 commit 9dda3a4
22 files changed
Lines changed: 2421 additions & 899 deletions
File tree
- packages
- react-native-test-library/apple
- react-native/scripts
- spm
- __docs__
- __tests__
- rn-tester
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
493 | 503 | | |
494 | | - | |
| 504 | + | |
495 | 505 | | |
496 | 506 | | |
497 | 507 | | |
498 | 508 | | |
499 | 509 | | |
500 | 510 | | |
501 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
502 | 514 | | |
503 | 515 | | |
504 | 516 | | |
| |||
Lines changed: 19 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
| 36 | + | |
38 | 37 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | | - | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
Lines changed: 104 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
336 | 337 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
341 | 342 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 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 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
355 | 422 | | |
356 | 423 | | |
357 | 424 | | |
358 | | - | |
359 | | - | |
| 425 | + | |
| 426 | + | |
360 | 427 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
367 | 433 | | |
368 | 434 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
377 | 438 | | |
378 | 439 | | |
379 | 440 | | |
| |||
385 | 446 | | |
386 | 447 | | |
387 | 448 | | |
388 | | - | |
| 449 | + | |
389 | 450 | | |
390 | 451 | | |
391 | | - | |
392 | | - | |
| 452 | + | |
| 453 | + | |
393 | 454 | | |
394 | 455 | | |
395 | 456 | | |
| |||
427 | 488 | | |
428 | 489 | | |
429 | 490 | | |
430 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
431 | 497 | | |
432 | 498 | | |
433 | 499 | | |
| |||
445 | 511 | | |
446 | 512 | | |
447 | 513 | | |
448 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
449 | 517 | | |
450 | 518 | | |
451 | 519 | | |
| |||
490 | 558 | | |
491 | 559 | | |
492 | 560 | | |
| 561 | + | |
493 | 562 | | |
494 | 563 | | |
495 | 564 | | |
| |||
596 | 665 | | |
597 | 666 | | |
598 | 667 | | |
599 | | - | |
| 668 | + | |
600 | 669 | | |
601 | 670 | | |
602 | 671 | | |
| |||
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
43 | | - | |
| 55 | + | |
44 | 56 | | |
45 | | - | |
| 57 | + | |
| 58 | + | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
50 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
51 | 76 | | |
52 | 77 | | |
53 | 78 | | |
54 | 79 | | |
55 | 80 | | |
56 | 81 | | |
57 | 82 | | |
58 | | - | |
59 | | - | |
| 83 | + | |
| 84 | + | |
60 | 85 | | |
61 | 86 | | |
62 | 87 | | |
63 | 88 | | |
64 | 89 | | |
65 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
66 | 93 | | |
67 | 94 | | |
68 | 95 | | |
69 | 96 | | |
70 | 97 | | |
71 | | - | |
| 98 | + | |
| 99 | + | |
72 | 100 | | |
73 | 101 | | |
74 | 102 | | |
75 | 103 | | |
76 | 104 | | |
77 | 105 | | |
78 | | - | |
| 106 | + | |
| 107 | + | |
79 | 108 | | |
80 | 109 | | |
81 | 110 | | |
| |||
0 commit comments