@@ -26,14 +26,14 @@ open MyApp-SPM.xcodeproj
2626```
2727
2828A future CLI integration (e.g., an ` --ios-build-system spm ` flag on
29- ` react-native init ` ) could run ` setup-apple- spm.js -- init` automatically as part
29+ ` react-native init ` ) could run ` react-native spm init` automatically as part
3030of project creation.
3131
3232### Existing project
3333
3434``` bash
3535cd MyApp/ios
36- node ../node_modules/ react-native/scripts/setup-apple- spm.js -- init
36+ react-native spm init
3737# CocoaPods setup continues to work — both can coexist
3838open MyApp-SPM.xcodeproj
3939```
@@ -118,7 +118,8 @@ goes read-only in December 2026.
118118
119119### Pipeline
120120
121- ` setup-apple-spm.js ` orchestrates five steps:
121+ ` react-native spm ` orchestrates five steps (the underlying script is
122+ ` scripts/setup-apple-spm.js ` ):
122123
123124| # | Step | Script | Output |
124125| ---| ------| --------| --------|
@@ -129,15 +130,15 @@ goes read-only in December 2026.
129130| 5 | Xcodeproj | ` spm/generate-spm-xcodeproj.js ` | ` AppName-SPM.xcodeproj ` |
130131| — | Sync (build-time) | ` spm/sync-spm-autolinking.js ` | Re-runs steps 1–4 when inputs change (downloads artifacts if missing) |
131132
132- When run with ` -- init` , the script also appends SPM-specific entries to the
133+ When run with the ` init ` action , the script also appends SPM-specific entries to the
133134project's ` .gitignore ` (e.g., ` autolinked/ ` , ` build/generated/ios/ ` ,
134135` build/xcframeworks/ ` , ` .build/ ` , ` Package.resolved ` ). Entries that already
135136exist are not duplicated. This ensures generated artifacts are not accidentally
136137committed.
137138
138139### Auto-sync build phase
139140
140- After initial setup, developers shouldn't need to re-run ` setup-apple- spm.js `
141+ After initial setup, developers shouldn't need to re-run ` react-native spm`
141142manually when dependencies change. The generated ` .xcodeproj ` includes a
142143** Sync SPM Autolinking** pre-build phase (ordered first, before VFS overlay)
143144that:
@@ -165,8 +166,8 @@ new version's cache directory.
165166The sync step is ** self-healing** : if xcframework artifacts are missing (e.g.,
166167the local cache at ` ~/Library/Caches/com.facebook.ReactNative/ ` was deleted,
167168or the project was freshly cloned), it automatically downloads them before
168- proceeding with autolinking and package generation. This means ` setup-apple- spm.js `
169- is only strictly required for initial project scaffolding (` -- init` ); subsequent
169+ proceeding with autolinking and package generation. This means ` react-native spm`
170+ is only strictly required for initial project scaffolding (` init ` ); subsequent
170171builds recover automatically.
171172
172173### Cleaning generated SPM state
@@ -178,17 +179,15 @@ Xcode provides no hook to run custom scripts during GUI clean actions.
178179To fully reset SPM state, run:
179180
180181``` bash
181- node setup-apple- spm.js -- clean
182+ react-native spm clean
182183```
183184
184185This removes ` build/xcframeworks/ ` , ` build/generated/ios/ ` , ` autolinked/ ` , and
185- ` .build/ ` , then re-runs the full setup (codegen, download, autolinking, package
186- generation). After it completes, open the ` .xcodeproj ` in Xcode and build.
187-
188- The ` --clean ` flag performs a full re-setup rather than just deleting files
189- because SPM package resolution is locked for the duration of a build — if only
190- stubs were left in place, Xcode would resolve stubs and never pick up the real
191- packages generated by the sync build phase.
186+ ` .build/ ` . Then run ` react-native spm update ` (or open the checked-in
187+ ` .xcodeproj ` and build) to regenerate state. SPM package resolution is locked
188+ for the duration of a build — if only stubs were left in place, Xcode would
189+ resolve stubs and never pick up the real packages generated by the sync build
190+ phase.
192191
193192### Stub packages for fresh clones
194193
@@ -241,16 +240,16 @@ AppName-SPM.xcodeproj
241240 └── build/generated/ios/ (codegen source path)
242241```
243242
244- The root ` Package.swift ` is generated once (` -- init` ) and committed. Developers
243+ The root ` Package.swift ` is generated once (` react-native spm init` ) and committed. Developers
245244can customize it — add dependencies, adjust settings, or add new targets.
246245Subsequent runs only regenerate the sub-packages (` autolinked/ ` and
247246` build/xcframeworks/ ` ).
248247
249248Both ` Package.swift ` and ` AppName-SPM.xcodeproj ` are generated once during
250- ` -- init` and committed. This is typically done by project scaffolding tools
251- (` react-native init ` , ` expo init ` ) rather than by developers manually. After
252- initial generation, these files are user-owned — subsequent ` setup-apple-spm.js `
253- runs (without ` --init ` ) only regenerate the sub-packages, not the root
249+ ` react-native spm init` and committed. This is typically done by project
250+ scaffolding tools (` react-native init ` , ` expo init ` ) rather than by developers
251+ manually. After initial generation, these files are user-owned — subsequent
252+ ` react-native spm update ` runs only regenerate the sub-packages, not the root
254253` Package.swift ` or ` .xcodeproj ` . Teammates can clone the repo and open Xcode
255254immediately — stub packages allow package resolution to succeed, and the
256255auto-sync build phase downloads artifacts and handles autolinking on the first
@@ -349,7 +348,7 @@ module.exports = {
349348};
350349```
351350
352- ** Planned (Phase 2):** When ` setup-apple- spm.js ` gains third-party library
351+ ** Planned (Phase 2):** When ` react-native spm` gains third-party library
353352support, it will:
3543531 . If ` spm.xcframework ` is declared, download the prebuilt binary (fast path).
3553542 . If the download fails or the ` --source ` flag is passed, fall back to
@@ -486,7 +485,7 @@ compilation support is a goal for specific use cases:
486485
487486The source compilation path would reuse the same SPM package structure but
488487replace binary xcframework targets with source targets. This is planned as a
489- ` --source ` flag to ` setup-apple- spm.js ` .
488+ ` --source ` flag to ` react-native spm` .
490489
491490### SPM build tool plugins
492491
@@ -542,7 +541,7 @@ required; libraries that don't provide them fall back to source compilation.
542541
543542### Migration path for existing apps
544543
545- 1 . Run ` setup-apple- spm.js -- init` in the ` ios/ ` directory.
544+ 1 . Run ` react-native spm init` in the ` ios/ ` directory.
5465452 . Commit the generated ` Package.swift ` and ` AppName-SPM.xcodeproj ` .
5475463 . Open the new ` .xcodeproj ` and build.
5485474 . Once validated, optionally remove CocoaPods files (` Podfile ` , ` Pods/ ` ,
@@ -559,7 +558,7 @@ Xcode build and re-runs the sync step automatically. This downloads the new
559558version's xcframeworks, regenerates the sub-packages, and updates autolinking.
560559No manual edits to ` Package.swift ` are needed — the root ` Package.swift ` only
561560references sub-packages by relative path, and those sub-packages are fully
562- regenerated each run. Developers can also run ` setup-apple- spm.js ` manually to
561+ regenerated each run. Developers can also run ` react-native spm` manually to
563562trigger the update before building.
564563
565564## How we teach this
@@ -576,10 +575,10 @@ trigger the update before building.
576575
577576### CLI discoverability
578577
579- - ` setup-apple- spm.js --help` should provide clear usage instructions and
578+ - ` react-native spm --help` should provide clear usage instructions and
580579 explain each step.
581- - Error messages should include actionable suggestions (e.g., "Run with --init
582- for first-time setup").
580+ - Error messages should include actionable suggestions (e.g., "Run
581+ ` react-native spm init ` for first-time setup").
583582- The auto-sync build phase should surface warnings in Xcode's issue navigator
584583 when autolinking state is stale.
585584
@@ -623,7 +622,7 @@ trigger the update before building.
623622 sources compile as an SPM target without producing a full release artifact.
624623 This would be useful for CI checks on pull requests.
625624
626- 5 . ** Hardening ` -- init` for existing projects.** Running ` -- init` on a project
625+ 5 . ** Hardening ` init ` for existing projects.** Running ` init ` on a project
627626 that already has ` Package.swift ` or ` .xcodeproj ` should detect existing
628627 files and avoid overwriting user modifications. The current ` .xcodeproj `
629628 generation uses a simple template-based approach; adopting a proper Xcode
0 commit comments