Commit 841e98e
feat(spm): scaffold cross-package sibling deps (reanimated → worklets)
A scaffolded library that depends on another autolinked library — reanimated
`#include <worklets/...>` from react-native-worklets — needs its Package.swift
to (a) declare that dependency and (b) have the dependency expose its namespace.
Neither happened, so the build failed with `'worklets/Compat/StableApi.h' file
not found`.
Three gaps fixed:
1. Pod-style dependency names. reanimated's podspec declares `s.dependency
"RNWorklets"` — a pod name the `react-native-*` sibling heuristic can't
recognize. scaffoldAll now builds a podspec-name → npm-name index (from each
autolinked dep's `.podspec` basename) and passes it to
translatePodspecToSpmTarget, which maps `RNWorklets` → react-native-worklets
and wires it as a sibling .package/.product.
2. Namespace exposure. SPM propagates a target's publicHeadersPath to dependent
packages as a search path. Derive publicHeadersPath from the
header_mappings_dir namespace root (preferring the cross-platform Common dir),
so worklets exposes `Common/cpp` → reanimated resolves `<worklets/...>`.
Falls back to the old first-prefix inference when no header_mappings_dir.
3. Sibling path. The autolinker references scaffolded deps via a
`libs/<SwiftName>` symlink and SPM resolves relative package paths against
that location, so a sibling is at `../<SwiftName>` — not `../<npm-name>`
(which resolved to a non-existent `libs/<npm-name>` and failed package
resolution). Latent bug, first exercised by a real scaffolded sibling.
- spm-types.js: `podspecPath` on AutolinkingIosPlatform.
- SCAFFOLDER_VERSION 9 → 11 (output changed → regenerate existing scaffolds).
- Tests: pod-name→sibling mapping, self-wire guard, publicHeadersPath from
header_mappings_dir, and the corrected sibling path.
Verified on a real app: re-scaffolding react-native-reanimated auto-emits the
worklets .package/.product + worklets publicHeadersPath "Common/cpp"; the build
now resolves packages and compiles past `<worklets/...>`, advancing to the
Hermes-header layer (`hermes/hermes.h`, tracked separately) and a worklets
version-macro define gap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent edcb7a4 commit 841e98e
3 files changed
Lines changed: 131 additions & 18 deletions
File tree
- packages/react-native/scripts/spm
- __tests__
Lines changed: 53 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
126 | 174 | | |
127 | 175 | | |
128 | 176 | | |
| |||
390 | 438 | | |
391 | 439 | | |
392 | 440 | | |
393 | | - | |
| 441 | + | |
394 | 442 | | |
395 | 443 | | |
396 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
397 | 448 | | |
398 | | - | |
| 449 | + | |
399 | 450 | | |
400 | 451 | | |
401 | 452 | | |
| |||
Lines changed: 77 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| |||
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
133 | 145 | | |
134 | 146 | | |
135 | 147 | | |
| |||
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
| 225 | + | |
213 | 226 | | |
214 | 227 | | |
215 | 228 | | |
| |||
218 | 231 | | |
219 | 232 | | |
220 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
221 | 242 | | |
222 | 243 | | |
223 | 244 | | |
| |||
264 | 285 | | |
265 | 286 | | |
266 | 287 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
276 | 315 | | |
277 | 316 | | |
278 | 317 | | |
| |||
415 | 454 | | |
416 | 455 | | |
417 | 456 | | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
422 | 462 | | |
423 | | - | |
| 463 | + | |
424 | 464 | | |
425 | 465 | | |
426 | 466 | | |
| |||
508 | 548 | | |
509 | 549 | | |
510 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
511 | 554 | | |
512 | 555 | | |
513 | 556 | | |
| |||
658 | 701 | | |
659 | 702 | | |
660 | 703 | | |
661 | | - | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
662 | 709 | | |
663 | 710 | | |
664 | 711 | | |
| |||
799 | 846 | | |
800 | 847 | | |
801 | 848 | | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
802 | 862 | | |
803 | 863 | | |
804 | 864 | | |
805 | 865 | | |
806 | 866 | | |
807 | 867 | | |
808 | 868 | | |
| 869 | + | |
809 | 870 | | |
810 | 871 | | |
811 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
0 commit comments