Commit ab6e590
committed
fix(spm): alias self-managed lib refs via libs/<Name> to avoid SPM identity collision
A community library that ships its `Package.swift` inside an `ios/` subdir
(common convention — e.g. @chrfalch/react-native-calculator/ios/Package.swift)
collides with our codegen package at build/generated/ios/Package.swift:
both have path basename "ios", which is what SPM uses to derive package
identity. SPM rejects with "Conflicting identity for ios". Worse, two libs
that both ship Package.swift in ios/ collide with each other regardless of
where our codegen lives.
The fix routes every self-managed dep through a uniquely-named symlink:
build/generated/autolinking/
Package.swift
libs/ # NEW
Calculator → <abs>/node_modules/@chrfalch/.../ios
ReactNativeSafeAreaContext → <abs>/node_modules/react-native-safe-area-context
packages/ # unchanged (wrapper synths, already unique)
The aggregator emits `.package(name: ..., path: "libs/<SwiftName>")` instead
of an absolute path. SPM derives identity from the symlink basename — the
Swift module name — which is guaranteed unique per autolinker construction.
`libs/` is wiped + repopulated on every autolinker run, so stale entries
for uninstalled deps don't linger.
Also reverts an aborted exploration that moved the codegen Package.swift to
build/generated/codegen/ — the lib-aliases approach is the better answer
because it solves lib-vs-lib collisions, not just codegen-vs-lib.1 parent 79ee3bc commit ab6e590
3 files changed
Lines changed: 62 additions & 5 deletions
File tree
- packages/react-native/scripts/spm
- __doc__
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| |||
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
313 | 339 | | |
314 | 340 | | |
315 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
180 | 198 | | |
181 | 199 | | |
182 | 200 | | |
| |||
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1180 | 1180 | | |
1181 | 1181 | | |
1182 | 1182 | | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1183 | 1189 | | |
1184 | 1190 | | |
| 1191 | + | |
| 1192 | + | |
1185 | 1193 | | |
1186 | 1194 | | |
1187 | 1195 | | |
| |||
1254 | 1262 | | |
1255 | 1263 | | |
1256 | 1264 | | |
1257 | | - | |
1258 | | - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1259 | 1272 | | |
1260 | 1273 | | |
1261 | | - | |
| 1274 | + | |
1262 | 1275 | | |
1263 | 1276 | | |
1264 | 1277 | | |
| |||
0 commit comments