You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6da65e8
Browse filesBrowse the repository at this point in the historyBrowse files
Re-sync SwiftPM autolinking when a watched path appears (#58828)
Summary:
The SwiftPM build-time sync runs only when its stamp is older than one of the files it watches. A watched path that did not exist at the last sync was dropped from the watch list. So when that path appeared later, the sync did not run.
Examples:
- A plugin watches its precompiled-module folder. On a fresh clone, that folder does not exist yet, so later precompiles never trigger a sync.
- A dependency has no root `Package.swift` or `.react-native/` folder. When one appears later, for example after `npx react-native spm scaffold`, the dependency is detected differently, but the sync does not run.
This PR writes missing watch paths to a new file, `.spm-sync-watch-absent`. The stamp is stale when one of those paths now exists. The missing paths do not go to `.spm-sync-watch-paths`, because projects from older versions treat a missing path in that file as stale and would sync on every build. Those projects get this fix after running `npx react-native spm update` once.
The paths that can go to `.spm-sync-watch-absent`:
- a plugin `watchPaths` entry that does not exist yet
- the root `Package.swift` and `.react-native/` of each dependency, when they do not exist
The docs now tell plugins to list their precompiled-module folder in `watchPaths`, but only a folder that the Xcode build does not write to.
This PR does not watch `project.pbxproj`. Xcode rewrites that file on many edits in the IDE, so watching it would run a full sync after each edit. #58827 makes `.spm-injected.json` a watched file instead. Only `spm add` and `spm update` change that file.
This PR is independent of #58827. They can land in either order. Both change the generated sync check, so the second one to land needs a rebase.
## Changelog:
[IOS] [FIXED] - SwiftPM: the build-time sync now runs again when a watched path that did not exist at the last sync appears.
Pull Request resolved: #58828
Test Plan:
```
yarn jest --no-cache -i packages/react-native/scripts/spm/__tests__/
```
Result: 21 suites and 1010 tests pass.
- `generate-spm-autolinking-test.js`:
- A missing watch path goes to `.spm-sync-watch-absent` only. This test failed before the change.
- A dependency without a root `Package.swift` or `.react-native/` lists both paths as absent. The first version of this PR already did this, so the test passed at once. Removing the two paths from the code makes it fail.
- `project.pbxproj` is not watched. This test failed before the change.
- `generate-spm-xcodeproj-test.js`: runs the shipped bash check under `/bin/bash`. The stamp is stale only when a path listed as absent now exists.
Reviewed By: andrewdacenko
Differential Revision: D125206241
Pulled By: cipolleschi
fbshipit-source-id: 2cb530615941b15adb27f8fcc4699812538e9f3d
(cherry picked from commit c89f412)
(cherry picked from commit 8c5d387)
|`build/generated/ios/`|`add`, `update`, `sync`, `codegen`| Codegen output plus the SwiftPM codegen manifest (the `React-GeneratedCode` package). |
261
-
|`build/generated/autolinking/`|`add`, `update`, `sync`|`Package.swift`, `autolinking.json`, `packages/`, `libs/`, `headers/`, the `.spm-sync-stamp`, `.spm-sync-watch-paths`, and any `.spm-plugin-*.json`plugin manifests.|
261
+
|`build/generated/autolinking/`|`add`, `update`, `sync`|`Package.swift`, `autolinking.json`, `packages/`, `libs/`, `headers/`, the `.spm-sync-stamp`, `.spm-sync-watch-paths`, `.spm-sync-watch-absent`, and any `.spm-plugin-*.json` manifests. |
262
262
|`build/xcframeworks/`|`add`, `update`, `sync`, `download`| The `debug/` and `release/` flavor slots (symlinks into the cache), `ReactHeadersTarget/`, the headers-only xcframeworks, `Package.swift`, `flavored-frameworks.json`, `.artifact-stamp`. |
263
263
|`.build/`, `Package.resolved`| Xcode / SwiftPM | SwiftPM's own build directory and resolution file. Machine-specific. |
264
264
@@ -711,6 +711,11 @@ _existing_ set of generated packages current; they do not create the first one.
0 commit comments