Commit fed41f8
feat(spm): scaffold header search paths from header_mappings_dir
Community libs that lay headers out under a namespaced subdir and consume them
via that namespace — reanimated/worklets ship `apple/reanimated/...` and
`Common/cpp/reanimated/...` and `#import <reanimated/...>` — declare it with a
per-subspec `header_mappings_dir`. CocoaPods makes those includes resolve by
copying the headers into `Pods/Headers` preserving structure relative to the
mappings dir; SPM has no equivalent copy step, so `<reanimated/apple/sensor/X.h>`
(physically at `apple/reanimated/apple/sensor/X.h`) was unresolved and the
scaffolded target failed with "file not found".
Fix: for every subspec's `header_mappings_dir`, add `dirname(mappings_dir)` as a
header search path on the scaffolded target. That exposes the
`<basename(mappings_dir)>/...` namespace from the physical source tree (e.g.
`-I apple` makes `<reanimated/apple/sensor/X.h>` resolve). The podspec's literal
HEADER_SEARCH_PATHS never list these because CocoaPods relies on the copy step.
- read-podspec.js: collect ALL subspecs' header_mappings_dir into
`headerMappingsDirs` (the existing singular `headerMappingsDir` is the merged
value; the array is the union).
- scaffold-package-swift.js: add `dirname()` of each (skipping "." and
non-existent dirs); bump SCAFFOLDER_VERSION 8 → 9 so already-scaffolded deps
regenerate with the new search paths.
- spm-types.js: `headerMappingsDirs: Array<string>` on PodspecModel.
- Tests for the reanimated/worklets pattern, the non-existent-dir skip, and the
single-segment ("." → skip) case.
Verified: re-scaffolding react-native-reanimated now auto-emits
`.headerSearchPath("Common/cpp")` + `.headerSearchPath("apple")`, and its own
`<reanimated/...>` headers resolve (build advances past them). 323 spm tests
pass. NOTE: a full reanimated build still needs the reanimated→worklets
cross-package dep and Hermes public headers in the artifacts (separate work).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent c6c48ea commit fed41f8
4 files changed
Lines changed: 88 additions & 1 deletion
File tree
- packages/react-native/scripts/spm
- __tests__
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
86 | 141 | | |
87 | 142 | | |
88 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
474 | 481 | | |
475 | 482 | | |
476 | 483 | | |
| |||
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
176 | 197 | | |
177 | 198 | | |
178 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
349 | 353 | | |
350 | 354 | | |
351 | 355 | | |
| |||
0 commit comments