From be44c42d3e056071bd57781718850fed7fe8f793 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 10:33:49 -0600 Subject: [PATCH 01/53] docs: add the alpha.8 fail-early design --- .../plans/2026-11-06-alpha-8-fail-early.md | 65 ++ .../2026-11-06-alpha-8-fail-early-design.md | 795 ++++++++++++++++++ 2 files changed, 860 insertions(+) create mode 100644 docs/design/plans/2026-11-06-alpha-8-fail-early.md create mode 100644 docs/design/specs/2026-11-06-alpha-8-fail-early-design.md diff --git a/docs/design/plans/2026-11-06-alpha-8-fail-early.md b/docs/design/plans/2026-11-06-alpha-8-fail-early.md new file mode 100644 index 0000000..c0bbf5f --- /dev/null +++ b/docs/design/plans/2026-11-06-alpha-8-fail-early.md @@ -0,0 +1,65 @@ +# Release 0.1.0-alpha.8, fail early: plan skeleton + +Status: skeleton, 2026-11-06. It lists the task groups of the +[alpha.8 design](../specs/2026-11-06-alpha-8-fail-early-design.md) and the failure-walk rows each group owns. The +tasks, their tests and the execution order are written after the owner approves the design and rules on its open +questions; the owner's calls among these rows may move a row to another group or to alpha.9. + +## A. The podspec reader runs real Ruby (design A, scaffolder fix 29) + +Rows 1–28: the Ruby probe and its lines in `build`, `doctor` and `setup` (1, 2), the fixed environment (3), the loud +failures and the escape (4–8), `node` calls (9), the autolinking callers (10), `ENV` names (11), `spm_dependency` (12), +the `pod` path (13), Podfile globals (14), identity fields (15), project state (16), one process per podspec (17), +side effects (18), output (19), the `ios` merge in `flattenSubspecs` (20), build keys the scaffold does not apply (21), +subspecs (22), the reader in the scaffold marker (23), cost (24), the revision bump to 8 (25), shipping in the vendored +copy and both 0.88 patches (26), the reduced reader's `⚠` (27), model fields (28). + +## B. The app target fails in seconds (design B) + +Rows 30–55: B1 pass 1 in `doctor --project` and at `build` start (30–32), conditions, text forms, `@import` and +generated headers (33–36), pass 2's certainty rule (37), B1 without a toolchain (38), B2's command lines and their +golden against Swift Build's response files (39, 40), toolchain and module cache (41, 42), Swift and clang modules and +`App-Swift.h` (43–45), the app target's shapes: xcconfig, synchronized folders, per-file flags (46–48), time, error +location, warnings, beyond syntax (49–52), the Expo bridging header (53), manifest planning (54), the anti-goal run on +every reference app (55). + +## C. Scaffold fidelity (design C) + +Rows 56–70: the glob comparison for fresh and persisted scaffolds, the scaffolder's exclusion list, glob semantics, +headers, scope and the reduced reader (56–62), the class check per target object (63–66), the class check in the packed +app (67–69), both in `install` (70). + +## D. Reliability: logs, build stamp, USB retry (design D) + +Rows 71–79: logs on disk per command (open, clean, children, signals, `start`, concurrency, rotation, privacy, commands +outside a project). + +Rows 81–92: the build stamp (packing and `Lookup`, gated by the device spike first; mismatch; existing Lookup errors; +the USB Lookup; the stale `.ipa`; repeat installs; per-build changes; the visible key; `run`; states from alpha.7). + +Rows 93–98: the USB retry after the four Wi‑Fi tries. + +## E. The guide (design E) + +Rows 99–103: `AGENTS.md` in the package, `rn-xtool agent-guide`, the guide test, the user's files, the user docs +shipped in the package. + +## F. Guards on rn-xtool (design F) + +Rows 104–108 and 29: the permanent reader sweep in CI, with the TypeScript readers' disagreements listed (29, deferred +to alpha.9 for the fix). + +Rows 109–111: the Objective-C target in the daily drift watch. + +Rows 112–115: the mention check (script, test, `pull_request` workflow, RELEASING steps) and the fifteen user-form +mentions fixed. + +## G. Follow-ups (design G) + +Row 80: the `-fmodules-cache-path` filter (built on group D's tee). + +Row 116: doctor's "N to download". + +Row 117: the `RCTDependencyProvider` include path on 0.85. + +Row 118: the DevTools `chrome-sandbox` section in troubleshooting. diff --git a/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md new file mode 100644 index 0000000..ec5b670 --- /dev/null +++ b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md @@ -0,0 +1,795 @@ +# Release 0.1.0-alpha.8: fail early, never silently (design) + +Status: design, 2026-11-06, draft for Willy's approval. It follows the real-app trial of 2026-11-05/06: a production +bare React Native 0.85.0 app with an Objective-C app target and 20 libraries, built, installed and launched with +0.1.0-alpha.7 after seven fixes. The decisions below were taken with the owner on 2026-11-06 and are recorded, not +reopened. The trial's ledger is kept outside the repo's tracked files; what this design rests on is restated here with +its sources. Nothing that identifies the app is part of this document. + +## Intent + +The trial found seven failures. Each one was fixed, and the app now runs on the iPhone. How they showed up is the +problem this release addresses: + +| # | Failure | How it showed | What would have caught it | +|---|---|---|---| +| F1 | SwiftPM refused the App library: the Objective-C `main.m` (the pre-0.77 template) makes the App target an executable target | `xtool-build` stopped in SwiftPM's planning, after `rn-spm` and `frameworks` | fixed in alpha.7 (`main.` compiled as `AppMain.`, `main.swift` refused early); B2's manifest sub-step generalises it (row 54) | +| F2 | `'AppDelegate.h' file not found` compiling `AppMain.m`: the app's headers sit at the root of the Xcode group tree | compile error inside `xtool-build` | B1, in `doctor --project` and seconds after `build` starts | +| F3 | `'RCTAppDelegate.h' file not found`: the App target saw only the root of React Native's header tree | compile error inside `xtool-build` | B1 pass 2 and B2, before `xtool-build` | +| F4 | C++20 errors in React Native's `hash_combine.h`: the app's Objective-C++ compiled without `-std=` | compile error inside `xtool-build` | B2 | +| F5 | "use of `@import` when modules are disabled" in a pod-header forwarder included by the app's `.mm` | compile error inside `xtool-build` | B2 (it compiles `.mm` with `-fmodules -fno-cxx-modules`, as Swift Build does) | +| F6 | react-native-screens 4.24.0 built without any of `ios/`: the podspec reader read its Ruby locals in part | **a green build**; the app aborted at start (`+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents]`, a nil class) | A (real Ruby reads the podspec as CocoaPods does), C, and alpha.7's codegen class guard | +| F7 | after `install --network`, the iPhone still ran the previous binary | **a green install** (as far as the trial can tell); the old app crashed as before | D2 (a per-build stamp checked on the iPhone) and D3 | + +Five failures (F1–F5) were in the app target itself: its manifest, its include paths, its flags. Each fix needed a whole +new build (`rn-spm`, `frameworks`, then `xtool-build` through the libraries) to reach the next error, while every one of +them could have been reported seconds after its inputs existed. Two failures (F6, F7) were silent: a build and an +install that reported success with a broken app. The same day the podspec reader's JavaScript evaluator, written to fix +F6, dropped react-native-worklets' defines (fixed before a device ran it, scaffold revision 7), and a one-off sweep of +the old reader against the new one found two more differences to fix. That is two silent reader bugs in one day, and a +third caught only because someone thought to compare. + +This release turns that into one rule, "fail early, never silently", and four mechanisms: + +1. **A. A podspec reader that runs real Ruby** with a small shim of CocoaPods and React Native's helpers, so a podspec + reads as CocoaPods reads it; anything the shim does not model stops loudly. +2. **B. Failing in seconds:** a static resolution of the app target's own `#import`/`#include`, and a compile of the app + target's own sources with the manifest's flags right before `xtool-build`. +3. **C. Scaffold fidelity:** the files a podspec's globs match against the files the manifest lists, Objective-C classes + per compiled target, and per target in the packed app. +4. **D. Three reliability pieces:** logs on disk per command, a build stamp verified on the iPhone after every + install, and a USB retry when Wi‑Fi does not reach the iPhone. + +Plus **E**, a one-page guide for automated tools working in a user's project (`AGENTS.md`, `rn-xtool agent-guide`), +**F**, guards on rn-xtool itself (a permanent reader sweep, an Objective-C reference in the drift watch, a mention +check), and **G**, four small follow-ups from the trial. + +Owner's rule, as before: mechanisms over versions. Every check follows a content fact (a glob, an include, a symbol, a +plist key), never a library name or a version number. + +## Decisions (owner, 2026-11-06) + +Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: + +- **A. Podspec reader: real Ruby, shimmed CocoaPods.** The system `ruby` runs each podspec with a shim of rn-xtool's + (a Ruby file of roughly a hundred lines): `Pod::Spec.new`/`Pod::Specification`, subspecs, platform-scoped attributes, + `Pod::UI`, `ENV` as a controlled environment (`RCT_NEW_ARCH_ENABLED='1'`, `RCT_HERMES_V1_ENABLED='1'`, every other + variable unset), and React Native's helpers as no-ops that record what matters. It dumps the evaluated spec as JSON in + `pod ipc spec`'s model, so the existing consumer is reused. Anything the shim does not model fails loudly with the + method and the podspec. The JavaScript evaluator stays as the fallback without Ruby, with a fixed `⚠` line; `pod ipc + spec` stays preferred when a real `pod` exists. `doctor` and `setup` report Ruby. A `podspecEnv` config is a possible + later mechanism, not built now. +- **B. Fail in seconds, both halves.** (1) Static `#import`/`#include` resolution of the app target's own sources + (Objective-C/C++ and the bridging header; ``, `` and `"X.h"`; with the include paths the manifest will + give the App target) in `doctor --project` and at the start of `build`. (2) A `build` step right before + `xtool-build` that compiles the app target's sources with the generated manifest's flags (`clang -fsyntax-only`, + `swiftc -typecheck` with the bridging header). +- **C. Scaffold fidelity, "A complete plus weak B".** After scaffolding: podspec globs on disk against the manifest's + files (a mismatch is an error naming the files). After compiling: a target whose manifest lists `.m`/`.mm` sources + defines at least one Objective-C class in its object; in the packed app, every target with Objective-C sources + contributes at least one class to the App binary (an `ℹ` line for a target that legitimately has none). +- **D. Reliability:** logs under `ios-xtool/logs/-.log` (full output, the N most recent kept); a + per-build stamp in the generated Info.plist, verified by the post-install Lookup (a mismatch is a failure naming both + stamps); an automatic USB retry, announced in one line, when the Wi‑Fi install does not reach the iPhone after the + existing four tries. +- **E. The guide:** `AGENTS.md` shipped in the npm package and printed by `rn-xtool agent-guide`, one page; ship + `docs/` too, or say why not. +- **F. Guards on the project:** the old-vs-new reader sweep as a permanent test over a fixed set of about 30 popular + React Native library podspecs, their tarballs cached under `tests/.cache`, run in CI; an Objective-C-template + reference app in the daily drift watch; a markdown, PR-body and release-notes check refusing a bare `@word` outside + code spans, and the bare `@import`s left in the docs fixed. +- **G. Follow-ups:** silence the per-file `clang: warning: argument unused during compilation: + '-fmodules-cache-path=…'`; `doctor`'s "N to download" for pods the cache already holds; the `duplicate protocol + definition of 'RCTDependencyProvider'` warning; a docs line on React Native DevTools' `chrome-sandbox`. +- **Out of scope, deferred to alpha.9:** a scaffold cache in `~/.cache`, parallel scaffolding. + +## Goals + +1. Every failure the trial met in the app target (F1–F5) is reported before `xtool-build` starts compiling libraries: + app-own includes in `doctor --project` and seconds after `build` starts; the rest within about 30 s of `generate`. +2. A podspec is read as CocoaPods reads it whenever Ruby is present, and a construct rn-xtool cannot read stops the + library with the podspec, the line and the name, never a partial read. +3. A build whose libraries lost their sources (F6) stops before install, by the glob comparison and the class checks, + not only by the codegen guard. +4. An install that did not replace the app on the iPhone (F7) fails, naming the stamp the iPhone has and the one built. +5. Every command leaves its full output on disk, so a failure can be read after the terminal is gone. +6. rn-xtool's own regressions of these kinds are caught in CI (reader sweep), daily (Objective-C drift target) or before + publishing (mention check). + +## Non-goals + +- A scaffold cache in `~/.cache` and parallel scaffolding (alpha.9). +- The `podspecEnv` config. ENV variables other than the two stay unset; the design records which ones a podspec read. +- Installing the `cocoapods` gem, or any gem, through `setup`. +- Replacing rn-xtool's TypeScript-side podspec line readers (the early checks in `src/project/earlyChecks.ts`, the + resource reader in `src/pipeline/scaffoldResources.ts`) with the Ruby reader (row 29 proposes a later block). +- Compiling libraries in the precheck. B2 compiles only the app target's own sources. +- Reading xcconfig-based build settings or Xcode 16 synchronized folders into the generated project. This block only + makes them visible (rows 46 and 47). +- Upstreaming the shim to React Native. + +## Anti-goals + +- **A check that blocks a working app.** Each new stop is an error only where the check is certain; where it is not, + it is a `⚠` or an `ℹ`. Every check runs on every reference app and on the production app before release + (Verification). +- **Silent degradation.** No reader, check or install path falls back without a line that names the fallback. + +## Constraints + +- Linux only (x86_64 verified; arm64 untested), no Mac anywhere in the loop, no Xcode tools. +- An alpha with real users starting: every behaviour change is named in the CHANGELOG, an "Upgrading" note when a + user must act (the scaffold revision moves, row 25). +- The scaffolder ships twice and stays byte-identical: `vendor/rn-spm/spm/` and `patches/react-native+0.88.{0,1}.patch`, + regenerated from the vendored copy by the recipe in `docs/RELEASING.md` ("Scaffolder changes"), never edited as + text. A new shim file is a new file in both. +- RELEASING's revision rule: a change to what a scaffold writes bumps `RN_XTOOL_SCAFFOLD_REVISION` and + `SCAFFOLD_REVISION` together (now 7, `vendor/rn-spm/spm/scaffold-package-swift.js:139`, `src/pipeline/patches.ts:362`). +- `npm run scan:private` is clean on every commit; no fixture holds a path, name or identifier of the production app. +- `doctor --project` keeps working without Swift, xtool or a network (the drift watch runs it on a runner without + Swift). +- Downloads and builds on the owner's machine need the owner's approval first; device runs are the owner's. + +## Facts + +### The trial + +1. **The failures and their fixes** are F1–F7 above. F1 is PR #33, F2 PR #34, F3–F6 PR #35 (fixes 27 and 28 of the + scaffolder, scaffold revisions 5 to 7), all merged into 0.1.0-alpha.7. F7 is open: the install's output was not + kept, so whether it reported success cannot be checked any more; the old image had the same size and offsets as the + previous day's crash, the new `.ipa` was 3.8 MB larger, and a USB `rn-xtool install` replaced it. +2. **Timings of the green build** (owner's machine, 2026-11-06): `rn-spm` 578 s with 20 scaffolds, `frameworks` 35 s, + `xtool-build` 273 s. F2–F5 each stopped inside `xtool-build`; each fix was followed by a full build to reach the next + error. +3. **Rulings already taken in the trial** that this design keeps: a referenced header missing on disk is skipped with + `ℹ` (as Xcode); per-file `COMPILER_FLAGS` of the app target are not read; a project whose + `CLANG_CXX_LANGUAGE_STANDARD` is older than React Native's headers need fails as in Xcode; unknown `ENV` variables + read as unset; the pod-header forwarder list is pinned per pod version. + +### The podspec reader + +4. **Its strategy** (`vendor/rn-spm/spm/read-podspec.js`): `readPodspec` (line 2512) tries `runPodIpcSpec` (line 86), + which writes a copy of the podspec next to it with `install_modules_dependencies(…)` and `use_react_native!(…)` + commented out (`patchPodspecForPodIpc`, lines 57–84), runs `pod ipc spec` with `RN_POD_ENV` over the process + environment (line 110; `RN_POD_ENV` at line 230) and parses the line-anchored JSON. On any failure it returns null + and `regexPodspec` reads the file, after `evaluateRubyLocals` (line 995) ran the Ruby subset of fix 28. +5. **What the JavaScript evaluator refuses and leaves out.** `source_files` and `exclude_files` (`STRICT_FIELDS`, line + 294) and `compiler_flags`, `header_dir`, `header_mappings_dir`, `frameworks`, `libraries` (`WHOLE_FIELDS`, line 305) + with an unevaluable part are refused (`unresolvedSourcesReason`, line 2478, whose text tells the user to install + CocoaPods). An unevaluable part of `OTHER_CFLAGS`, `GCC_PREPROCESSOR_DEFINITIONS`, `HEADER_SEARCH_PATHS` and + `SWIFT_ACTIVE_COMPILATION_CONDITIONS` is left out with a `!` warning (lines 321–328); the trial lists + react-native-worklets' and react-native-vision-camera's values among them. `name`, `module_name` and `version` are + read as literals only (line 299). +6. **The consumer of the JSON model.** `flattenSubspecs` (line 2011) reads `subspecs`, `default_subspecs`, the + `dropSubspecs` option (fix 20) and the attributes of each selected layer. It reads no `ios` key. In CocoaPods' JSON + form an attribute set through `s.ios.` lives under `"ios"`, as in the CDN specs rn-xtool already parses + (`src/pods/spec.ts:171`). So on the `pod ipc spec` path, react-native-svg's `s.ios.exclude_files` is not applied + today; the regex path merges `s.ios.*` (fix 6). This was read in code only: there is no CocoaPods on the build + machine to run `pod ipc spec`. +7. **Who calls the reader.** The scaffolder (`scaffold-package-swift.js:2263` and `:2283`, refusal at `:2294`); the + autolinking's header search paths for every autolinked library (`generate-spm-autolinking.js:835`, which returns + `[]` on any throw); name facts (`expand-spm-dependencies.js:310` and `:482`, null on a throw, `readPodspecNames`' + regex first). `usesInstallModulesDependencies` comes from a regex over the podspec source (`read-podspec.js`, in + `readPodspec`). Today `readPodspec` throws only for a missing file, so these catches never hid a reader failure; a + Ruby reader that throws would be hidden by them. +8. **React Native's helpers** are defined in `scripts/react_native_pods.rb` of 0.85.0 and 0.88.1 (read from the cached + tarballs): `min_ios_version_supported`, `folly_flags`, `resolve_use_frameworks`, `add_dependency`, + `create_header_search_path_for_frameworks`, `install_modules_dependencies`, `podspec_sources`, `spm_dependency`, + `get_folly_config` and the other `get_*_config`/`set_*_config`, `rct_cxx_language_standard`; 0.88.1 adds + `rncore_pod` and `mark_as_react_native_build`. `install_modules_dependencies` appends compiler flags and + `pod_target_xcconfig` entries and about twenty `s.dependency` lines (`NewArchitectureHelper`, + `scripts/cocoapods/new_architecture.rb:75`). +9. **What real podspecs call.** A static scan (Ruby's `Ripper`, nothing evaluated) of 35 podspecs: the 15 libraries of + the trial's reader sweep that ship one, the bare 0.88 reference app's libraries, the Expo SDK 57 reference's Expo + modules and the podspec fixtures in `tests/fixtures/podspecs/`: + - helpers: `install_modules_dependencies` (16 files), `add_dependency` (react-native-gesture-handler, + expo-modules-core), `get_folly_config` (Expo's two), `respond_to?(:install_modules_dependencies, true)` (4), + `defined?(install_modules_dependencies())` (react-native-webview, gesture-handler 2.32.0), `use_expo_modules!` + under `defined?` (`Expo.podspec`). None of them calls `use_react_native!`, `folly_flags`, `use_frameworks?` or + `spm_dependency`; `folly_compiler_flags` is a local everywhere; + - CocoaPods: `Pod::Spec.new`, `Pod::UI.puts`, `Pod::Config.instance.installation_root`, `.project_pods_root` and + `.project_root`, `instance_variable_get(:@podfile)` (expo-modules-core's worklets adapter); + - Ruby beyond attributes: `require 'json'`, `require 'colored2'` (`Expo.podspec`, a CocoaPods dependency gem), + `require_relative` of the library's own `scripts/*.rb` (gesture-handler, react-native-reanimated, svg, + worklets), `File.read`/`File.join`/`File.exist?`, `Pathname`, `raise`, backticks and `system` running `node` + (worklets, reanimated, vision-camera, Expo); + - globals the Podfile may set: `$VCEnableLocation`, `$VCEnableFrameProcessors`, `$RNVideoUseGoogleIMA`, + `$RNVideoUseVideoCaching`, under `defined?`; + - `ENV` names: `RCT_NEW_ARCH_ENABLED`, `RCT_HERMES_V1_ENABLED`, `USE_HERMES`, `USE_FRAMEWORKS`, `RNS_GAMMA_ENABLED`, + `RNS_DEBUG_LOGGING`, `RNS_USE_CXXBRIDGE`, `REACT_NATIVE_PATH`, `IS_WORKLETS_PROFILING`, `IS_REANIMATED_PROFILING`, + `PROJECT_ROOT`, and `REACT_NATIVE_NODE_MODULES_DIR` in the libraries' scripts; + - attributes: the usual ones, and `s.ios.exclude_files`, `s.ios.resource_bundles`, `ss.ios.dependency`, + `s.respond_to?(:visionos)`, `test_spec`, `script_phase`, `prepare_command`, `static_framework`, + `project_header_files`. +10. **What a library's own Ruby does.** react-native-worklets 0.8.3's `scripts/worklets_utils.rb` finds React Native + with `` `cd "#{Pod::Config.instance.installation_root}" && node --print "require.resolve(…)"` `` and raises when it + cannot; it runs `system("node …/validate-react-native-version.js …")`; it reads `./src/featureFlags/staticFlags.json` + relative to the working directory, which CocoaPods sets to the podspec's folder. reanimated's reads the app's + `package.json` through `installation_root/..`. These are the values fix 28 leaves out with `!`. +11. **Ruby on the machine.** The build machine has Ruby 3.3.8. Neither `doctor` nor `setup` mentions Ruby today + (`src/commands/doctor.ts`, `src/commands/setup.ts`). +12. **The scaffolder's copies** (fact 11 of the [library compatibility design](2026-11-04-library-compat-design.md), + unchanged): `vendor/rn-spm/` is pristine 0.88.0 plus the 0.88 patch plus `vendor/rn-spm/rn-xtool-edits.patch`; + `tests/vendor-rn-spm.test.ts`, `tests/patches.test.ts`, `tests/patches-upstream.test.ts` and + `tests/rn-scaffolder.test.ts` keep them equal. Fixes 1–28 are taken (`docs/upstream/react-native-scaffolder.md`), so + the reader change is fix 29. + +### The app target + +13. **What rn-xtool reads from a bare app's Xcode project** (`readTargetContent`, `src/project/pbxproj.ts:332`): the + Sources phase (Swift, C-family, headers; anything else refused), every header the group tree places under `ios/` + outside `Pods/`, `build/`, `DerivedData/`, frameworks and Products, the bridging header, + `GCC_PREPROCESSOR_DEFINITIONS`, `HEADER_SEARCH_PATHS`, `CLANG_CXX_LANGUAGE_STANDARD`, `PRODUCT_MODULE_NAME`, and the + names of `OTHER_CFLAGS`/`OTHER_LDFLAGS`/`OTHER_SWIFT_FLAGS` when set (an `ℹ` line). Settings are read from the + target's and the project's configurations only: nothing in `src/project/` reads a `baseConfigurationReference` + (xcconfig) or a synchronized folder group. +14. **How the sources are copied** (`copyBareTarget`, `src/generate/bareSources.ts`): into `ios-xtool/Sources/App`, + with one forwarding header per app header in `Sources/App/include/` (Xcode's header map), `main.` as + `AppMain.`, and a `-Swift.h` forward to `App-Swift.h` in a mixed target. +15. **The App target's include paths** (`src/generate/iosXtool.ts:108-115`): the copy's `include/` and the project's + `HEADER_SEARCH_PATHS`, then `reactNativeBareIncludeDirs(ios/build/xcframeworks)` (ReactHeadersTarget's flat + `include/React`, then each module folder of the device slice of `ReactNativeHeaders.xcframework`) and + `podHeaderForwardDirs` (each autolinked library's `rn-spm-pod-headers`). The last two exist only after `rn-spm`. +16. **The App target's flags** (`src/generate/packageSwift.ts`): for a mixed target, `cSettings` and `cxxSettings` with + the defines, `-I` for each include path, the Swift headers dir and Expo's importer paths, and `-std=` for C++ only; + for Swift, `-import-objc-header` with the same paths as `-Xcc -I`. SwiftPM adds the header directories and module + maps of the products the App depends on (`ReactHeaders`, `ReactNativeHeaders`, `ReactNativeDependenciesHeaders`, + `ReactCodegen`, `ReactAppDependencyProvider`, `Autolinked`, `ExpoModulesJSIHeaders`) itself. The trial's response + files show Swift Build compiling `.mm` with `-fmodules -fno-cxx-modules`, as Xcode does. +17. **Build order** (`src/commands/build.ts:62`): `patches`, `rn-artifacts`, `rn-spm`, `jsi`, `app-config`, + `frameworks`, `generate`, `xtool-build`; after it the binary-pod post-pack checks and the codegen class guard + (lines 595–596). `App-Swift.h` exists only once Swift Build ran (`swiftHeadersDir`, `src/paths.ts:59-67`). +18. **`doctor --project`** runs the `node` check, the project read and the capability probe only, so it needs no + toolchain (`src/commands/doctor.ts:521-551`). + +### Checks after the build + +19. **The codegen class guard** (`src/pipeline/codegenClasses.ts`, alpha.7) reads the classes + `RCTThirdPartyComponentsProvider.mm` and `RCTModuleProviders.mm` name and requires each in the App binary or an + embedded framework (`llvm-nm --defined-only`); a stripped binary gives an `ℹ` line; a missing class removes the + packed app and its `.ipa`. `install` runs it again on the app xtool builds before installing (`checkedApp`, + `src/commands/install.ts`). +20. **Where a target's object is.** Swift Build writes and links `ios-xtool/.build/out/Products/Debug-iphoneos/.o` + (`EMPTY_TARGETS_DIR`, `src/pods/emptyTargets.ts`). In the trial, `RNScreens.o` defined no Objective-C class. +21. **How a scaffold lists its sources** (`scaffold-package-swift.js:1110-1170`, emitted at `:1847-1856`): the podspec's + `source_files` globs expanded on disk (`expandSpmSourceGlobs`), `exclude_files` applied with `micromatch`, then the + scaffold's own files filtered out (`Package.swift`, `Package@swift-*.swift`, the prefix header, `include/`, the + mixed-support and React-headers folders), and `.metal` files excluded off Darwin. The manifest lists the result as + explicit `sources:` paths. + +### Installing + +22. **Over Wi‑Fi** (`src/device/wifiInstall.ts`): lockdown session, AFC upload to `/PublicStaging`, installd `Install`, + then `Lookup` with four `ReturnAttributes` (`CFBundleIdentifier`, `CFBundleShortVersionString`, `CFBundleVersion`, + `SignerIdentity`, `src/device/installproxy.ts:54`). The result is checked only for the bundle id's presence; the + version and build are printed, not compared (`src/commands/install.ts`, end of `installNetwork`). +23. **Retries.** `retryWhileUnreachable` makes four tries ten seconds apart and ends with "connect it by USB and run + `rn-xtool install`" (`src/device/discover.ts:264-283`). An interrupted upload is retried once; an interrupted + `Install` never (`InstallInterruptedError`). +24. **Over USB**, `install` runs `xtool dev run --usb` (`src/tools/xtool.ts:174`) and does no Lookup of its own. + `usbmuxConnector` and `LockdownClient` exist and `doctor`'s Wi‑Fi probe already opens a lockdown session over USB + with them. +25. **The state** (`src/state.ts`) records the fingerprints, the UDIDs and the signed bundle id; `run` skips build and + install when `depsFingerprint`, `installedFingerprint` and `installedUdid` match (`src/commands/run.ts:61-80`). +26. **Info.plist** is regenerated at every `generate` from the project's template (`transformInfoPlist`, + `src/plist.ts:78`; `src/generate/iosXtool.ts:276-284`), and xtool packs it (`infoPath: Info.plist` in `xtool.yml`). + +### Output + +27. **No log file exists.** `devBuild` runs `xtool dev build` with `stdio: "inherit"` (`src/tools/exec.ts:47`), so the + longest output of a build never passes through rn-xtool; `rn-spm` streams through `streamingRunner` + (`src/pipeline/rnSpm.ts`). `ios-xtool/.gitignore` holds `*` (`src/generate/iosXtool.ts:327`). `build --clean` + removes `ios-xtool/` on bare (`src/commands/build.ts:477`). +28. **The noise.** Swift Build passes `-fmodules-cache-path=/.build/out/ModuleCache.noindex` to clang on + compile and link steps where it is not used; earlier build logs of the reference apps hold the warning 209, 106 and + 9 times. +29. **Redaction exists**: `doctor --report` redacts Apple IDs, Team IDs, UDIDs, device names, IPs and home folders + (`redact`, `src/commands/report.ts`). + +### rn-xtool's own guards + +30. **The drift watch** never compiles: per supported line it creates a project (`create-expo` or the React Native + CLI's template, which is Swift since 0.77) and runs `doctor --project`, a dry run of the bundled patches and the + manifest-rewrite check (`docs/RELEASING.md`, `src/drift/targets.ts`, `src/drift/check.ts`). +31. **CI** (`.github/workflows/ci.yml`) runs on `ubuntu-latest`: `npm ci`, `node scripts/fetch-test-tarballs.mjs` + (the 15 tarballs of `tests/tarballs.json`, 23.6 MB, into `tests/.cache`), lint, `scan:private`, tests, and the list + of skipped tests. +32. **Bare mentions in the tracked markdown** (outside fenced blocks and code spans): four `@import` in user form, not + three: `CHANGELOG.md:47`, `docs/troubleshooting.md:292` and `:918`, and `docs/upstream/react-native-scaffolder.md:498`; + eleven more user-form ones in `docs/design/specs/2026-11-04-library-compat-design.md:44` and `docs/research/` + (`@react-navigation`, `@d11`, and hunk line numbers written `@54`, `@113`, `@170`, `@844`, `@1099`); and 122 scoped + package names (`@scope/name`). +33. **What ships.** `package.json` `files` holds no `docs/` (RELEASING step 4 says so); error texts link to + `docs/troubleshooting.md` on GitHub (`src/docs.ts`). `docs/` is 1.7 MB, 1.1 MB of it `docs/design/`. + +### The follow-ups + +34. **doctor's pods line** counts a pod as cached only when the project's lock records it at the resolved version and + the cache holds `downloads/.` (`src/project/capabilities.ts:471-479` and `:536-537`). Before a + project's first build there is no lock entry, so the line says "N to download" whatever the cache holds. Whether + the trial's build then downloaded the ten files again is not recorded. +35. **`RCTDependencyProvider`.** On 0.88.1 the flat `ReactHeadersTarget/include/React/RCTDependencyProvider.h` is a + redirect to `` written by headers-compose (seen in the bare 0.88 + reference app); on 0.86.3 the flat folder holds no such file. The trial's warning came from 0.85.0, whose second + path was not identified (the ledger names `ReactAppHeaders`/`ReactAppDependencyProvider` and + `React_RCTAppDelegate`). + +## Approaches + +Each decision with the alternatives that were weighed. The owner's choice is marked; the others are recorded so they +are not proposed again without new facts. + +### A. Reading a podspec + +1. **Real Ruby, shimmed CocoaPods (owner's choice).** The system `ruby` evaluates the podspec as CocoaPods does: every + local, condition, interpolation, `require_relative` helper and `node` call runs for real. The shim models only the + DSL and React Native's helpers, which are small and stable (facts 8 and 9). Ruby is one `apt install` away on + Ubuntu; a machine without it keeps today's reader with a `⚠` line. +2. *Install the `cocoapods` gem through `setup`.* Rejected: native extensions (`ffi`, the `xcodeproj` gem's + dependencies) build differently across distros and Ruby versions, `gem install` needs write access to a gem home, + and `pod ipc spec` still lacks React Native's helpers (fact 4 strips them). +3. *Keep improving the JavaScript evaluator.* Rejected: two silent bugs in one day (F6 and the worklets defines), and + every new podspec idiom is another subset to write. It stays as the fallback only. + +### B. Failing in seconds + +1. **Both halves: a static include resolution and a precompile of the app's own sources (owner's choice).** The static + half runs without a toolchain, so it works in `doctor --project` and in the drift watch, and catches F2 before + anything changes. The precompile uses the real compiler with the manifest's flags, so it catches what only a + compiler sees: F4 (the C++ standard) and F5 (`@import` with modules off in Objective-C++). +2. *Only the static half.* Rejected: F4 and F5 are not include problems. +3. *Only the precompile.* Rejected: it needs the toolchain and the generated project, so it cannot run in + `doctor --project`, and it starts only after `rn-spm`. + +### C. Scaffold fidelity + +1. **"A complete plus weak B" (owner's choice):** the glob-against-manifest comparison for every file (A complete), + and a class check per target and per packed app that asks only for "at least one class" (weak B). +2. *Require every `@interface` of a library's public headers in the binary.* Rejected: declarations under `#if` + (platform, architecture, feature flags) would stop working apps. +3. *Only the codegen class guard of alpha.7.* Rejected: it covers libraries with codegen components and modules only; + an old-architecture module that lost its sources is not named there. + +### D. Reliability + +1. **Logs on disk per command, a build stamp verified on the iPhone, and a USB retry (owner's choice).** +2. *Compare `CFBundleShortVersionString`/`CFBundleVersion` after install.* Rejected: the trial's app keeps its version + and build across builds (they come from the Xcode project), so they cannot tell a new binary from an old one. +3. *Keep the terminal as the only record.* Rejected: F7's output was lost. + +### E. The guide + +1. **One page, `AGENTS.md`, shipped and printed by a command (owner's choice).** A tool working in a user's project + reads what rn-xtool generates, what belongs to the user and how to diagnose, without the repository. +2. *Point at the README on GitHub.* Rejected: it describes installing and using rn-xtool, not what may be deleted or + regenerated in a project, and it is not on the user's disk. + +### F. Guards on rn-xtool + +1. **A permanent reader sweep in CI, an Objective-C drift target, a mention check (owner's choice).** +2. *Sweep once per release by hand.* Rejected: the one-off sweep of 2026-11-06 found two reader bugs; a permanent one + finds the next one on the commit that causes it. + +## Design + +### A. The podspec reader + +**Hop by hop, for one podspec:** + +1. **Choose the path.** `readPodspec` keeps its order with one step added: `pod ipc spec` when a `pod` runs (unchanged, + row 13), else the shim when a usable `ruby` runs, else the JavaScript evaluator. "Usable" is decided once per run: + `ruby` on `PATH`, a version the shim supports (the builder sets the floor from the shim's needs; Ubuntu 22.04's + archive has 3.0), and `require 'json'` working. +2. **Run Ruby.** One process per podspec: `ruby `, with + - the working directory set to the podspec's folder (CocoaPods evaluates a podspec there; worklets reads + `./src/featureFlags/staticFlags.json`, fact 10); + - an environment of `PATH`, `HOME`, `LANG` and the two React Native variables, nothing else: no `RUBYOPT`, + `BUNDLE_*` or `GEM_*` from the shell, so a project's `Gemfile` or a `bundle exec` shell cannot change the run; + - a 30 s timeout per podspec, as `pod ipc spec` has. +3. **What the shim models.** + - `Pod::Spec.new`/`Pod::Specification` with every attribute CocoaPods 1.16 defines (unknown names fail), subspecs + (nested), `default_subspec(s)`, `test_spec`/`app_spec` (recorded, never merged), platform proxies `s.ios`, + `s.osx`, `s.tvos`, `s.visionos`, `s.watchos`, and `s.respond_to?` answering as CocoaPods does; + - `Pod::UI.puts`/`.warn`/`.info` (captured, not printed), `Pod::Config.instance` with `installation_root` and + `project_root` (the app's `ios/`) and `project_pods_root` (`ios/Pods`, which need not exist), `Pod::Executable` + only if the sweep finds a caller; + - React Native's helpers of fact 8 as recorders: `install_modules_dependencies` records the call (the scaffolder's + React-core marker, today a regex), `add_dependency` records the dependency, `get_folly_config` returns the + installed React Native's folly values (read from its `scripts/cocoapods/helpers.rb` when that file loads alone, + else the values the supported lines share), `min_ios_version_supported` returns the value the installed React Native defines, and + `spm_dependency` records its arguments so the scaffold can refuse the library by name (row 12); + - `require` of the gems CocoaPods brings and podspecs load (`colored2`) as stubs; `require_relative` of the + library's own files runs them; + - `ENV` as podspecs see it: the two variables, every other name unset; each name read is recorded. + - Everything else is Ruby: `defined?`, backticks, `system`, `File`, `JSON` behave as under CocoaPods. A + `defined?(name)` of something the shim does not define answers nil, as under CocoaPods without that Podfile. +4. **Fail loudly.** A call to a method or constant the shim does not define, an attribute CocoaPods does not know, a + `require` that does not load, an exception the podspec raises itself, or the timeout ends the run with a result + naming the podspec, the line and the name: `:: the podspec calls foo(…), which rn-xtool's podspec + reader does not model`. No fallback to the JavaScript evaluator follows (rows 4–8). +5. **Write the model.** The shim writes the spec as CocoaPods' JSON form to ``, not to stdout (a podspec's + own `puts` cannot corrupt it), plus three rn-xtool keys: the `ENV` names read, the helpers called, and whatever + `Pod::UI` printed. +6. **Consume it.** `flattenSubspecs` reads it as it reads `pod ipc spec`'s JSON, with one fix shared by both paths: + each layer's `ios` attributes are merged over its own (and `osx`, `tvos`, `visionos`, `watchos` are ignored), as + CocoaPods does for an iOS target (fact 6). `dropSubspecs` (fix 20) applies unchanged. `name`, `module_name` and + `version` keep today's resolution: `readPodspecNames`' literals first (row 15). +7. **Tell the caller.** Every caller of the reader learns which path read the podspec and why a run failed. The scaffold + turns a failure into its `status: 'error'` with the reason, as for fix 28's refusals. The autolinking callers + (fact 7) no longer swallow a reader failure: it stops `rn-spm` with the same text (row 10). The results file + records the path per library. +8. **Say which reader ran.** When the JavaScript evaluator read any podspec, `build` prints one fixed line at the + `rn-spm` step: `⚠ Ruby was not found (or ), so rn-xtool read the podspecs with its reduced reader, which + evaluates a subset of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does. See …`. `doctor` + prints a `ruby` line (`✔ ruby 3.3.8`, or `⚠ not found — podspecs are read with the reduced reader; sudo apt install + ruby`), and so does `doctor --project` (it needs no toolchain). `setup` checks Ruby and prints the install command; + it installs nothing. +9. **Ship it.** The shim is `scripts/spm/read-podspec-shim.rb` in React Native's tree: a new file in + `vendor/rn-spm/spm/` and in both 0.88 patches. Scaffolder fix 29 documents it. The scaffolds' output changes + (fact 6's `ios` merge, the values fix 28 left out), so the scaffold revision moves from 7 to 8, and each scaffold's + marker records the reader that wrote it. + +### B. The app target's checks + +**B1, the include resolution.** It reads the app target as `generate` will copy it (fact 13): every C-family source, +every header the copy keeps, and the bridging header. For each file it strips comments, follows `#if`/`#ifdef`/ +`#elif`/`#else` with the target's defines, `RCT_NEW_ARCH_ENABLED=1`, `DEBUG=1` and the iOS values of `TARGET_OS_*`, +and evaluates `__has_include` with the resolver itself. Each `#import`/`#include`: + +- `"X.h"`: the including file's folder, then the app's headers by name (the forwards of fact 14), then the include + paths in order; +- `` and ``: the include paths in order, then the dependency products' header folders (fact 16); +- `@import M;`: a module map on the paths or a target of the package graph named `M`; +- generated names (`App-Swift.h`, `-Swift.h`, any ``): not checked; the build makes + them. + +An include is **missing** when it is unconditional (outside every `#if` group except include guards) and resolves +nowhere; one under a condition B1 cannot evaluate is never an error. B1 runs twice: + +1. **Pass 1, before anything changes**: in `doctor --project` and at the start of `build`, next to the early checks. + It knows the app's own files and `HEADER_SEARCH_PATHS`. An app-own quote include that is missing (F2) is an error + with the file, the line, the header and where rn-xtool looked. An angle include into React Native's or a library's + headers is "not checked yet" while `ios/build/xcframeworks` and the scaffolds are not staged: one `ℹ` line with the + count, in doctor only. +2. **Pass 2, in the precheck step** (below): the include list the manifest has just been given, plus the dependency + products' header folders. A missing include is an error (F3). + +**B2, the precheck.** A new `build` step, `precheck`, after `generate` and before `xtool-build`: + +1. **The command lines.** One function builds them from the same inputs `renderPackageSwift` used: the App target's + defines and `-I` list, `-std=` for C++ and Objective-C++, the dependency products' header folders and the module + maps already on disk, and what Swift Build passes every App compile (`-target arm64-apple-ios`, the + iPhoneOS SDK of xtool's Swift SDK bundle, `-fobjc-arc`, `-fmodules`, `-fno-cxx-modules` for C++ and Objective-C++, + `-DDEBUG=1`, a module cache in `ios-xtool/.precheck/ModuleCache`). A test compares the result with the response + file Swift Build wrote for the reference apps' App target (row 39). +2. **Swift first.** `swiftc -typecheck` on the App's Swift files with `-import-objc-header` and the same `-Xcc` paths, + writing `App-Swift.h` into `ios-xtool/.precheck/` (`-emit-objc-header-path`) for the next hop. When a Swift file + imports a module SwiftPM builds from Swift (Expo, `ExpoModulesCore`, any Swift library target), the Swift part is + not checked: one `ℹ` line names the file and the module (row 43). +3. **C-family next.** `clang -fsyntax-only` on each `.m`, `.mm`, `.c`, `.cc`, `.cpp` of the App, in parallel, with + `nice`. A file that imports `App-Swift.h` is checked only when hop 2 wrote it. +4. **Report.** An error stops the build before `xtool-build`: `✖ precheck — :: ` with + clang's include stack (F4's error is in a React Native header; the cause is the app's flags), the first ten errors, + and the log file's path. Warnings are not printed: `xtool-build` prints them once. +5. **Manifest planning** (row 54, owner's call): `swift package describe --type json` in `ios-xtool/`, which plans the + package without compiling, would report F1-like refusals (an executable App target, an invalid header layout) at the + same point. + +Both B1 and B2 run on bare projects and on an Expo project's bridging header ([library +compatibility](2026-11-04-library-compat-design.md), goal 3.6); an Expo project's `AppDelegate.swift` imports `Expo` +and is therefore not prechecked. + +### C. Scaffold fidelity + +1. **Globs against the manifest**, in `rn-spm` after the scaffold step, for every library whose `Package.swift` + carries the scaffolder's banner (just scaffolded or applied from `patches/`). The expected set is the podspec's + selected layers' `source_files` minus `exclude_files`, expanded by Ruby's `Dir.glob` with CocoaPods' flags when Ruby + is present (the JavaScript expansion otherwise), minus the scaffolder's own exclusions of fact 21, which the + scaffolder exports as one list. Only compiled extensions are compared (`.m`, `.mm`, `.c`, `.cc`, `.cpp`, `.cxx`, + `.swift`); headers move into shims and are not. A file the globs match that no target lists, or a listed file the + globs do not match, is a difference: for a manifest written by this run it is an error naming the library and the + files; for one applied from `patches/` it is a `⚠` naming the patch (row 57). +2. **Classes per target**, after `xtool-build`: for each scaffolded target whose manifest lists `.m` or `.mm` sources, + `llvm-nm --defined-only` on `.o` (fact 20). No `_OBJC_CLASS_$_` symbol while the sources hold a + non-category `@implementation` is an error naming the target and the files that declare one; no class and no such + `@implementation` (categories or C functions only) is an `ℹ` line. +3. **Classes per target in the packed app**: each class of hop 2 must be defined in the App binary or an embedded + framework. A target that defines classes in its object and contributes none is an error (it was not linked); a target + hop 2 noted with `ℹ` gets no line here. The failure removes the packed app and its `.ipa`, as the codegen guard does. + `install` runs hops 2 and 3 again on the app xtool builds before installing (`checkedApp`). + +### D. Reliability + +**D1, logs.** Every project command (`build`, `install`, `run`, `start`, `doctor --project`, `doctor --report`) opens +`ios-xtool/logs/--.log` before its first line and writes everything the terminal shows, +without color codes, including every child's output: `xtool dev build` and `xtool dev run` move from inherited stdio to +the tee runner rn-xtool already has (fact 27). The file ends with the exit status, or the signal. The ten most recent +logs per command are kept. `build --clean` keeps `ios-xtool/logs/`. A failure's last line names its log. A log that +cannot be opened gives one `⚠` line and the command goes on. `start` logs rn-xtool's own lines, not Metro's stream +(row 75). + +**G1, the noise**, is filtered in the same tee: the exact `clang: warning: argument unused during compilation: +'-fmodules-cache-path=…' [-Wunused-command-line-argument]` line is not shown, still written to the log, and counted in +one line at the end of `xtool-build`. + +**D2, the build stamp.** + +1. `generate` writes `RNXtoolBuildStamp` (the build's UTC time and 8 random hex characters) into the generated + Info.plist and `buildStamp` into the state. +2. After `xtool-build`, the packed `App.app/Info.plist` must hold it; after `xtool dev build --ipa`, so must the + `.ipa`'s, before anything is uploaded (row 87). +3. After the install, a `Lookup` asks for `RNXtoolBuildStamp` too: over Wi‑Fi in the existing session; over USB through + a new lockdown session over usbmux, after `xtool dev run`. +4. The same stamp: `Installed (build ) on …`, and `installedStamp` in the state. Another stamp, or none: + `✖ The iPhone kept the app built at ; this build is . installd reported the install as + complete. Install over USB: rn-xtool install`. A state without `buildStamp` (built by alpha.7) gives `ℹ` and no + check. +5. `run` counts the app as installed only when `installedStamp` equals `buildStamp` (row 91). + +Whether xtool keeps a custom Info.plist key and whether installd returns one in `Lookup` is checked on a device before +anything else is built (open question 1). + +**D3, the USB retry.** When the four Wi‑Fi tries fail as unreachable (fact 23), `install --network` looks for the same +iPhone (UDID) on USB. Found: `iPhone did not respond over Wi‑Fi after 4 tries; installing over USB instead (it is +connected by USB)`, then the USB install with D2's check. Another iPhone on USB: the Wi‑Fi error, plus a sentence +naming both UDIDs; nothing is installed. None: the Wi‑Fi error as today, plus "and no iPhone is connected by USB". +Any other failure (an interrupted `Install`, a refused pair record, several iPhones) keeps today's handling. + +### E. The guide + +`AGENTS.md` at the package root, in `files`, printed by `rn-xtool agent-guide` (also `--path` to print where it is). +One page: + +- what each step of `build` does and writes (`patches`, `rn-artifacts`, `rn-spm`, `jsi`, `app-config`, `frameworks`, + `generate`, `precheck`, `xtool-build`, the post-build checks), and what `install`, `run` and `start` do; +- what is regenerable and may be deleted (`ios-xtool/`, `ios/build/`, `~/.cache/rn-xtool/`), what belongs to the user + and is never deleted or regenerated by a tool (`patches/`, `rn-xtool.config.json`, `rn-xtool-pods.lock.json`, the + Xcode project), and what is never committed (`ios-xtool/`, `ios/build/`, the logs); +- how to diagnose: `rn-xtool doctor --project`, `rn-xtool doctor --report` (redacted, for an issue), the logs; +- what the marks mean: `✔` done, `⚠` works with a limit the line names, `!` a scaffolder note about one library, `ℹ` + information, `✖` stopped; +- where the troubleshooting page is. + +A test keeps the guide's step list equal to `BUILD_STEP_NAMES` plus `precheck`, and its folder lists equal to the paths +rn-xtool writes. `docs/` ships in part (row 103): the user pages (`docs/README.md`, `troubleshooting.md`, +`how-it-works.md`, `bare-react-native.md`, `libraries.md`, `recipe.md`, `wifi-install.md`), so the guide's links work +offline; not `docs/design/`, `docs/research/` or `docs/upstream/` (1.4 MB of history and upstream proposals). + +### F. Guards on rn-xtool + +1. **The reader sweep**, `tests/podspecReaderSweep.test.ts`: about 30 libraries pinned in `tests/tarballs.json`, the + production app's 20 among them, plus the most installed React Native libraries with an iOS podspec (the builder + proposes the list, the owner approves it). Each is unpacked into a temporary project next to a cached + `react-native` (their podspecs run `node` against it), read by both readers, and compared with a reviewed golden + per library: the shim's model, and the fields where the reduced reader differs. A change in either reader's output + fails until the golden is updated in the same commit. On CI the Ruby half must run: a missing Ruby fails the job, + not skips it; locally it skips with the test's name saying it needs Ruby. +2. **The Objective-C drift target**, `bare-0.88/objc` (and per bare line): the CLI's fresh project with its Swift + app delegate replaced by an Objective-C one in the pre-0.77 layout (`main.m`, `AppDelegate.h`, `AppDelegate.mm` at + the root of the group tree), from a fixture written for rn-xtool. The watch runs `doctor --project` on it (B1 pass + 1), downloads React Native's headers artifact for the line's newest patch, builds the bare include list + (`reactNativeBareIncludeDirs`) and runs B1 pass 2 against it. A header the Objective-C template imports that no + longer resolves makes the line red. +3. **The mention check**, `scripts/check-mentions.mjs …` and a test over every tracked markdown file: outside + fenced blocks and code spans, a `@` followed by a GitHub user name (`@import`, `@word`) is refused with the file and + line; a scoped package name (`@scope/name`) passes (row 112). RELEASING runs it on the release notes' file before + `gh release create --notes-file`, and the PR text is checked before `gh pr create --body-file`; a workflow on + `pull_request` (`opened`, `edited`, `reopened`, `synchronize`) checks the PR body and fails the run when a mention is + left. The fifteen user-form mentions of fact 32 become code spans or plain words in the same task. + +### G. Follow-ups + +1. **The `-fmodules-cache-path` noise**: D1's filter (above). +2. **doctor's "to download"**: a pod counts as cached when the cache holds an archive with the sha256 the lock records + or, without a lock entry, the sha256 the spec declares, or one a previous resolution of the same URL recorded in the + cache. The builder first checks whether the build itself downloads again in the same state; if it does, the fix is + in the `pods` step too. +3. **`duplicate protocol definition of 'RCTDependencyProvider'`**: the builder finds the second path on 0.85.0 + (`clang -H` on `AppDelegate.mm` of a fresh bare 0.85 project with the Objective-C fixture) and makes the App's include list reach the header by one + file only, without changing 0.86–0.88's resolution (tests on all four lines' header trees). +4. **DevTools on Linux**: troubleshooting gets a section: React Native DevTools (the `j` key) runs Chromium's + `chrome-sandbox`, which must be owned by root with mode 4755 on Linux (`sudo chown root:root …/chrome-sandbox && + sudo chmod 4755 …/chrome-sandbox`), or DevTools does not open; the rest of Metro works without it. + +## Failure walk + +The process, end to end. Each piece talks to something outside rn-xtool's own code: a Ruby interpreter running +third-party Ruby and `node`, the compiler and the SDK, Swift Build's object files, the iPhone's installd over Wi‑Fi and +USB, the disk, GitHub's mention parser, npm and the drift watch's runners. + +1. **A, reading a podspec:** probe `ruby` once per run; pick `pod`, the shim or the reduced reader; spawn Ruby in the + podspec's folder with a fixed environment; the podspec runs (its `require`s, React Native's helpers, `node` calls, + `ENV`, `Pod::Config`); the shim writes the JSON model; `flattenSubspecs` consumes it; the scaffold and the + autolinking act on it; `build` says which reader ran; the shim ships in the vendored copy and both 0.88 patches. +2. **B, the app target:** B1 pass 1 in `doctor --project` and at `build` start; `generate`; B1 pass 2 and B2 in the + `precheck` step (command lines, `swiftc -typecheck`, `clang -fsyntax-only`, report); `xtool-build`. +3. **C, fidelity:** the glob comparison in `rn-spm`; the class check per target object after `xtool-build`; the class + check per target in the packed app; both again in `install`. +4. **D1 and G1, logs:** open the log; tee every line and every child; filter the `-fmodules-cache-path` noise; close + with the status; rotate. +5. **D2, the stamp:** `generate` writes it; the packed app and the `.ipa` hold it; installd installs; `Lookup` returns + it; rn-xtool compares and records; `run` reads it. +6. **D3, the USB retry:** four Wi‑Fi tries fail; usbmux lists the iPhones; the USB install runs with D2's check. +7. **E, the guide:** packed into the npm package; printed by `agent-guide`; read by a tool in a user's project. +8. **F, guards:** the sweep in CI (npm, Ruby, `node`); the drift watch's Objective-C target (the CLI template, the + fixture, React Native's headers artifact); the mention check (locally, in tests, in a `pull_request` workflow). +9. **G, follow-ups:** doctor's pods line; the include list for `RCTDependencyProvider`; the DevTools docs line. + +| # | Hop | Fails how | Who learns | Proposed ruling | +|---|-----|-----------|------------|-----------------| +| 1 | A, Ruby probe | no `ruby` on `PATH` | user: the fixed `⚠` line at `rn-spm` (once per build), doctor's `⚠ ruby — not found …` line, and `setup`'s install command | handle: A.1, A.8; tests with a `PATH` without Ruby | +| 2 | A, Ruby probe | Ruby runs but is unusable: older than the shim's floor, `require 'json'` fails (some distros package it apart), the interpreter crashes | user: the same `⚠` line with the reason (`ruby 2.5.1 is older than `, `ruby cannot load json`); doctor says the same | handle: the probe runs a one-line script through the shim's own loader; tests with a fake `ruby` per case | +| 3 | A, spawn | the shell's `RUBYOPT`, `BUNDLE_GEMFILE`, `GEM_HOME` (a `bundle exec` shell, the project's `Gemfile` with `cocoapods`) would load other code or fail the start | nobody: the run gets a fixed environment (A.2) | handle: test with `RUBYOPT=-rnonexistent` in the parent environment | +| 4 | A, shim | the podspec calls a method or constant the shim does not define, or sets an attribute CocoaPods does not know | user at `rn-spm`: `:: the podspec calls foo(…), which rn-xtool's podspec reader does not model`; a scaffolded library is refused, an autolinking read stops `rn-spm` (row 10) | handle: one test per kind (method, constant, attribute) | +| 5 | A, shim × a working app | the library built with the reduced reader before, and a shim gap now stops it (anti-goal) | user: row 4's stop | **owner's call.** Proposed handle: the sweep (F1) covers about 30 libraries before release; the stop's text says how to report; `RN_XTOOL_PODSPEC_READER=reduced` forces the reduced reader for one run, with the `⚠` line naming the variable, so nothing falls back silently. Alternative: no escape, the user waits for a fix | +| 6 | A, `require` | a gem the shim does not stub (a CocoaPods plugin, `xcodeproj`) | user: `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2` | handle: `colored2` stubbed (Expo's podspec); test with an unknown gem | +| 7 | A, the podspec raises | worklets and reanimated raise when React Native is not found, when its version check fails, or with the New Architecture off | user: the podspec's own message, prefixed with the podspec's path, as `pod install` shows it | handle: test with worklets 0.8.3's podspec and no `react-native` | +| 8 | A, timeout | a backtick or `system` call hangs (a `node` script waiting, a network call) | user: ` did not finish in 30 s`; the library is refused | handle: test with a podspec that sleeps | +| 9 | A, `node` calls | the child's `PATH` lacks `node`, or `require.resolve` from `ios/` fails | user: the podspec's raise (row 7) | handle: the child environment keeps `PATH` and `HOME`; test with worklets' utils in a fixture project | +| 10 | A, callers | the autolinking callers catch every throw (fact 7), so a shim failure there would leave a library without its header search paths, silently | user: `rn-spm` stops with the shim's text | **owner's call**, because it can stop an Expo build on an Expo module's podspec (`Expo.podspec` requires `colored2`, tests `use_expo_modules!`, calls `get_folly_config`). Proposed handle: the failure propagates; the sweep includes every podspec of the Expo SDK 57 and 58 templates and of the reference apps | +| 11 | A, `ENV` | a podspec reads a variable other than the two (`USE_FRAMEWORKS`, `RNS_GAMMA_ENABLED`, `USE_HERMES`) | nobody at build: unset, as the trial ruled | **owner's call.** Proposed accept: the names read are listed per library in the log and in `doctor --report`, not on the terminal; troubleshooting says, present tense, that rn-xtool reads podspecs with only `RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED` set. Alternative: one `ℹ` line per library at the scaffold step | +| 12 | A, `spm_dependency` | a podspec declares a SwiftPM dependency through React Native's helper | user: the scaffold refuses the library: `uses spm_dependency(url: …, products: …), which rn-xtool does not map yet` | handle (the refusal); support is deferred to the block whose library needs it | +| 13 | A, `pod` present | `pod ipc spec` keeps React Native's helpers stripped, so `defined?(install_modules_dependencies())` and `respond_to?(:install_modules_dependencies, true)` are false and react-native-webview, async-storage, keychain, video take their old-architecture branch, unlike the shim; this is today's behaviour too | nobody: the scaffold differs from a machine with only Ruby | **owner's call.** Proposed accept: doctor's ruby line says `pod` is used when present; troubleshooting says so in the present tense. Alternative: prefer the shim over `pod` (the decision keeps `pod` first) | +| 14 | A, Podfile globals | `$VCEnableLocation`, `$VCEnableFrameProcessors`, `$RNVideoUse…` are undefined | nobody: the podspec takes its default branch | accept: troubleshooting says, present tense, that podspecs read as with a Podfile that sets no globals (vision-camera's location APIs on, frame processors only when react-native-worklets-core is installed) | +| 15 | A, identity | Ruby evaluates `s.name = package['name']`, so the model's name differs from today's literal reading and targets would be renamed (fix 28 notes react-native-app-auth and react-native-webview) | user: persisted patches and codegen names no longer match | handle: `name`, `module_name`, `version` keep `readPodspecNames`' literals first (A.6); the sweep asserts every target name is unchanged | +| 16 | A, project state | a podspec reads the app's state (reanimated's static feature flags in the app's `package.json`, vision-camera's check for react-native-worklets-core), so a persisted scaffold keeps the state of the day it was written | nobody until the feature misbehaves | accept: troubleshooting says to delete the library's patch after changing its feature flags or installing an optional sibling (as library compatibility row 45) | +| 17 | A, one process per podspec | CocoaPods evaluates every podspec in one process; a podspec that relies on a global another one set reads it unset | nobody | accept: none of the 35 scanned podspecs does (fact 9); the sweep would show a new one | +| 18 | A, side effects | the shim runs a library's Ruby and `node` scripts on the user's machine at scaffold time | nobody | accept: how-it-works says, present tense, that rn-xtool runs a library's podspec as CocoaPods runs it on a Mac, with the same trust as installing the library | +| 19 | A, output | a podspec prints (vision-camera's thanks, `Pod::UI.puts`) | nobody: the model goes to a file; the prints go to the log | handle: test with a podspec that prints braces | +| 20 | A, consume, platforms | `ios`-scoped attributes are ignored today on the `pod` path (fact 6), and `osx`/`tvos` ones must stay out | user: react-native-svg's macOS files in sources, or its iOS excludes missing | handle: A.6's merge, tested with svg 15.16.0's podspec on both paths | +| 21 | A, consume, keys | a key that changes a CocoaPods build but not the scaffold (`script_phases`, `prepare_command`, `info_plist`, `module_map`) | user: a `!` warning naming the key and the library | handle: the scaffold's warnings list such keys; metadata keys are ignored as today | +| 22 | A, subspecs | nested subspecs, `default_subspecs = :none`, a subspec depending on a sibling subspec, fix 20's dropped subspecs | user: a wrong source set (caught by C1 only against the same model) | handle: tests with the gesture-handler, screens and vision-camera fixtures on the shim | +| 23 | A, two readers in a team | one developer without Ruby persists a scaffold; another, with Ruby, builds with it | the second developer: `⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool regenerates it` | **owner's call.** Proposed handle: the marker records the reader (A.9) and `scaffoldPatchWarnings` compares. Alternative: accept, documented | +| 24 | A, cost | one Ruby process per podspec, plus the `node` calls some make | user: seconds added to `rn-spm` | accept: the model is memoized per run (`readPodspecCached`); the proof records the time | +| 25 | A, revision | revision 7 → 8: every persisted scaffold gets the "older rn-xtool scaffolder" warning | user: one `⚠` per persisted patch until regenerated | accept: RELEASING's rule; the CHANGELOG's Upgrading section says to delete and rebuild | +| 26 | A, shipping | the shim is missing from an installed React Native 0.88 (patch not applied), or the copies drift apart | user: `⚠ the podspec reader's Ruby shim is missing from ; using the reduced reader`; maintainers: the byte tests | handle: the patch adds the file; the "patched RN files carry the patch" test gets fix 29's hunk | +| 27 | A, reduced reader in use | the JavaScript evaluator's known limits remain on a machine without Ruby | user: the fixed `⚠` line on every build | accept: the line is the decision; C and the class checks run whatever the reader | +| 28 | A, model fields | the regex path's internal fields (`__unresolved__`, `__header_dir_scopes__`) are absent from the shim's JSON | nobody: the consumer derives them from the layers | handle: the sweep compares the two models field by field | +| 29 | A, rn-xtool's other readers | the early checks and the resource reader keep their TypeScript line readers, which may disagree with the shim (a dependency under a Ruby condition) | user: an early refusal for a pod the scaffold does not use, or none for one it does | **owner's call.** Proposed defer to alpha.9 ("one podspec model for every reader"); the sweep lists the disagreements meanwhile | +| 30 | B1 pass 1 | an app-own quote include resolves nowhere (F2) | user in `doctor --project` and seconds after `build` starts: `✖ : imports "AppDelegate.h", which is not in ` | handle: fixture of the root-group layout | +| 31 | B1, header map | a quote include of an app header that lives in another folder | nobody: resolved by name, as Xcode's header map and the forwards do | handle: test with headers at the root of the group tree and in the app folder | +| 32 | B1 pass 1, before staging | an angle include into React Native's or a library's headers cannot be checked yet | user in doctor: one `ℹ` with the count, "checked at build" | handle | +| 33 | B1, conditions | `__has_include` chains (codegen's `RCTAppDependencyProvider.h` shape), `#ifdef RCT_NEW_ARCH_ENABLED`, `#if TARGET_OS_OSX` | nobody for a branch not taken; a condition B1 cannot evaluate never makes an error | handle: tests per form | +| 34 | B1, text forms | an include in a comment or under `#if 0`; an include built from a macro | nobody | handle (comments, `#if 0`); accept (macro includes are not checked; B2 compiles them) | +| 35 | B1, `@import` | a module B1 cannot place | nobody in B1; B2 compiles it | handle: B1 never errors on `@import` | +| 36 | B1, generated headers | `App-Swift.h`, `-Swift.h` | nobody | accept: the build generates them; B2's hop 2 writes the App's | +| 37 | B1 pass 2, certainty | an angle include resolves in Swift Build through a folder B1's list lacks (a dependency target's header folder SwiftPM adds), so B1 would stop a working app | user: a false stop | **owner's call.** Proposed handle: pass 2 and B2 share one include-list function, tested against Swift Build's response files (row 39); a miss is an error only when its first path component names no target of the package graph, else a `⚠` that leaves the verdict to B2 | +| 38 | B1, where it runs | `doctor --project` and the drift watch have no toolchain | nobody | handle: B1 is TypeScript over files only (fact 18) | +| 39 | B2, command lines | rn-xtool's flags differ from Swift Build's and the precheck stops a file that `xtool-build` compiles | user: a false stop | handle: a golden test against the App target's response files of the bare 0.85–0.88 references, the Objective-C fixture and an Expo 58 app with a bridging header. **Owner's call** on an escape: proposed `rn-xtool build --skip-precheck`, printed with `⚠`; alternative none | +| 40 | B2, false pass | the flags differ the other way | user at `xtool-build`, as today | accept | +| 41 | B2, toolchain | `clang`, `swiftc` or the iPhoneOS SDK cannot be found | user: a stop naming the tool and `rn-xtool setup` | handle; doctor already fails on `swift` and `darwin-sdk` | +| 42 | B2, module cache | a stale cache after a React Native or toolchain change ("module file out of date") | user: a stop, or nothing after the retry | handle: the cache is keyed by React Native version and toolchain; one retry without it; `--clean` removes it | +| 43 | B2, Swift modules | a Swift file imports a module SwiftPM builds from Swift (Expo, `ExpoModulesCore`) | user: `ℹ precheck — imports , which SwiftPM builds: checked by xtool-build` | accept: an Expo app's `AppDelegate.swift` is never prechecked; handle the line | +| 44 | B2, clang modules | Swift imports a clang target without a module map on disk (`ReactAppDependencyProvider`, `ReactCodegen`; SwiftPM synthesises theirs at build) | nobody: synthesised by SwiftPM's rule into `.precheck/`, or the file skipped with `ℹ` | handle: never an error; the builder picks synthesis or skip | +| 45 | B2, `App-Swift.h` | an Objective-C file imports the App's Swift header and hop 2 did not write it | user: one `ℹ` naming the files not checked | handle | +| 46 | B, target shape: xcconfig | `HEADER_SEARCH_PATHS`, defines or the C++ standard come from an xcconfig (`baseConfigurationReference`); the manifest lacks them, and B mirrors the manifest, so the errors look like rn-xtool's | user: `⚠ sets HEADER_SEARCH_PATHS, … for the app target; rn-xtool does not read xcconfig files` at doctor and build start | **owner's call.** Proposed handle (the `⚠` only; reading xcconfigs is a later block) | +| 47 | B, target shape: synchronized folders | an Xcode 16 synchronized folder group holds the app's sources; nothing is in the Sources phase | user: a refusal at doctor and build start naming the group | **owner's call.** Proposed handle (the refusal); reading such groups is a later block | +| 48 | B, per-file flags | the app target's per-file `COMPILER_FLAGS` (`-fno-objc-arc`) are not read | user at precheck or `xtool-build`, the same way | accept: the trial's ruling; B2 uses the manifest's flags | +| 49 | B2, time | the first precheck builds React Native's clang modules into its cache | user: a slower first build | accept: measured in the proof; parallel and `nice` | +| 50 | B2, location | the error is in a library header (F4: `hash_combine.h`) while the cause is the app's flags | user: clang's include stack, starting at the app's file | handle | +| 51 | B2, warnings | the app's warnings | user at `xtool-build`, once | accept: the precheck prints errors only | +| 52 | B2, beyond syntax | a file passes `-fsyntax-only` and fails at code generation or link | user at `xtool-build`, as today | accept | +| 53 | B, Expo bridging header | the prebuild's bridging header imports something its paths do not reach | user: B1 pass 2 or B2, after prebuild | handle: the Expo 58 bridging-header fixture | +| 54 | B2, manifest planning | the generated manifest is refused by SwiftPM's planning (an executable App target as in F1, an invalid header layout) | user at `xtool-build`'s first seconds today | **owner's call.** Proposed handle: `swift package describe --type json` in the precheck. Alternative: defer to alpha.9 | +| 55 | B, anti-goal | a check stops a project that builds today | user: a false stop | handle: Verification runs B on every reference app and on the production app with no stop before release | +| 56 | C1, fresh scaffold | the globs match a compiled file no target lists, or a target lists a file the globs do not match | user at `rn-spm`: `✖ : its podspec's source_files match , which its Package.swift does not compile` (and the converse) | handle | +| 57 | C1, persisted scaffold | a manifest applied from `patches/` differs from the globs: stale, or a deliberate hand edit (a promised feature) | user: `⚠ patches/: …` | **owner's call.** Proposed `⚠` (a hand edit is legitimate). Alternative: error unless the patch carries a marker that says the list was edited | +| 58 | C1, scaffolder exclusions | `.metal` off Darwin, the scaffold's own files, `include/` | nobody: the scaffolder exports the list, and C1 subtracts it | handle: tests with a `.metal` file and a library with real sources under `include/` | +| 59 | C1, glob semantics | `Dir.glob` and `micromatch` differ (`**`, braces, dotfiles, case, symlinks) | user: a false difference, or a missed one | handle: the expected set uses Ruby's `Dir.glob` with CocoaPods' flags when Ruby runs; tests on each form | +| 60 | C1, headers | a header the globs match is not in the manifest | nobody | accept: headers are relocated by design; the compile reports a missing one | +| 61 | C1, scope | self-managed `Package.swift` and Expo modules are not compared | nobody | accept | +| 62 | C1, reduced reader | the expected set comes from the same reduced model, so a reader error like F6's is invisible to C1 | nobody at C1 | accept: row 27's `⚠` says the reduced reader ran; C2, C3 and the codegen guard still run | +| 63 | C2, object | `.o` is missing or unreadable | user: `ℹ classes of not checked: ` | handle | +| 64 | C2, no class | a target lists `.m`/`.mm` sources with a non-category `@implementation` and its object defines no class | user: `✖ compiled Objective-C files and defines no class: `; the app is removed | handle | +| 65 | C2, legitimate none | every `@implementation` sits under a platform guard false on iOS (macOS-only code), so the error of row 64 would stop a working app | user: a false stop | **owner's call.** Proposed handle: the error names the target, and a `knownLimits.allow` entry `no-objc-classes:` turns it into a `⚠`. Alternative: `⚠` always | +| 66 | C2, Swift | a mixed target's classes are Swift (`_TtC…`, `@objc` names) | nobody: they count | handle | +| 67 | C3, not linked | a target defines classes in its object and none reaches the App binary or a framework | user: `✖ 's classes are not in the app: it was not linked`; app and `.ipa` removed | handle | +| 68 | C3, frameworks | a self-managed dynamic product holds the classes | nobody: `Frameworks/*` count | handle | +| 69 | C3, symbols | a stripped binary, or `llvm-nm` missing | user: `ℹ` (as the codegen guard), or doctor's `llvm-nm` failure | accept | +| 70 | C, install | `install` rebuilds from `.build` | user: the same checks before installing | handle: `checkedApp` runs C2 and C3 | +| 71 | D1, open | `ios-xtool/logs/` cannot be written (permissions, disk full) | user: one `⚠ Could not write the log (); the command goes on` | handle | +| 72 | D1, clean | `build --clean` removes `ios-xtool/`, the running log with it | nobody | handle: `logs/` is kept; test | +| 73 | D1, children | a child with inherited stdio (`xtool dev build`, `xtool dev run`) bypasses the log; with a pipe, xtool loses its terminal | user: an incomplete log | handle: every runner tees (test over the runners); accept that xtool's output is no longer colored | +| 74 | D1, crash or Ctrl-C | the log ends mid-line | nobody | handle: lines are written synchronously; the signal is written last | +| 75 | D1, `start` | Metro runs for hours | user: a large file | **owner's call.** Proposed: `start` logs rn-xtool's lines only, not Metro's stream | +| 76 | D1, concurrency | `build` and `start` at once | nobody: one file each (pid in the name) | handle | +| 77 | D1, rotation | the ten most recent per command are kept | user: an older log is gone | accept: present tense in troubleshooting; the owner may change N | +| 78 | D1, privacy | logs hold the Apple ID, UDIDs, IPs, paths | user, if they paste one | **owner's call.** Proposed accept: the logs are never committed (`ios-xtool/.gitignore`), the guide and troubleshooting say to share `doctor --report`, and `doctor --report` adds the last 60 lines of the newest build log through `redact`. Alternative: no log in the report | +| 79 | D1, commands outside a project | `setup`, `auth`, `doctor` without a project | nobody: no log | **owner's call.** Proposed accept (no log). Alternative: `~/.cache/rn-xtool/logs/` | +| 80 | G1, the filter | it hides a line that matters | nobody on the terminal; the log holds it | handle: only the exact text; one count line at the end of `xtool-build` | +| 81 | D2, packing | xtool drops or rewrites a custom Info.plist key | rn-xtool: the packed-app check fails every build | handle: the device spike first (open question 1); test on the packed app | +| 82 | D2, Lookup | installd does not return a custom key in `Lookup` | rn-xtool: no install could be verified | **owner's call** if the spike says so (open question 1) | +| 83 | D2, mismatch | installd reports Complete and the iPhone keeps the old build (F7) | user: `✖ The iPhone kept the app built at ; this build is …` | handle: tests with a fake installd | +| 84 | D2, Lookup fails | the Lookup itself fails | user: today's `VerifyFailedError` | accept | +| 85 | D2, not installed | the bundle id is not on the iPhone after Complete | user: today's error | accept | +| 86 | D2, USB Lookup | usbmuxd or the pair record cannot be read after `xtool dev run` | user: `⚠ installed over USB, not verified: ` | **owner's call.** Proposed `⚠` (xtool reported success). Alternative: failure | +| 87 | D2, stale `.ipa` | `xtool dev build --ipa` reports a path to an older `.ipa` | user: a stop before the upload, naming both stamps | handle | +| 88 | D2, same build again | `install` twice | nobody: the same stamp passes | accept | +| 89 | D2, every build differs | the Info.plist changes on every `generate`, so xtool repacks and re-signs | nobody | accept: no source is recompiled for it | +| 90 | D2, visible key | the app's code can read `RNXtoolBuildStamp` | nobody | accept: namespaced, harmless | +| 91 | D2, `run` | `run` skips the install on fingerprints alone | user: an old app after `run` | handle: `installedStamp` must equal `buildStamp` | +| 92 | D2, old state | the state was written by alpha.7 (no `buildStamp`) | user: `ℹ built by an older rn-xtool: rebuild to verify the install` | handle | +| 93 | D3, same iPhone on USB | the four Wi‑Fi tries fail and the iPhone is on USB | user: the one announce line, then the USB install with D2's check | handle | +| 94 | D3, another iPhone | another iPhone is on USB | user: the Wi‑Fi error and both UDIDs; nothing installed | handle | +| 95 | D3, none | no iPhone on USB | user: today's error, "and no iPhone is connected by USB" | handle | +| 96 | D3, interrupted `Install` | the link died after `Install` was sent | user: today's `InstallInterruptedError` | **owner's call.** Proposed keep (no automatic retry). Alternative: retry over USB, since D2 now verifies the result | +| 97 | D3, other errors | a refused pair record, several iPhones, the scan refused | user: today's messages | accept: not "does not reach" | +| 98 | D3, `xtool dev run` | it rebuilds what is out of date and launches the app | user: the app opens | accept | +| 99 | E, packing | `AGENTS.md` is not in the package | maintainers: `tests/packageFiles.test.ts` | handle | +| 100 | E, command | `agent-guide` cannot find the file (a checkout without a build) | user: an error naming the path | handle | +| 101 | E, drift | the guide names steps or folders that changed | maintainers: the guide test | handle | +| 102 | E, user files | a tool deletes `patches/`, the config or the lock after reading the guide | user: their fixes gone | handle: the guide names them as the user's and never to be deleted; a test checks the list | +| 103 | E, `docs/` | the guide's links point at files not in the package | user offline: dead links | **owner's call.** Proposed handle: ship the user pages (E), not `docs/design/`, `docs/research/`, `docs/upstream/`; RELEASING step 4 lists them | +| 104 | F1, tarballs | about 30 more tarballs to fetch | CI: time and the existing fetch rules (two tries, integrity) | handle: `tests/tarballs.json`; the proof records the size | +| 105 | F1, third-party code | the sweep runs the libraries' Ruby and `node` scripts in CI | nobody | accept: the CI job has a read-only token and no secrets | +| 106 | F1, no Ruby | the runner has no Ruby | CI: a failure, not a skip | handle | +| 107 | F1, goldens | a deliberate reader change updates many goldens | maintainers | accept: reviewed in the same commit | +| 108 | F1, coverage | a library outside the set hits a shim gap | user: row 4's stop | accept: the report adds it to the set | +| 109 | F2, fixture | a CLI template change breaks the Objective-C overlay | the drift issue for that line | handle | +| 110 | F2, network | React Native's headers artifact cannot be downloaded | the line reads `unknown (could not run)` | accept: the drift watch's existing rule | +| 111 | F2, no compile | the drift watch never runs B2 | nobody | accept: the drift watch's documented limit | +| 112 | F3, scope | scoped package names (`@scope/name`, 122 in the docs) | maintainers | **owner's call.** Proposed: they pass and the user form is refused (the alpha.7 release listed only the user-form `@import` as a contributor; whether GitHub links `@org/name` as a team mention was not checked). Alternative: refuse every `@` outside code | +| 113 | F3, timing | GitHub notifies when the PR or release is published, before CI runs | the person mentioned | accept: RELEASING runs the check on the body and notes files before `gh pr create` and `gh release create`; CI flags what is left | +| 114 | F3, UI text | release notes typed in GitHub's page | nobody | accept: RELEASING says to publish notes from the checked file only | +| 115 | F3, existing text | the fifteen user-form mentions of fact 32 | maintainers: the new test | handle: fixed in the same task | +| 116 | G2, doctor's count | "N to download" while the cache holds the files | user: a wrong line | handle: G.2, after the builder checks whether the build downloads again | +| 117 | G3, include order | the fix for 0.85 changes another line's resolution | user: a compile error on 0.86–0.88 | handle: tests on the four lines' header trees | +| 118 | G4, DevTools | `j` fails on Linux | user | accept: the troubleshooting section | + +## Verification + +- **Unit tests**, each written red first, own the `handle` rows (the plan names them). `npm test`, `npm run lint`, + `npm run scan:private` and the new mention check are green and clean; the byte tests of the scaffolder run, not skip. +- **The reader sweep** (F1) passes in CI with Ruby, and its goldens are reviewed by the owner once, with the + differences between the two readers listed per library. +- **Downloads and builds need the owner's approval first.** The sweep's tarballs (tens of MB), React Native's headers + artifact for the drift target, and the builds below. +- **Spike gate (device, before group D2 is built):** a bare 0.88.1 build with a hand-added `RNXtoolBuildStamp` in its + Info.plist; check the key in the packed `App.app` and in `Lookup`'s answer over Wi‑Fi and over USB (open question 1). +- **Build-only proofs**, on copies of the reference apps: + 1. The Objective-C fixture app with seeded faults, one per build: a missing app header (F2), the bare include dirs + removed (F3), `CLANG_CXX_LANGUAGE_STANDARD` removed (F4), an `@import` in a header its `.mm` includes (F5). Each is + reported by B1 or B2 before `xtool-build`, and the time from `generate` to the report is recorded (target: about + 30 s). + 2. react-native-screens 4.24.0 with the reduced reader forced and a podspec idiom it cannot read added: C1, C2 or the + codegen guard stops the build before install. + 3. The bare 0.85, 0.86, 0.87 and 0.88 references (Swift templates) and the Expo SDK 57 and 58 references build with + no new stop and no new `⚠` except the ones this design lists; their scaffolds under the shim match the sweep's + goldens. +- **Device pass for the owner** (free team): + - the production bare React Native 0.85.0 app with an Objective-C app target and 20 libraries builds with alpha.8 + (no hand fix, scaffolds regenerated at revision 8), installs over Wi‑Fi with `Installed … (build )`, installs + over USB with the stamp verified, and runs: it opens past its start screen, react-native-screens' screens show, + and Fast Refresh works; + - with Wi‑Fi off on the iPhone and the cable in, `install --network` prints the USB announce line, installs over USB + and verifies the stamp; + - `ios-xtool/logs/` holds one log per command run, each ending with its status; + - a clean Expo SDK 58 template and the bare React Native 0.88.1 reference build, install with the stamp verified, and + launch with Fast Refresh, as in alpha.7. + + Until the owner confirms these, the CHANGELOG calls the stamp and the USB retry build-verified only. + +## Open questions + +1. **Does a custom Info.plist key survive xtool's packing, and does installd return it in `Lookup`?** Proposed: the + spike gate answers both before group D2 is built, and lists every attribute `Lookup` returns for a development app. + If xtool drops the key, the stamp needs another carrier in the signed bundle; if installd does not return it, the + owner picks, from that list, an attribute that changes with every build. Either way the D2 rows stay as written. +2. **The owner's calls in the failure walk**, each with a proposed ruling: rows 5, 10, 11, 13, 23, 29, 37, 39, 46, 47, + 54, 57, 65, 75, 78, 79, 82, 86, 96, 103 and 112. +3. **The sweep's library list** (F1): the builder proposes about 30 (the production app's 20 and the most installed + React Native libraries with an iOS podspec), the owner approves it with the size it adds to CI. +4. **N for the logs** (D1): proposed 10 per command. + +## Left to the builder + +- Exact names: the shim's file and its JSON keys, the `precheck` step, the env variable of row 5, the flag of row 39, + the `knownLimits` key of row 65, the state fields, the log file pattern beyond the decided folder. +- The Ruby floor the shim supports, from what it uses. +- Whether `get_folly_config` loads React Native's `helpers.rb` or holds the shared values. +- Whether B2 synthesises module maps for clang targets or skips the Swift file (row 44). +- How B2 finds the iPhoneOS SDK inside xtool's Swift SDK bundle. +- Whether B1 pass 2's React Native half can run right after `rn-artifacts` instead of after `generate`. +- The Objective-C fixture's contents (written for rn-xtool from React Native's pre-0.77 template, MIT) and how the drift + watch overlays it on the CLI's project. +- The wording of the stops and lines not quoted above, and of the docs sections. From 5fa2fc14650e10a7e2ce2d342f7b3388f424afb3 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 10:51:51 -0600 Subject: [PATCH 02/53] docs: close the alpha.8 design rulings --- .../plans/2026-11-06-alpha-8-fail-early.md | 69 ++-- .../2026-11-06-alpha-8-fail-early-design.md | 306 ++++++++++++------ 2 files changed, 246 insertions(+), 129 deletions(-) diff --git a/docs/design/plans/2026-11-06-alpha-8-fail-early.md b/docs/design/plans/2026-11-06-alpha-8-fail-early.md index c0bbf5f..608894d 100644 --- a/docs/design/plans/2026-11-06-alpha-8-fail-early.md +++ b/docs/design/plans/2026-11-06-alpha-8-fail-early.md @@ -1,58 +1,71 @@ # Release 0.1.0-alpha.8, fail early: plan skeleton -Status: skeleton, 2026-11-06. It lists the task groups of the -[alpha.8 design](../specs/2026-11-06-alpha-8-fail-early-design.md) and the failure-walk rows each group owns. The -tasks, their tests and the execution order are written after the owner approves the design and rules on its open -questions; the owner's calls among these rows may move a row to another group or to alpha.9. +Status: skeleton, 2026-11-06. The [alpha.8 design](../specs/2026-11-06-alpha-8-fail-early-design.md) is approved, with +its rulings R1–R13. This file lists the task groups and the failure-walk rows each group owns; every row 1–118 has +exactly one owner. The tasks, their tests and the execution order are written next. + +Two gates come before the groups that depend on them: + +- **The device spike** (R9) runs first of all: it decides the build stamp's carrier (`RNXtoolBuildStamp`, then + `CFBundleGetInfoString`, then another free-text key `Lookup` returns), so group D2 is built on its result. +- **The response-file capture** (R12) runs before group B's golden test: reference builds on the owner's machine, one at + a time (approved by the owner on 2026-11-06), whose App-target response files are normalised (home folders become + `/home/me`) before they enter `tests/fixtures/`. ## A. The podspec reader runs real Ruby (design A, scaffolder fix 29) Rows 1–28: the Ruby probe and its lines in `build`, `doctor` and `setup` (1, 2), the fixed environment (3), the loud -failures and the escape (4–8), `node` calls (9), the autolinking callers (10), `ENV` names (11), `spm_dependency` (12), -the `pod` path (13), Podfile globals (14), identity fields (15), project state (16), one process per podspec (17), -side effects (18), output (19), the `ios` merge in `flattenSubspecs` (20), build keys the scaffold does not apply (21), -subspecs (22), the reader in the scaffold marker (23), cost (24), the revision bump to 8 (25), shipping in the vendored -copy and both 0.88 patches (26), the reduced reader's `⚠` (27), model fields (28). +failures and `RN_XTOOL_PODSPEC_READER=reduced` (4–8, R2), `node` calls (9), shim failures propagating from the +autolinking callers (10, R3), `ENV` names in the log and `doctor --report` (11, R4), `spm_dependency` (12), +`pod ipc spec` removed from the reader (13, R1), Podfile globals (14), identity fields (15), project state (16), one +process per podspec (17), side effects (18), output (19), the `ios` merge in `flattenSubspecs` (20), build keys the +scaffold does not apply (21), subspecs (22), the reader in the scaffold marker and `scaffoldPatchWarnings` (23, R5), +cost (24), the revision bump to 8 (25), shipping in the vendored copy and both 0.88 patches (26), the reduced reader's +`⚠` (27), model fields (28). ## B. The app target fails in seconds (design B) Rows 30–55: B1 pass 1 in `doctor --project` and at `build` start (30–32), conditions, text forms, `@import` and -generated headers (33–36), pass 2's certainty rule (37), B1 without a toolchain (38), B2's command lines and their -golden against Swift Build's response files (39, 40), toolchain and module cache (41, 42), Swift and clang modules and -`App-Swift.h` (43–45), the app target's shapes: xcconfig, synchronized folders, per-file flags (46–48), time, error -location, warnings, beyond syntax (49–52), the Expo bridging header (53), manifest planning (54), the anti-goal run on -every reference app (55). +generated headers (33–36), the shared include-list function and pass 2's certainty rule (37, R6), B1 without a +toolchain (38), B2's command lines, their golden against the captured response files, and `--skip-precheck` (39, R2, +R12), the false pass (40), toolchain and module cache (41, 42), Swift and clang modules and `App-Swift.h` (43–45), the +app target's shapes: the non-CocoaPods xcconfig `⚠`, the synchronized-folder refusal, per-file flags (46–48, R6), time, +error location, warnings, beyond syntax (49–52), the Expo bridging header (53), `swift package describe` in the +precheck (54, R6), the anti-goal run on every reference app (55). ## C. Scaffold fidelity (design C) -Rows 56–70: the glob comparison for fresh and persisted scaffolds, the scaffolder's exclusion list, glob semantics, -headers, scope and the reduced reader (56–62), the class check per target object (63–66), the class check in the packed -app (67–69), both in `install` (70). +Rows 56–70: the glob comparison for fresh scaffolds and the `⚠` for persisted ones (56, 57, R7), the scaffolder's +exclusion list, glob semantics, headers, scope and the reduced reader (58–62), the class check per target object and the +`no-objc-classes:` allow key (63–66, R7), at least one class per target in the packed app (67–69, R7), both in +`install` (70). ## D. Reliability: logs, build stamp, USB retry (design D) -Rows 71–79: logs on disk per command (open, clean, children, signals, `start`, concurrency, rotation, privacy, commands -outside a project). +Rows 71–79: logs on disk per command (open, clean, children, signals, `start`'s own lines only, concurrency, ten kept, +the redacted tail in `doctor --report`, no log outside a project; R8, R13). -Rows 81–92: the build stamp (packing and `Lookup`, gated by the device spike first; mismatch; existing Lookup errors; -the USB Lookup; the stale `.ipa`; repeat installs; per-build changes; the visible key; `run`; states from alpha.7). +Rows 81–92: the build stamp, on the device spike's carrier (81, 82, R9), the mismatch, the existing Lookup errors, the +`⚠` for an unverified USB install (86, R9), the stale `.ipa`, repeat installs, per-build changes, the visible key, +`run`, states from alpha.7. -Rows 93–98: the USB retry after the four Wi‑Fi tries. +Rows 93–98: the USB retry after the four Wi‑Fi tries; no automatic retry after an interrupted `Install` (96, R9). ## E. The guide (design E) -Rows 99–103: `AGENTS.md` in the package, `rn-xtool agent-guide`, the guide test, the user's files, the user docs -shipped in the package. +Rows 99–103: `AGENTS.md` in the package, `rn-xtool agent-guide`, the guide test, the user's files, the user doc pages +shipped and listed in RELEASING step 4 (103, R10). ## F. Guards on rn-xtool (design F) -Rows 104–108 and 29: the permanent reader sweep in CI, with the TypeScript readers' disagreements listed (29, deferred -to alpha.9 for the fix). +Rows 104–108 and 29: the permanent reader sweep in CI over R11's set (the 30 most-downloaded React Native libraries with +an iOS podspec, the trial's failing versions, the Expo SDK 57 and 58 template podspecs, the reference apps' libraries), +with the TypeScript readers' disagreements listed (29, the fix deferred to alpha.9). Rows 109–111: the Objective-C target in the daily drift watch. -Rows 112–115: the mention check (script, test, `pull_request` workflow, RELEASING steps) and the fifteen user-form -mentions fixed. +Rows 112–115: the mention check (script, test, `pull_request` workflow, RELEASING steps; scoped names pass, R10) and +the fifteen user-form mentions fixed. ## G. Follow-ups (design G) diff --git a/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md index ec5b670..b9baf85 100644 --- a/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md +++ b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md @@ -1,8 +1,9 @@ # Release 0.1.0-alpha.8: fail early, never silently (design) -Status: design, 2026-11-06, draft for Willy's approval. It follows the real-app trial of 2026-11-05/06: a production -bare React Native 0.85.0 app with an Objective-C app target and 20 libraries, built, installed and launched with -0.1.0-alpha.7 after seven fixes. The decisions below were taken with the owner on 2026-11-06 and are recorded, not +Status: design, approved by the owner on 2026-11-06, with the rulings below. It follows the real-app trial of +2026-11-05/06: a production bare React Native 0.85.0 app with an Objective-C app target and 20 libraries, built, +installed and launched with 0.1.0-alpha.7 after seven fixes. The decisions below were taken with the owner on +2026-11-06, and the rulings on the questions the draft left open were taken the same day; both are recorded, not reopened. The trial's ledger is kept outside the repo's tracked files; what this design rests on is restated here with its sources. Nothing that identifies the app is part of this document. @@ -56,8 +57,9 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: `Pod::UI`, `ENV` as a controlled environment (`RCT_NEW_ARCH_ENABLED='1'`, `RCT_HERMES_V1_ENABLED='1'`, every other variable unset), and React Native's helpers as no-ops that record what matters. It dumps the evaluated spec as JSON in `pod ipc spec`'s model, so the existing consumer is reused. Anything the shim does not model fails loudly with the - method and the podspec. The JavaScript evaluator stays as the fallback without Ruby, with a fixed `⚠` line; `pod ipc - spec` stays preferred when a real `pod` exists. `doctor` and `setup` report Ruby. A `podspecEnv` config is a possible + method and the podspec. The JavaScript evaluator stays as the fallback without Ruby, with a fixed `⚠` line. The shim + is the reader whenever `ruby` exists: rn-xtool no longer runs `pod ipc spec` (ruling R1). `doctor` and `setup` + report Ruby. A `podspecEnv` config is a possible later mechanism, not built now. - **B. Fail in seconds, both halves.** (1) Static `#import`/`#include` resolution of the app target's own sources (Objective-C/C++ and the bridging header; ``, `` and `"X.h"`; with the include paths the manifest will @@ -83,6 +85,53 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: definition of 'RCTDependencyProvider'` warning; a docs line on React Native DevTools' `chrome-sandbox`. - **Out of scope, deferred to alpha.9:** a scaffold cache in `~/.cache`, parallel scaffolding. +## Rulings (2026-11-06) + +The draft left these questions open; they were ruled the same day, and the design and the failure walk below are +written with them. + +- **R1. The shim is the only Ruby reader; `pod ipc spec` is dropped** (changes decision A and row 13). The `pod` path + strips React Native's helpers before it runs (fact 4), so `defined?(install_modules_dependencies())` and + `respond_to?(:install_modules_dependencies, true)` are false there, and react-native-webview, async-storage, keychain + and video take their old-architecture branch. The shim models the helpers and gives one result on every machine with + Ruby. The JavaScript evaluator stays as the fallback without Ruby. +- **R2. An exit for each new stop that can block a working app** (rows 5 and 39). `RN_XTOOL_PODSPEC_READER=reduced` + forces the reduced reader for one run, and `rn-xtool build --skip-precheck` skips the precheck; each prints a `⚠` + line naming itself, and `doctor --report` records that it was used. A blocked user with no way out abandons the tool + before reporting; the report turns each use into a signal for the maintainers. +- **R3. A shim failure is never swallowed** (row 10): it stops `rn-spm` with the shim's text, also when an autolinking + read hits it. The reader sweep covers every podspec of the Expo SDK 57 and 58 templates and of the reference apps, + so Expo modules are proven before release. +- **R4. The `ENV` names a podspec read** (row 11) are listed per library in the log and in `doctor --report`, not on the + terminal; troubleshooting states which two variables are set. +- **R5. Readers recorded and compared** (rows 23 and 29). The scaffold marker records the reader that wrote it, and + `scaffoldPatchWarnings` warns when a persisted scaffold was written by the other one. One podspec model for every + rn-xtool reader (the TypeScript early checks and resource reader included) is deferred to alpha.9; the sweep lists + their disagreements meanwhile. +- **R6. The app target's checks** (rows 37, 46, 47, 54). B1 pass 2 and B2 share one include-list function; a missing + angle include is an error only when its first path component names no target of the package graph, otherwise a `⚠` + that leaves the verdict to B2. An xcconfig that is not CocoaPods' generated `Pods-*.xcconfig` and sets a setting + rn-xtool reads gives a `⚠`; a synchronized folder group in the app target is refused, naming the group. + `swift package describe --type json` runs in the precheck. +- **R7. Fidelity checks** (rows 57 and 65). A difference in a scaffold applied from `patches/` is a `⚠`, since a hand + edit is legitimate. A `knownLimits.allow` entry `no-objc-classes:` turns the "no Objective-C class" error + into a `⚠`. The packed-app check asks for at least one class per target with Objective-C sources, not for each class + (decision C's weak B). +- **R8. Logs** (rows 75, 78, 79): `start` logs rn-xtool's own lines only; logs are never committed, and `doctor + --report` adds the last 60 lines of the newest build log through `redact`; no log is written outside a project. +- **R9. The stamp and the install** (rows 82, 86, 96). The device spike runs first and decides the stamp's carrier + (below). An unverified USB install is a `⚠`. An interrupted `Install` is not retried automatically. +- **R10. What ships, and the mention rule** (rows 103 and 112). The user doc pages ship (listed in E) and RELEASING + step 4 lists them; `docs/design/`, `docs/research/` and `docs/upstream/` do not. A scoped `@scope/name` passes the + mention check; the bare user form is refused. +- **R11. The sweep's set** (F1): the 30 most-downloaded React Native libraries with an iOS podspec at their current + versions, plus the versions that failed in the trial (react-native-screens 4.24.0, react-native-worklets 0.8.1 and + 0.8.3), plus every podspec of the Expo SDK 57 and 58 templates and the reference apps' libraries. +- **R12. Swift Build's response files** for the precheck's golden test (row 39) do not exist as fixtures. They are + captured from reference builds on the owner's machine, one build at a time (approved by the owner on 2026-11-06), + and normalised (home folders become `/home/me`) before they enter `tests/fixtures/`. +- **R13. Log retention:** the ten most recent logs per command are kept. + ## Goals 1. Every failure the trial met in the app target (F1–F5) is reported before `xtool-build` starts compiling libraries: @@ -102,7 +151,7 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: - The `podspecEnv` config. ENV variables other than the two stay unset; the design records which ones a podspec read. - Installing the `cocoapods` gem, or any gem, through `setup`. - Replacing rn-xtool's TypeScript-side podspec line readers (the early checks in `src/project/earlyChecks.ts`, the - resource reader in `src/pipeline/scaffoldResources.ts`) with the Ruby reader (row 29 proposes a later block). + resource reader in `src/pipeline/scaffoldResources.ts`) with the Ruby reader (row 29: alpha.9). - Compiling libraries in the precheck. B2 compiles only the app target's own sources. - Reading xcconfig-based build settings or Xcode 16 synchronized folders into the generated project. This block only makes them visible (rows 46 and 47). @@ -124,7 +173,8 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: regenerated from the vendored copy by the recipe in `docs/RELEASING.md` ("Scaffolder changes"), never edited as text. A new shim file is a new file in both. - RELEASING's revision rule: a change to what a scaffold writes bumps `RN_XTOOL_SCAFFOLD_REVISION` and - `SCAFFOLD_REVISION` together (now 7, `vendor/rn-spm/spm/scaffold-package-swift.js:139`, `src/pipeline/patches.ts:362`). + `SCAFFOLD_REVISION` together (now 7, `vendor/rn-spm/spm/scaffold-package-swift.js:139`, + `src/pipeline/patches.ts:362`). - `npm run scan:private` is clean on every commit; no fixture holds a path, name or identifier of the production app. - `doctor --project` keeps working without Swift, xtool or a network (the drift watch runs it on a runner without Swift). @@ -179,8 +229,10 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: `rncore_pod` and `mark_as_react_native_build`. `install_modules_dependencies` appends compiler flags and `pod_target_xcconfig` entries and about twenty `s.dependency` lines (`NewArchitectureHelper`, `scripts/cocoapods/new_architecture.rb:75`). -9. **What real podspecs call.** A static scan (Ruby's `Ripper`, nothing evaluated) of 35 podspecs: the 15 libraries of - the trial's reader sweep that ship one, the bare 0.88 reference app's libraries, the Expo SDK 57 reference's Expo +9. **What real podspecs call.** A static scan (Ruby's `Ripper`, nothing evaluated) of 35 podspecs: 15 libraries at the + versions the one-off reader sweep of 2026-11-06 read (among them react-native-vision-camera 4.7.3, + react-native-video 6.19.3, react-native-worklets 0.8.3, react-native-reanimated 4.3.4), the bare 0.88 reference app's + libraries, the Expo SDK 57 reference's Expo modules and the podspec fixtures in `tests/fixtures/podspecs/`: - helpers: `install_modules_dependencies` (16 files), `add_dependency` (react-native-gesture-handler, expo-modules-core), `get_folly_config` (Expo's two), `respond_to?(:install_modules_dependencies, true)` (4), @@ -203,9 +255,10 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: `project_header_files`. 10. **What a library's own Ruby does.** react-native-worklets 0.8.3's `scripts/worklets_utils.rb` finds React Native with `` `cd "#{Pod::Config.instance.installation_root}" && node --print "require.resolve(…)"` `` and raises when it - cannot; it runs `system("node …/validate-react-native-version.js …")`; it reads `./src/featureFlags/staticFlags.json` - relative to the working directory, which CocoaPods sets to the podspec's folder. reanimated's reads the app's - `package.json` through `installation_root/..`. These are the values fix 28 leaves out with `!`. + cannot; it runs `system("node …/validate-react-native-version.js …")`; it reads + `./src/featureFlags/staticFlags.json` relative to the working directory, which CocoaPods sets to the podspec's + folder. reanimated's reads the app's `package.json` through `installation_root/..`. These are the values fix 28 + leaves out with `!`. 11. **Ruby on the machine.** The build machine has Ruby 3.3.8. Neither `doctor` nor `setup` mentions Ruby today (`src/commands/doctor.ts`, `src/commands/setup.ts`). 12. **The scaffolder's copies** (fact 11 of the [library compatibility design](2026-11-04-library-compat-design.md), @@ -249,8 +302,9 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: embedded framework (`llvm-nm --defined-only`); a stripped binary gives an `ℹ` line; a missing class removes the packed app and its `.ipa`. `install` runs it again on the app xtool builds before installing (`checkedApp`, `src/commands/install.ts`). -20. **Where a target's object is.** Swift Build writes and links `ios-xtool/.build/out/Products/Debug-iphoneos/.o` - (`EMPTY_TARGETS_DIR`, `src/pods/emptyTargets.ts`). In the trial, `RNScreens.o` defined no Objective-C class. +20. **Where a target's object is.** Swift Build writes and links + `ios-xtool/.build/out/Products/Debug-iphoneos/.o` (`EMPTY_TARGETS_DIR`, `src/pods/emptyTargets.ts`). In the + trial, `RNScreens.o` defined no Objective-C class. 21. **How a scaffold lists its sources** (`scaffold-package-swift.js:1110-1170`, emitted at `:1847-1856`): the podspec's `source_files` globs expanded on disk (`expandSpmSourceGlobs`), `exclude_files` applied with `micromatch`, then the scaffold's own files filtered out (`Package.swift`, `Package@swift-*.swift`, the prefix header, `include/`, the @@ -295,10 +349,10 @@ Release 0.1.0-alpha.8, theme "fail early, never silently". Recorded as decided: (the 15 tarballs of `tests/tarballs.json`, 23.6 MB, into `tests/.cache`), lint, `scan:private`, tests, and the list of skipped tests. 32. **Bare mentions in the tracked markdown** (outside fenced blocks and code spans): four `@import` in user form, not - three: `CHANGELOG.md:47`, `docs/troubleshooting.md:292` and `:918`, and `docs/upstream/react-native-scaffolder.md:498`; - eleven more user-form ones in `docs/design/specs/2026-11-04-library-compat-design.md:44` and `docs/research/` - (`@react-navigation`, `@d11`, and hunk line numbers written `@54`, `@113`, `@170`, `@844`, `@1099`); and 122 scoped - package names (`@scope/name`). + three: `CHANGELOG.md:47`, `docs/troubleshooting.md:292` and `:918`, and + `docs/upstream/react-native-scaffolder.md:498`; eleven more user-form ones in + `docs/design/specs/2026-11-04-library-compat-design.md:44` and `docs/research/` (`@react-navigation`, `@d11`, and + hunk line numbers written `@54`, `@113`, `@170`, `@844`, `@1099`); and 122 scoped package names (`@scope/name`). 33. **What ships.** `package.json` `files` holds no `docs/` (RELEASING step 4 says so); error texts link to `docs/troubleshooting.md` on GitHub (`src/docs.ts`). `docs/` is 1.7 MB, 1.1 MB of it `docs/design/`. @@ -324,10 +378,12 @@ are not proposed again without new facts. 1. **Real Ruby, shimmed CocoaPods (owner's choice).** The system `ruby` evaluates the podspec as CocoaPods does: every local, condition, interpolation, `require_relative` helper and `node` call runs for real. The shim models only the DSL and React Native's helpers, which are small and stable (facts 8 and 9). Ruby is one `apt install` away on - Ubuntu; a machine without it keeps today's reader with a `⚠` line. + Ubuntu; a machine without it keeps today's reader with a `⚠` line. With Ruby, the shim is the only reader: + `pod ipc spec` is dropped (R1), so a machine with CocoaPods reads a podspec as one without it. 2. *Install the `cocoapods` gem through `setup`.* Rejected: native extensions (`ffi`, the `xcodeproj` gem's dependencies) build differently across distros and Ruby versions, `gem install` needs write access to a gem home, - and `pod ipc spec` still lacks React Native's helpers (fact 4 strips them). + and `pod ipc spec` still lacks React Native's helpers (fact 4 strips them), which sends four of the libraries + scanned into their old-architecture branch (R1). 3. *Keep improving the JavaScript evaluator.* Rejected: two silent bugs in one day (F6 and the worklets defines), and every new podspec idiom is another subset to write. It stays as the fallback only. @@ -376,8 +432,10 @@ are not proposed again without new facts. **Hop by hop, for one podspec:** -1. **Choose the path.** `readPodspec` keeps its order with one step added: `pod ipc spec` when a `pod` runs (unchanged, - row 13), else the shim when a usable `ruby` runs, else the JavaScript evaluator. "Usable" is decided once per run: +1. **Choose the path.** `readPodspec` reads with the shim when a usable `ruby` runs, else with the JavaScript evaluator. + `pod ipc spec` is no longer run (R1, row 13): `runPodIpcSpec` and `patchPodspecForPodIpc` leave the vendored + reader, and `unresolvedSourcesReason`'s advice becomes "install Ruby". `RN_XTOOL_PODSPEC_READER=reduced` forces the + JavaScript evaluator for one run (R2, row 5). "Usable" is decided once per run: `ruby` on `PATH`, a version the shim supports (the builder sets the floor from the shim's needs; Ubuntu 22.04's archive has 3.0), and `require 'json'` working. 2. **Run Ruby.** One process per podspec: `ruby `, with @@ -385,7 +443,7 @@ are not proposed again without new facts. `./src/featureFlags/staticFlags.json`, fact 10); - an environment of `PATH`, `HOME`, `LANG` and the two React Native variables, nothing else: no `RUBYOPT`, `BUNDLE_*` or `GEM_*` from the shell, so a project's `Gemfile` or a `bundle exec` shell cannot change the run; - - a 30 s timeout per podspec, as `pod ipc spec` has. + - a 30 s timeout per podspec, as `pod ipc spec` had. 3. **What the shim models.** - `Pod::Spec.new`/`Pod::Specification` with every attribute CocoaPods 1.16 defines (unknown names fail), subspecs (nested), `default_subspec(s)`, `test_spec`/`app_spec` (recorded, never merged), platform proxies `s.ios`, @@ -396,8 +454,8 @@ are not proposed again without new facts. - React Native's helpers of fact 8 as recorders: `install_modules_dependencies` records the call (the scaffolder's React-core marker, today a regex), `add_dependency` records the dependency, `get_folly_config` returns the installed React Native's folly values (read from its `scripts/cocoapods/helpers.rb` when that file loads alone, - else the values the supported lines share), `min_ios_version_supported` returns the value the installed React Native defines, and - `spm_dependency` records its arguments so the scaffold can refuse the library by name (row 12); + else the values the supported lines share), `min_ios_version_supported` returns the value the installed React + Native defines, and `spm_dependency` records its arguments so the scaffold can refuse the library by name (row 12); - `require` of the gems CocoaPods brings and podspecs load (`colored2`) as stubs; `require_relative` of the library's own files runs them; - `ENV` as podspecs see it: the two variables, every other name unset; each name read is recorded. @@ -406,28 +464,32 @@ are not proposed again without new facts. 4. **Fail loudly.** A call to a method or constant the shim does not define, an attribute CocoaPods does not know, a `require` that does not load, an exception the podspec raises itself, or the timeout ends the run with a result naming the podspec, the line and the name: `:: the podspec calls foo(…), which rn-xtool's podspec - reader does not model`. No fallback to the JavaScript evaluator follows (rows 4–8). + reader does not model`. No fallback to the JavaScript evaluator follows (rows 4–8); only + `RN_XTOOL_PODSPEC_READER=reduced` selects it, visibly (R2). 5. **Write the model.** The shim writes the spec as CocoaPods' JSON form to ``, not to stdout (a podspec's own `puts` cannot corrupt it), plus three rn-xtool keys: the `ENV` names read, the helpers called, and whatever `Pod::UI` printed. -6. **Consume it.** `flattenSubspecs` reads it as it reads `pod ipc spec`'s JSON, with one fix shared by both paths: - each layer's `ios` attributes are merged over its own (and `osx`, `tvos`, `visionos`, `watchos` are ignored), as - CocoaPods does for an iOS target (fact 6). `dropSubspecs` (fix 20) applies unchanged. `name`, `module_name` and - `version` keep today's resolution: `readPodspecNames`' literals first (row 15). +6. **Consume it.** `flattenSubspecs` reads it as it read `pod ipc spec`'s JSON, with one fix: each layer's `ios` + attributes are merged over its own (and `osx`, `tvos`, `visionos`, `watchos` are ignored), as CocoaPods does for an + iOS target (fact 6). `dropSubspecs` (fix 20) applies unchanged. `name`, `module_name` and `version` keep today's + resolution: `readPodspecNames`' literals first (row 15). 7. **Tell the caller.** Every caller of the reader learns which path read the podspec and why a run failed. The scaffold turns a failure into its `status: 'error'` with the reason, as for fix 28's refusals. The autolinking callers - (fact 7) no longer swallow a reader failure: it stops `rn-spm` with the same text (row 10). The results file + (fact 7) no longer swallow a reader failure: it stops `rn-spm` with the same text (R3, row 10). The results file records the path per library. 8. **Say which reader ran.** When the JavaScript evaluator read any podspec, `build` prints one fixed line at the `rn-spm` step: `⚠ Ruby was not found (or ), so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does. See …`. `doctor` prints a `ruby` line (`✔ ruby 3.3.8`, or `⚠ not found — podspecs are read with the reduced reader; sudo apt install ruby`), and so does `doctor --project` (it needs no toolchain). `setup` checks Ruby and prints the install command; - it installs nothing. + it installs nothing. When `RN_XTOOL_PODSPEC_READER=reduced` is set, the `⚠` line names the variable instead, and + `doctor --report` says the last build used it. The `ENV` names each podspec read go to the log and to + `doctor --report` (R4, row 11). 9. **Ship it.** The shim is `scripts/spm/read-podspec-shim.rb` in React Native's tree: a new file in `vendor/rn-spm/spm/` and in both 0.88 patches. Scaffolder fix 29 documents it. The scaffolds' output changes (fact 6's `ios` merge, the values fix 28 left out), so the scaffold revision moves from 7 to 8, and each scaffold's - marker records the reader that wrote it. + marker records the reader that wrote it; `scaffoldPatchWarnings` warns when a persisted scaffold's reader differs + from the one this machine uses (R5, row 23). ### B. The app target's checks @@ -450,9 +512,16 @@ nowhere; one under a condition B1 cannot evaluate is never an error. B1 runs twi It knows the app's own files and `HEADER_SEARCH_PATHS`. An app-own quote include that is missing (F2) is an error with the file, the line, the header and where rn-xtool looked. An angle include into React Native's or a library's headers is "not checked yet" while `ios/build/xcframeworks` and the scaffolds are not staged: one `ℹ` line with the - count, in doctor only. + count, in doctor only. The same pass checks the app target's shape (R6, rows 46 and 47): an xcconfig the target or + the project names (`baseConfigurationReference`) that is not CocoaPods' generated `Pods-*.xcconfig` and sets a + setting rn-xtool reads (`HEADER_SEARCH_PATHS`, `GCC_PREPROCESSOR_DEFINITIONS`, `CLANG_CXX_LANGUAGE_STANDARD`, + `SWIFT_OBJC_BRIDGING_HEADER`, `PRODUCT_MODULE_NAME`, `CODE_SIGN_ENTITLEMENTS`, `INFOPLIST_FILE`) gives + `⚠ sets for the app target; rn-xtool does not read xcconfig files`; a synchronized folder group + in the app target is refused, naming the group. 2. **Pass 2, in the precheck step** (below): the include list the manifest has just been given, plus the dependency - products' header folders. A missing include is an error (F3). + products' header folders, from the one include-list function B2 uses. A missing include is an error (F3) when it is + a quote include or its first path component names no target of the package graph; otherwise it is a `⚠` and B2 + decides (R6, row 37). **B2, the precheck.** A new `build` step, `precheck`, after `generate` and before `xtool-build`: @@ -461,7 +530,9 @@ nowhere; one under a condition B1 cannot evaluate is never an error. B1 runs twi maps already on disk, and what Swift Build passes every App compile (`-target arm64-apple-ios`, the iPhoneOS SDK of xtool's Swift SDK bundle, `-fobjc-arc`, `-fmodules`, `-fno-cxx-modules` for C++ and Objective-C++, `-DDEBUG=1`, a module cache in `ios-xtool/.precheck/ModuleCache`). A test compares the result with the response - file Swift Build wrote for the reference apps' App target (row 39). + files Swift Build wrote for the reference apps' App target (row 39). Those files are not fixtures yet: they are + captured from reference builds on the owner's machine, one build at a time, and normalised (home folders become + `/home/me`) before they enter `tests/fixtures/` (R12). 2. **Swift first.** `swiftc -typecheck` on the App's Swift files with `-import-objc-header` and the same `-Xcc` paths, writing `App-Swift.h` into `ios-xtool/.precheck/` (`-emit-objc-header-path`) for the next hop. When a Swift file imports a module SwiftPM builds from Swift (Expo, `ExpoModulesCore`, any Swift library target), the Swift part is @@ -471,9 +542,11 @@ nowhere; one under a condition B1 cannot evaluate is never an error. B1 runs twi 4. **Report.** An error stops the build before `xtool-build`: `✖ precheck — :: ` with clang's include stack (F4's error is in a React Native header; the cause is the app's flags), the first ten errors, and the log file's path. Warnings are not printed: `xtool-build` prints them once. -5. **Manifest planning** (row 54, owner's call): `swift package describe --type json` in `ios-xtool/`, which plans the - package without compiling, would report F1-like refusals (an executable App target, an invalid header layout) at the - same point. +5. **Manifest planning** (R6, row 54): `swift package describe --type json` in `ios-xtool/`, which plans the package + without compiling, runs first and reports F1-like refusals (an executable App target, an invalid header layout). +6. **The exit** (R2, row 39): `rn-xtool build --skip-precheck` skips hops 2–5 with + `⚠ precheck skipped (--skip-precheck): errors in the app's own sources show in xtool-build`, and `doctor --report` + says the last build skipped it. B1 pass 1 still runs. Both B1 and B2 run on bare projects and on an Expo project's bridging header ([library compatibility](2026-11-04-library-compat-design.md), goal 3.6); an Expo project's `AppDelegate.swift` imports `Expo` @@ -492,11 +565,14 @@ and is therefore not prechecked. 2. **Classes per target**, after `xtool-build`: for each scaffolded target whose manifest lists `.m` or `.mm` sources, `llvm-nm --defined-only` on `.o` (fact 20). No `_OBJC_CLASS_$_` symbol while the sources hold a non-category `@implementation` is an error naming the target and the files that declare one; no class and no such - `@implementation` (categories or C functions only) is an `ℹ` line. -3. **Classes per target in the packed app**: each class of hop 2 must be defined in the App binary or an embedded - framework. A target that defines classes in its object and contributes none is an error (it was not linked); a target - hop 2 noted with `ℹ` gets no line here. The failure removes the packed app and its `.ipa`, as the codegen guard does. - `install` runs hops 2 and 3 again on the app xtool builds before installing (`checkedApp`). + `@implementation` (categories or C functions only) is an `ℹ` line. A `knownLimits.allow` entry + `no-objc-classes:` turns the error into a `⚠` for a target whose implementations are all under platform + guards false on iOS (R7, row 65). +3. **Classes per target in the packed app** (weak B, R7): every target with Objective-C sources whose object defines + classes must contribute at least one of them to the App binary or an embedded framework. A target that contributes + none is an error (it was not linked); a target hop 2 noted with `ℹ` gets no line here. The failure removes the packed + app and its `.ipa`, as the codegen guard does. `install` runs hops 2 and 3 again on the app xtool builds before + installing (`checkedApp`). ### D. Reliability @@ -506,7 +582,8 @@ without color codes, including every child's output: `xtool dev build` and `xtoo the tee runner rn-xtool already has (fact 27). The file ends with the exit status, or the signal. The ten most recent logs per command are kept. `build --clean` keeps `ios-xtool/logs/`. A failure's last line names its log. A log that cannot be opened gives one `⚠` line and the command goes on. `start` logs rn-xtool's own lines, not Metro's stream -(row 75). +(row 75). Logs are never committed; `doctor --report` adds the last 60 lines of the newest build log through `redact` +(row 78). Commands that run outside a project (`setup`, `auth`, `doctor` without a project) write no log (row 79). **G1, the noise**, is filtered in the same tee: the exact `clang: warning: argument unused during compilation: '-fmodules-cache-path=…' [-Wunused-command-line-argument]` line is not shown, still written to the log, and counted in @@ -526,8 +603,17 @@ one line at the end of `xtool-build`. check. 5. `run` counts the app as installed only when `installedStamp` equals `buildStamp` (row 91). -Whether xtool keeps a custom Info.plist key and whether installd returns one in `Lookup` is checked on a device before -anything else is built (open question 1). +**The device spike comes first** (R9, rows 81 and 82). Before anything else of D2 is built, a bare 0.88.1 build checks +on the iPhone, over Wi‑Fi and over USB, which carrier survives xtool's packing and comes back in `Lookup`, and lists +every attribute `Lookup` returns for a development app. The candidates it tries, in order: + +1. `RNXtoolBuildStamp`, rn-xtool's own key (the design above); +2. `CFBundleGetInfoString`, a free-text bundle key iOS does not display; +3. another free-text key from the spike's list of what `Lookup` returns. + +rn-xtool writes a candidate other than its own only when the project's Info.plist does not set it, and never touches +`CFBundleVersion` or `CFBundleShortVersionString` (the app's own version checks read them). The first candidate that +survives both hops is the carrier; the D2 rows hold whichever it is. **D3, the USB retry.** When the four Wi‑Fi tries fail as unreachable (fact 23), `install --network` looks for the same iPhone (UDID) on USB. Found: `iPhone did not respond over Wi‑Fi after 4 tries; installing over USB instead (it is @@ -553,17 +639,37 @@ One page: A test keeps the guide's step list equal to `BUILD_STEP_NAMES` plus `precheck`, and its folder lists equal to the paths rn-xtool writes. `docs/` ships in part (row 103): the user pages (`docs/README.md`, `troubleshooting.md`, `how-it-works.md`, `bare-react-native.md`, `libraries.md`, `recipe.md`, `wifi-install.md`), so the guide's links work -offline; not `docs/design/`, `docs/research/` or `docs/upstream/` (1.4 MB of history and upstream proposals). +offline; not `docs/design/`, `docs/research/` or `docs/upstream/` (1.4 MB of history and upstream proposals). RELEASING +step 4 lists the shipped pages (R10). ### F. Guards on rn-xtool -1. **The reader sweep**, `tests/podspecReaderSweep.test.ts`: about 30 libraries pinned in `tests/tarballs.json`, the - production app's 20 among them, plus the most installed React Native libraries with an iOS podspec (the builder - proposes the list, the owner approves it). Each is unpacked into a temporary project next to a cached - `react-native` (their podspecs run `node` against it), read by both readers, and compared with a reviewed golden - per library: the shim's model, and the fields where the reduced reader differs. A change in either reader's output - fails until the golden is updated in the same commit. On CI the Ruby half must run: a missing Ruby fails the job, - not skips it; locally it skips with the test's name saying it needs Ruby. +1. **The reader sweep**, `tests/podspecReaderSweep.test.ts`, over a fixed set pinned in `tests/tarballs.json` (R11): + - the 30 most-downloaded React Native libraries that ship an iOS podspec, at their current versions. Source: npm's + downloads API (`api.npmjs.org/downloads/point`), 2026-10-07 to 2026-11-05, read on 2026-11-06; the podspec checked + in each current tarball's file list (jsDelivr). By downloads: react-native-safe-area-context 5.11.1, + react-native-screens 4.30.1, react-native-reanimated 4.7.1, react-native-gesture-handler 3.5.0, + react-native-worklets 0.13.1, react-native-svg 15.16.1, `@react-native-async-storage/async-storage` 3.1.1, + `@react-native-masked-view/masked-view` 0.3.2, react-native-webview 14.0.1, `@sentry/react-native` 8.34.0, + `@react-native-community/netinfo` 12.0.1, react-native-keyboard-controller 1.23.0, + `@react-native-community/datetimepicker` 9.3.0, react-native-get-random-values 2.1.0, react-native-nitro-modules + 0.37.2, react-native-mmkv 4.3.2, `@react-native-firebase/app` 27.1.0, `@shopify/react-native-skia` 2.14.0, + lottie-react-native 7.5.0, react-native-view-shot 6.2.1, `@react-native-community/slider` 5.2.2, + react-native-pager-view 10.0.0, react-native-maps 1.29.11, react-native-device-info 15.0.2, + `@react-native-google-signin/google-signin` 17.0.0, react-native-blob-util 0.25.1, react-native-purchases 11.0.1, + `@react-native-picker/picker` 2.11.4, `@react-native-clipboard/clipboard` 1.16.3, react-native-permissions 5.6.3. + `@shopify/flash-list` 2.3.3 and react-native-edge-to-edge 1.8.2 rank among them and ship no podspec, so they are + not in the set; + - the versions that failed in the trial: react-native-screens 4.24.0, react-native-worklets 0.8.1 and 0.8.3; + - every podspec of the Expo SDK 57 and 58 templates (R3), and the reference apps' libraries at the versions they pin + (the bare 0.85–0.88 and Expo references, and the bare 0.88.1 reference of the library-compatibility proof). + + Each library is unpacked into a temporary project next to a cached `react-native` (their podspecs run `node` against + it), read by both readers, and compared with a reviewed golden per library: the shim's model, and the fields where + the reduced reader differs. A change in either reader's output fails until the golden is updated in the same commit. + The test also lists, per library, where rn-xtool's TypeScript readers disagree with the shim (row 29). On CI the + Ruby half must run: a missing Ruby fails the job, not skips it; locally it skips with the test's name saying it + needs Ruby. 2. **The Objective-C drift target**, `bare-0.88/objc` (and per bare line): the CLI's fresh project with its Swift app delegate replaced by an Objective-C one in the pre-0.77 layout (`main.m`, `AppDelegate.h`, `AppDelegate.mm` at the root of the group tree), from a fixture written for rn-xtool. The watch runs `doctor --project` on it (B1 pass @@ -584,9 +690,9 @@ offline; not `docs/design/`, `docs/research/` or `docs/upstream/` (1.4 MB of his or, without a lock entry, the sha256 the spec declares, or one a previous resolution of the same URL recorded in the cache. The builder first checks whether the build itself downloads again in the same state; if it does, the fix is in the `pods` step too. -3. **`duplicate protocol definition of 'RCTDependencyProvider'`**: the builder finds the second path on 0.85.0 - (`clang -H` on `AppDelegate.mm` of a fresh bare 0.85 project with the Objective-C fixture) and makes the App's include list reach the header by one - file only, without changing 0.86–0.88's resolution (tests on all four lines' header trees). +3. **`duplicate protocol definition of 'RCTDependencyProvider'`**: the builder finds the second path on 0.85.0 (`clang + -H` on `AppDelegate.mm` of a fresh bare 0.85 project with the Objective-C fixture) and makes the App's include list + reach the header by one file only, without changing 0.86–0.88's resolution (tests on all four lines' header trees). 4. **DevTools on Linux**: troubleshooting gets a section: React Native DevTools (the `j` key) runs Chromium's `chrome-sandbox`, which must be owned by root with mode 4755 on Linux (`sudo chown root:root …/chrome-sandbox && sudo chmod 4755 …/chrome-sandbox`), or DevTools does not open; the rest of Metro works without it. @@ -597,7 +703,7 @@ The process, end to end. Each piece talks to something outside rn-xtool's own co third-party Ruby and `node`, the compiler and the SDK, Swift Build's object files, the iPhone's installd over Wi‑Fi and USB, the disk, GitHub's mention parser, npm and the drift watch's runners. -1. **A, reading a podspec:** probe `ruby` once per run; pick `pod`, the shim or the reduced reader; spawn Ruby in the +1. **A, reading a podspec:** probe `ruby` once per run; pick the shim or the reduced reader; spawn Ruby in the podspec's folder with a fixed environment; the podspec runs (its `require`s, React Native's helpers, `node` calls, `ENV`, `Pod::Config`); the shim writes the JSON model; `flattenSubspecs` consumes it; the scaffold and the autolinking act on it; `build` says which reader ran; the shim ships in the vendored copy and both 0.88 patches. @@ -615,37 +721,37 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. fixture, React Native's headers artifact); the mention check (locally, in tests, in a `pull_request` workflow). 9. **G, follow-ups:** doctor's pods line; the include list for `RCTDependencyProvider`; the DevTools docs line. -| # | Hop | Fails how | Who learns | Proposed ruling | +| # | Hop | Fails how | Who learns | Ruling | |---|-----|-----------|------------|-----------------| | 1 | A, Ruby probe | no `ruby` on `PATH` | user: the fixed `⚠` line at `rn-spm` (once per build), doctor's `⚠ ruby — not found …` line, and `setup`'s install command | handle: A.1, A.8; tests with a `PATH` without Ruby | | 2 | A, Ruby probe | Ruby runs but is unusable: older than the shim's floor, `require 'json'` fails (some distros package it apart), the interpreter crashes | user: the same `⚠` line with the reason (`ruby 2.5.1 is older than `, `ruby cannot load json`); doctor says the same | handle: the probe runs a one-line script through the shim's own loader; tests with a fake `ruby` per case | | 3 | A, spawn | the shell's `RUBYOPT`, `BUNDLE_GEMFILE`, `GEM_HOME` (a `bundle exec` shell, the project's `Gemfile` with `cocoapods`) would load other code or fail the start | nobody: the run gets a fixed environment (A.2) | handle: test with `RUBYOPT=-rnonexistent` in the parent environment | | 4 | A, shim | the podspec calls a method or constant the shim does not define, or sets an attribute CocoaPods does not know | user at `rn-spm`: `:: the podspec calls foo(…), which rn-xtool's podspec reader does not model`; a scaffolded library is refused, an autolinking read stops `rn-spm` (row 10) | handle: one test per kind (method, constant, attribute) | -| 5 | A, shim × a working app | the library built with the reduced reader before, and a shim gap now stops it (anti-goal) | user: row 4's stop | **owner's call.** Proposed handle: the sweep (F1) covers about 30 libraries before release; the stop's text says how to report; `RN_XTOOL_PODSPEC_READER=reduced` forces the reduced reader for one run, with the `⚠` line naming the variable, so nothing falls back silently. Alternative: no escape, the user waits for a fix | +| 5 | A, shim × a working app | the library built with the reduced reader before, and a shim gap now stops it (anti-goal) | user: row 4's stop, whose text says how to report it and how to force the reduced reader | handle (R2): `RN_XTOOL_PODSPEC_READER=reduced` forces the reduced reader for one run; the `⚠` line names the variable and `doctor --report` records that it was used; the sweep (F1) covers the set of R11 before release | | 6 | A, `require` | a gem the shim does not stub (a CocoaPods plugin, `xcodeproj`) | user: `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2` | handle: `colored2` stubbed (Expo's podspec); test with an unknown gem | | 7 | A, the podspec raises | worklets and reanimated raise when React Native is not found, when its version check fails, or with the New Architecture off | user: the podspec's own message, prefixed with the podspec's path, as `pod install` shows it | handle: test with worklets 0.8.3's podspec and no `react-native` | | 8 | A, timeout | a backtick or `system` call hangs (a `node` script waiting, a network call) | user: ` did not finish in 30 s`; the library is refused | handle: test with a podspec that sleeps | | 9 | A, `node` calls | the child's `PATH` lacks `node`, or `require.resolve` from `ios/` fails | user: the podspec's raise (row 7) | handle: the child environment keeps `PATH` and `HOME`; test with worklets' utils in a fixture project | -| 10 | A, callers | the autolinking callers catch every throw (fact 7), so a shim failure there would leave a library without its header search paths, silently | user: `rn-spm` stops with the shim's text | **owner's call**, because it can stop an Expo build on an Expo module's podspec (`Expo.podspec` requires `colored2`, tests `use_expo_modules!`, calls `get_folly_config`). Proposed handle: the failure propagates; the sweep includes every podspec of the Expo SDK 57 and 58 templates and of the reference apps | -| 11 | A, `ENV` | a podspec reads a variable other than the two (`USE_FRAMEWORKS`, `RNS_GAMMA_ENABLED`, `USE_HERMES`) | nobody at build: unset, as the trial ruled | **owner's call.** Proposed accept: the names read are listed per library in the log and in `doctor --report`, not on the terminal; troubleshooting says, present tense, that rn-xtool reads podspecs with only `RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED` set. Alternative: one `ℹ` line per library at the scaffold step | +| 10 | A, callers | the autolinking callers catch every throw (fact 7), so a shim failure there would leave a library without its header search paths, silently | user: `rn-spm` stops with the shim's text, also on an Expo module's podspec (`Expo.podspec` requires `colored2`, tests `use_expo_modules!`, calls `get_folly_config`) | handle (R3): the failure propagates; the sweep covers every podspec of the Expo SDK 57 and 58 templates and of the reference apps | +| 11 | A, `ENV` | a podspec reads a variable other than the two (`USE_FRAMEWORKS`, `RNS_GAMMA_ENABLED`, `USE_HERMES`) | nobody at build: unset, as the trial ruled | accept (R4): the names read are listed per library in the log and in `doctor --report`; troubleshooting says, present tense, that rn-xtool reads podspecs with only `RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED` set | | 12 | A, `spm_dependency` | a podspec declares a SwiftPM dependency through React Native's helper | user: the scaffold refuses the library: `uses spm_dependency(url: …, products: …), which rn-xtool does not map yet` | handle (the refusal); support is deferred to the block whose library needs it | -| 13 | A, `pod` present | `pod ipc spec` keeps React Native's helpers stripped, so `defined?(install_modules_dependencies())` and `respond_to?(:install_modules_dependencies, true)` are false and react-native-webview, async-storage, keychain, video take their old-architecture branch, unlike the shim; this is today's behaviour too | nobody: the scaffold differs from a machine with only Ruby | **owner's call.** Proposed accept: doctor's ruby line says `pod` is used when present; troubleshooting says so in the present tense. Alternative: prefer the shim over `pod` (the decision keeps `pod` first) | +| 13 | A, `pod` no longer used | a machine with CocoaPods got `pod ipc spec`'s model until alpha.7 (React Native's helpers stripped, so react-native-webview, async-storage, keychain and video took their old-architecture branch); from alpha.8 the shim reads it as on every machine with Ruby | user with CocoaPods: those libraries' scaffolds change, with the revision 8 warning (row 25) | accept (R1): one reader per machine state (Ruby: the shim; no Ruby: the reduced reader with its `⚠`); how-it-works says so in the present tense | | 14 | A, Podfile globals | `$VCEnableLocation`, `$VCEnableFrameProcessors`, `$RNVideoUse…` are undefined | nobody: the podspec takes its default branch | accept: troubleshooting says, present tense, that podspecs read as with a Podfile that sets no globals (vision-camera's location APIs on, frame processors only when react-native-worklets-core is installed) | | 15 | A, identity | Ruby evaluates `s.name = package['name']`, so the model's name differs from today's literal reading and targets would be renamed (fix 28 notes react-native-app-auth and react-native-webview) | user: persisted patches and codegen names no longer match | handle: `name`, `module_name`, `version` keep `readPodspecNames`' literals first (A.6); the sweep asserts every target name is unchanged | | 16 | A, project state | a podspec reads the app's state (reanimated's static feature flags in the app's `package.json`, vision-camera's check for react-native-worklets-core), so a persisted scaffold keeps the state of the day it was written | nobody until the feature misbehaves | accept: troubleshooting says to delete the library's patch after changing its feature flags or installing an optional sibling (as library compatibility row 45) | | 17 | A, one process per podspec | CocoaPods evaluates every podspec in one process; a podspec that relies on a global another one set reads it unset | nobody | accept: none of the 35 scanned podspecs does (fact 9); the sweep would show a new one | | 18 | A, side effects | the shim runs a library's Ruby and `node` scripts on the user's machine at scaffold time | nobody | accept: how-it-works says, present tense, that rn-xtool runs a library's podspec as CocoaPods runs it on a Mac, with the same trust as installing the library | | 19 | A, output | a podspec prints (vision-camera's thanks, `Pod::UI.puts`) | nobody: the model goes to a file; the prints go to the log | handle: test with a podspec that prints braces | -| 20 | A, consume, platforms | `ios`-scoped attributes are ignored today on the `pod` path (fact 6), and `osx`/`tvos` ones must stay out | user: react-native-svg's macOS files in sources, or its iOS excludes missing | handle: A.6's merge, tested with svg 15.16.0's podspec on both paths | +| 20 | A, consume, platforms | `ios`-scoped attributes were ignored on the `pod` path (fact 6), and `osx`/`tvos` ones must stay out | user: react-native-svg's macOS files in sources, or its iOS excludes missing | handle: A.6's merge, tested with svg 15.16.0's podspec on the shim and on the reduced reader | | 21 | A, consume, keys | a key that changes a CocoaPods build but not the scaffold (`script_phases`, `prepare_command`, `info_plist`, `module_map`) | user: a `!` warning naming the key and the library | handle: the scaffold's warnings list such keys; metadata keys are ignored as today | | 22 | A, subspecs | nested subspecs, `default_subspecs = :none`, a subspec depending on a sibling subspec, fix 20's dropped subspecs | user: a wrong source set (caught by C1 only against the same model) | handle: tests with the gesture-handler, screens and vision-camera fixtures on the shim | -| 23 | A, two readers in a team | one developer without Ruby persists a scaffold; another, with Ruby, builds with it | the second developer: `⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool regenerates it` | **owner's call.** Proposed handle: the marker records the reader (A.9) and `scaffoldPatchWarnings` compares. Alternative: accept, documented | +| 23 | A, two readers in a team | one developer without Ruby persists a scaffold; another, with Ruby, builds with it | the second developer: `⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool regenerates it` | handle (R5): the marker records the reader (A.9) and `scaffoldPatchWarnings` warns when the readers differ | | 24 | A, cost | one Ruby process per podspec, plus the `node` calls some make | user: seconds added to `rn-spm` | accept: the model is memoized per run (`readPodspecCached`); the proof records the time | | 25 | A, revision | revision 7 → 8: every persisted scaffold gets the "older rn-xtool scaffolder" warning | user: one `⚠` per persisted patch until regenerated | accept: RELEASING's rule; the CHANGELOG's Upgrading section says to delete and rebuild | | 26 | A, shipping | the shim is missing from an installed React Native 0.88 (patch not applied), or the copies drift apart | user: `⚠ the podspec reader's Ruby shim is missing from ; using the reduced reader`; maintainers: the byte tests | handle: the patch adds the file; the "patched RN files carry the patch" test gets fix 29's hunk | | 27 | A, reduced reader in use | the JavaScript evaluator's known limits remain on a machine without Ruby | user: the fixed `⚠` line on every build | accept: the line is the decision; C and the class checks run whatever the reader | | 28 | A, model fields | the regex path's internal fields (`__unresolved__`, `__header_dir_scopes__`) are absent from the shim's JSON | nobody: the consumer derives them from the layers | handle: the sweep compares the two models field by field | -| 29 | A, rn-xtool's other readers | the early checks and the resource reader keep their TypeScript line readers, which may disagree with the shim (a dependency under a Ruby condition) | user: an early refusal for a pod the scaffold does not use, or none for one it does | **owner's call.** Proposed defer to alpha.9 ("one podspec model for every reader"); the sweep lists the disagreements meanwhile | +| 29 | A, rn-xtool's other readers | the early checks and the resource reader keep their TypeScript line readers, which may disagree with the shim (a dependency under a Ruby condition) | user: an early refusal for a pod the scaffold does not use, or none for one it does | defer to alpha.9, "one podspec model for every reader" (R5); the sweep lists the disagreements meanwhile | | 30 | B1 pass 1 | an app-own quote include resolves nowhere (F2) | user in `doctor --project` and seconds after `build` starts: `✖ : imports "AppDelegate.h", which is not in ` | handle: fixture of the root-group layout | | 31 | B1, header map | a quote include of an app header that lives in another folder | nobody: resolved by name, as Xcode's header map and the forwards do | handle: test with headers at the root of the group tree and in the app folder | | 32 | B1 pass 1, before staging | an angle include into React Native's or a library's headers cannot be checked yet | user in doctor: one `ℹ` with the count, "checked at build" | handle | @@ -653,27 +759,27 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. | 34 | B1, text forms | an include in a comment or under `#if 0`; an include built from a macro | nobody | handle (comments, `#if 0`); accept (macro includes are not checked; B2 compiles them) | | 35 | B1, `@import` | a module B1 cannot place | nobody in B1; B2 compiles it | handle: B1 never errors on `@import` | | 36 | B1, generated headers | `App-Swift.h`, `-Swift.h` | nobody | accept: the build generates them; B2's hop 2 writes the App's | -| 37 | B1 pass 2, certainty | an angle include resolves in Swift Build through a folder B1's list lacks (a dependency target's header folder SwiftPM adds), so B1 would stop a working app | user: a false stop | **owner's call.** Proposed handle: pass 2 and B2 share one include-list function, tested against Swift Build's response files (row 39); a miss is an error only when its first path component names no target of the package graph, else a `⚠` that leaves the verdict to B2 | +| 37 | B1 pass 2, certainty | an angle include resolves in Swift Build through a folder B1's list lacks (a dependency target's header folder SwiftPM adds), so B1 would stop a working app | user: a `⚠`, and B2's verdict | handle (R6): pass 2 and B2 share one include-list function, tested against Swift Build's response files (row 39); a miss is an error only when its first path component names no target of the package graph, else a `⚠` that leaves the verdict to B2 | | 38 | B1, where it runs | `doctor --project` and the drift watch have no toolchain | nobody | handle: B1 is TypeScript over files only (fact 18) | -| 39 | B2, command lines | rn-xtool's flags differ from Swift Build's and the precheck stops a file that `xtool-build` compiles | user: a false stop | handle: a golden test against the App target's response files of the bare 0.85–0.88 references, the Objective-C fixture and an Expo 58 app with a bridging header. **Owner's call** on an escape: proposed `rn-xtool build --skip-precheck`, printed with `⚠`; alternative none | +| 39 | B2, command lines | rn-xtool's flags differ from Swift Build's and the precheck stops a file that `xtool-build` compiles | user: a false stop, whose text names `--skip-precheck` | handle: a golden test against the App target's response files of the bare 0.85–0.88 references, the Objective-C fixture and an Expo 58 app with a bridging header, captured on the owner's machine one build at a time and normalised (home folders become `/home/me`) before they enter `tests/fixtures/` (R12); `rn-xtool build --skip-precheck` skips it, printed with `⚠` and recorded in `doctor --report` (R2) | | 40 | B2, false pass | the flags differ the other way | user at `xtool-build`, as today | accept | | 41 | B2, toolchain | `clang`, `swiftc` or the iPhoneOS SDK cannot be found | user: a stop naming the tool and `rn-xtool setup` | handle; doctor already fails on `swift` and `darwin-sdk` | | 42 | B2, module cache | a stale cache after a React Native or toolchain change ("module file out of date") | user: a stop, or nothing after the retry | handle: the cache is keyed by React Native version and toolchain; one retry without it; `--clean` removes it | | 43 | B2, Swift modules | a Swift file imports a module SwiftPM builds from Swift (Expo, `ExpoModulesCore`) | user: `ℹ precheck — imports , which SwiftPM builds: checked by xtool-build` | accept: an Expo app's `AppDelegate.swift` is never prechecked; handle the line | | 44 | B2, clang modules | Swift imports a clang target without a module map on disk (`ReactAppDependencyProvider`, `ReactCodegen`; SwiftPM synthesises theirs at build) | nobody: synthesised by SwiftPM's rule into `.precheck/`, or the file skipped with `ℹ` | handle: never an error; the builder picks synthesis or skip | | 45 | B2, `App-Swift.h` | an Objective-C file imports the App's Swift header and hop 2 did not write it | user: one `ℹ` naming the files not checked | handle | -| 46 | B, target shape: xcconfig | `HEADER_SEARCH_PATHS`, defines or the C++ standard come from an xcconfig (`baseConfigurationReference`); the manifest lacks them, and B mirrors the manifest, so the errors look like rn-xtool's | user: `⚠ sets HEADER_SEARCH_PATHS, … for the app target; rn-xtool does not read xcconfig files` at doctor and build start | **owner's call.** Proposed handle (the `⚠` only; reading xcconfigs is a later block) | -| 47 | B, target shape: synchronized folders | an Xcode 16 synchronized folder group holds the app's sources; nothing is in the Sources phase | user: a refusal at doctor and build start naming the group | **owner's call.** Proposed handle (the refusal); reading such groups is a later block | +| 46 | B, target shape: xcconfig | `HEADER_SEARCH_PATHS`, defines, the C++ standard or another setting rn-xtool reads come from an xcconfig (`baseConfigurationReference`); the manifest lacks them, and B mirrors the manifest, so the errors look like rn-xtool's | user: `⚠ sets HEADER_SEARCH_PATHS, … for the app target; rn-xtool does not read xcconfig files` at doctor and build start | handle (R6): the `⚠` only, and only for an xcconfig that is not CocoaPods' generated `Pods-*.xcconfig` and sets a setting rn-xtool reads; reading xcconfigs is a later block | +| 47 | B, target shape: synchronized folders | an Xcode 16 synchronized folder group holds the app's sources; nothing is in the Sources phase | user: a refusal at doctor and build start naming the group | handle (R6): the refusal; reading such groups is a later block | | 48 | B, per-file flags | the app target's per-file `COMPILER_FLAGS` (`-fno-objc-arc`) are not read | user at precheck or `xtool-build`, the same way | accept: the trial's ruling; B2 uses the manifest's flags | | 49 | B2, time | the first precheck builds React Native's clang modules into its cache | user: a slower first build | accept: measured in the proof; parallel and `nice` | | 50 | B2, location | the error is in a library header (F4: `hash_combine.h`) while the cause is the app's flags | user: clang's include stack, starting at the app's file | handle | | 51 | B2, warnings | the app's warnings | user at `xtool-build`, once | accept: the precheck prints errors only | | 52 | B2, beyond syntax | a file passes `-fsyntax-only` and fails at code generation or link | user at `xtool-build`, as today | accept | | 53 | B, Expo bridging header | the prebuild's bridging header imports something its paths do not reach | user: B1 pass 2 or B2, after prebuild | handle: the Expo 58 bridging-header fixture | -| 54 | B2, manifest planning | the generated manifest is refused by SwiftPM's planning (an executable App target as in F1, an invalid header layout) | user at `xtool-build`'s first seconds today | **owner's call.** Proposed handle: `swift package describe --type json` in the precheck. Alternative: defer to alpha.9 | +| 54 | B2, manifest planning | the generated manifest is refused by SwiftPM's planning (an executable App target as in F1, an invalid header layout) | user: the precheck's first hop, in seconds | handle (R6): `swift package describe --type json` runs in the precheck | | 55 | B, anti-goal | a check stops a project that builds today | user: a false stop | handle: Verification runs B on every reference app and on the production app with no stop before release | | 56 | C1, fresh scaffold | the globs match a compiled file no target lists, or a target lists a file the globs do not match | user at `rn-spm`: `✖ : its podspec's source_files match , which its Package.swift does not compile` (and the converse) | handle | -| 57 | C1, persisted scaffold | a manifest applied from `patches/` differs from the globs: stale, or a deliberate hand edit (a promised feature) | user: `⚠ patches/: …` | **owner's call.** Proposed `⚠` (a hand edit is legitimate). Alternative: error unless the patch carries a marker that says the list was edited | +| 57 | C1, persisted scaffold | a manifest applied from `patches/` differs from the globs: stale, or a deliberate hand edit (a promised feature) | user: `⚠ patches/: …` | handle (R7): a `⚠`, since a hand edit is legitimate | | 58 | C1, scaffolder exclusions | `.metal` off Darwin, the scaffold's own files, `include/` | nobody: the scaffolder exports the list, and C1 subtracts it | handle: tests with a `.metal` file and a library with real sources under `include/` | | 59 | C1, glob semantics | `Dir.glob` and `micromatch` differ (`**`, braces, dotfiles, case, symlinks) | user: a false difference, or a missed one | handle: the expected set uses Ruby's `Dir.glob` with CocoaPods' flags when Ruby runs; tests on each form | | 60 | C1, headers | a header the globs match is not in the manifest | nobody | accept: headers are relocated by design; the compile reports a missing one | @@ -681,9 +787,9 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. | 62 | C1, reduced reader | the expected set comes from the same reduced model, so a reader error like F6's is invisible to C1 | nobody at C1 | accept: row 27's `⚠` says the reduced reader ran; C2, C3 and the codegen guard still run | | 63 | C2, object | `.o` is missing or unreadable | user: `ℹ classes of not checked: ` | handle | | 64 | C2, no class | a target lists `.m`/`.mm` sources with a non-category `@implementation` and its object defines no class | user: `✖ compiled Objective-C files and defines no class: `; the app is removed | handle | -| 65 | C2, legitimate none | every `@implementation` sits under a platform guard false on iOS (macOS-only code), so the error of row 64 would stop a working app | user: a false stop | **owner's call.** Proposed handle: the error names the target, and a `knownLimits.allow` entry `no-objc-classes:` turns it into a `⚠`. Alternative: `⚠` always | +| 65 | C2, legitimate none | every `@implementation` sits under a platform guard false on iOS (macOS-only code), so the error of row 64 would stop a working app | user: the error, naming the target and the `knownLimits.allow` key | handle (R7): `knownLimits.allow` entry `no-objc-classes:` turns the error into a `⚠` | | 66 | C2, Swift | a mixed target's classes are Swift (`_TtC…`, `@objc` names) | nobody: they count | handle | -| 67 | C3, not linked | a target defines classes in its object and none reaches the App binary or a framework | user: `✖ 's classes are not in the app: it was not linked`; app and `.ipa` removed | handle | +| 67 | C3, not linked | a target with Objective-C sources defines classes in its object and none of them reaches the App binary or a framework | user: `✖ 's classes are not in the app: it was not linked`; app and `.ipa` removed | handle: at least one class per target (weak B, R7) | | 68 | C3, frameworks | a self-managed dynamic product holds the classes | nobody: `Frameworks/*` count | handle | | 69 | C3, symbols | a stripped binary, or `llvm-nm` missing | user: `ℹ` (as the codegen guard), or doctor's `llvm-nm` failure | accept | | 70 | C, install | `install` rebuilds from `.build` | user: the same checks before installing | handle: `checkedApp` runs C2 and C3 | @@ -691,18 +797,18 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. | 72 | D1, clean | `build --clean` removes `ios-xtool/`, the running log with it | nobody | handle: `logs/` is kept; test | | 73 | D1, children | a child with inherited stdio (`xtool dev build`, `xtool dev run`) bypasses the log; with a pipe, xtool loses its terminal | user: an incomplete log | handle: every runner tees (test over the runners); accept that xtool's output is no longer colored | | 74 | D1, crash or Ctrl-C | the log ends mid-line | nobody | handle: lines are written synchronously; the signal is written last | -| 75 | D1, `start` | Metro runs for hours | user: a large file | **owner's call.** Proposed: `start` logs rn-xtool's lines only, not Metro's stream | +| 75 | D1, `start` | Metro runs for hours | nobody: no large file | handle (R8): `start` logs rn-xtool's own lines only, not Metro's stream | | 76 | D1, concurrency | `build` and `start` at once | nobody: one file each (pid in the name) | handle | | 77 | D1, rotation | the ten most recent per command are kept | user: an older log is gone | accept: present tense in troubleshooting; the owner may change N | -| 78 | D1, privacy | logs hold the Apple ID, UDIDs, IPs, paths | user, if they paste one | **owner's call.** Proposed accept: the logs are never committed (`ios-xtool/.gitignore`), the guide and troubleshooting say to share `doctor --report`, and `doctor --report` adds the last 60 lines of the newest build log through `redact`. Alternative: no log in the report | -| 79 | D1, commands outside a project | `setup`, `auth`, `doctor` without a project | nobody: no log | **owner's call.** Proposed accept (no log). Alternative: `~/.cache/rn-xtool/logs/` | +| 78 | D1, privacy | logs hold the Apple ID, UDIDs, IPs, paths | user, if they paste one | accept (R8): the logs are never committed (`ios-xtool/.gitignore`); the guide and troubleshooting say to share `doctor --report`, which adds the last 60 lines of the newest build log through `redact` | +| 79 | D1, commands outside a project | `setup`, `auth`, `doctor` without a project | nobody: no log | accept (R8): troubleshooting says, present tense, that only project commands write logs | | 80 | G1, the filter | it hides a line that matters | nobody on the terminal; the log holds it | handle: only the exact text; one count line at the end of `xtool-build` | -| 81 | D2, packing | xtool drops or rewrites a custom Info.plist key | rn-xtool: the packed-app check fails every build | handle: the device spike first (open question 1); test on the packed app | -| 82 | D2, Lookup | installd does not return a custom key in `Lookup` | rn-xtool: no install could be verified | **owner's call** if the spike says so (open question 1) | +| 81 | D2, packing | xtool drops or rewrites the carrier key | rn-xtool: the packed-app check fails every build | handle (R9): the device spike runs first and picks a carrier that survives packing; test on the packed app | +| 82 | D2, Lookup | installd does not return the carrier key in `Lookup` | rn-xtool: no install could be verified | handle (R9): the spike tries `RNXtoolBuildStamp`, then `CFBundleGetInfoString`, then another free-text key from its list of what `Lookup` returns, and the first that survives packing and `Lookup` is the carrier | | 83 | D2, mismatch | installd reports Complete and the iPhone keeps the old build (F7) | user: `✖ The iPhone kept the app built at ; this build is …` | handle: tests with a fake installd | | 84 | D2, Lookup fails | the Lookup itself fails | user: today's `VerifyFailedError` | accept | | 85 | D2, not installed | the bundle id is not on the iPhone after Complete | user: today's error | accept | -| 86 | D2, USB Lookup | usbmuxd or the pair record cannot be read after `xtool dev run` | user: `⚠ installed over USB, not verified: ` | **owner's call.** Proposed `⚠` (xtool reported success). Alternative: failure | +| 86 | D2, USB Lookup | usbmuxd or the pair record cannot be read after `xtool dev run` | user: `⚠ installed over USB, not verified: ` | handle (R9): a `⚠`, since xtool reported success | | 87 | D2, stale `.ipa` | `xtool dev build --ipa` reports a path to an older `.ipa` | user: a stop before the upload, naming both stamps | handle | | 88 | D2, same build again | `install` twice | nobody: the same stamp passes | accept | | 89 | D2, every build differs | the Info.plist changes on every `generate`, so xtool repacks and re-signs | nobody | accept: no source is recompiled for it | @@ -712,15 +818,15 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. | 93 | D3, same iPhone on USB | the four Wi‑Fi tries fail and the iPhone is on USB | user: the one announce line, then the USB install with D2's check | handle | | 94 | D3, another iPhone | another iPhone is on USB | user: the Wi‑Fi error and both UDIDs; nothing installed | handle | | 95 | D3, none | no iPhone on USB | user: today's error, "and no iPhone is connected by USB" | handle | -| 96 | D3, interrupted `Install` | the link died after `Install` was sent | user: today's `InstallInterruptedError` | **owner's call.** Proposed keep (no automatic retry). Alternative: retry over USB, since D2 now verifies the result | +| 96 | D3, interrupted `Install` | the link died after `Install` was sent | user: today's `InstallInterruptedError` | accept (R9): no automatic retry; the message already says to check the iPhone and install again | | 97 | D3, other errors | a refused pair record, several iPhones, the scan refused | user: today's messages | accept: not "does not reach" | | 98 | D3, `xtool dev run` | it rebuilds what is out of date and launches the app | user: the app opens | accept | | 99 | E, packing | `AGENTS.md` is not in the package | maintainers: `tests/packageFiles.test.ts` | handle | | 100 | E, command | `agent-guide` cannot find the file (a checkout without a build) | user: an error naming the path | handle | | 101 | E, drift | the guide names steps or folders that changed | maintainers: the guide test | handle | | 102 | E, user files | a tool deletes `patches/`, the config or the lock after reading the guide | user: their fixes gone | handle: the guide names them as the user's and never to be deleted; a test checks the list | -| 103 | E, `docs/` | the guide's links point at files not in the package | user offline: dead links | **owner's call.** Proposed handle: ship the user pages (E), not `docs/design/`, `docs/research/`, `docs/upstream/`; RELEASING step 4 lists them | -| 104 | F1, tarballs | about 30 more tarballs to fetch | CI: time and the existing fetch rules (two tries, integrity) | handle: `tests/tarballs.json`; the proof records the size | +| 103 | E, `docs/` | the guide's links point at files not in the package | user offline: dead links | handle (R10): the user pages ship (E); `docs/design/`, `docs/research/`, `docs/upstream/` do not; RELEASING step 4 lists them; `tests/packageFiles.test.ts` checks both | +| 104 | F1, tarballs | about 45 more tarballs to fetch (R11's set) | CI: time and the existing fetch rules (two tries, integrity) | handle: `tests/tarballs.json`; the proof records the size | | 105 | F1, third-party code | the sweep runs the libraries' Ruby and `node` scripts in CI | nobody | accept: the CI job has a read-only token and no secrets | | 106 | F1, no Ruby | the runner has no Ruby | CI: a failure, not a skip | handle | | 107 | F1, goldens | a deliberate reader change updates many goldens | maintainers | accept: reviewed in the same commit | @@ -728,7 +834,7 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. | 109 | F2, fixture | a CLI template change breaks the Objective-C overlay | the drift issue for that line | handle | | 110 | F2, network | React Native's headers artifact cannot be downloaded | the line reads `unknown (could not run)` | accept: the drift watch's existing rule | | 111 | F2, no compile | the drift watch never runs B2 | nobody | accept: the drift watch's documented limit | -| 112 | F3, scope | scoped package names (`@scope/name`, 122 in the docs) | maintainers | **owner's call.** Proposed: they pass and the user form is refused (the alpha.7 release listed only the user-form `@import` as a contributor; whether GitHub links `@org/name` as a team mention was not checked). Alternative: refuse every `@` outside code | +| 112 | F3, scope | scoped package names (`@scope/name`, 122 in the docs) | maintainers | handle (R10): they pass and the bare user form is refused (the alpha.7 release listed only the user-form `@import` as a contributor) | | 113 | F3, timing | GitHub notifies when the PR or release is published, before CI runs | the person mentioned | accept: RELEASING runs the check on the body and notes files before `gh pr create` and `gh release create`; CI flags what is left | | 114 | F3, UI text | release notes typed in GitHub's page | nobody | accept: RELEASING says to publish notes from the checked file only | | 115 | F3, existing text | the fifteen user-form mentions of fact 32 | maintainers: the new test | handle: fixed in the same task | @@ -740,12 +846,16 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. - **Unit tests**, each written red first, own the `handle` rows (the plan names them). `npm test`, `npm run lint`, `npm run scan:private` and the new mention check are green and clean; the byte tests of the scaffolder run, not skip. -- **The reader sweep** (F1) passes in CI with Ruby, and its goldens are reviewed by the owner once, with the - differences between the two readers listed per library. +- **The reader sweep** (F1) passes in CI with Ruby over R11's set, and its goldens are reviewed by the owner once, + with the differences between the two readers listed per library. - **Downloads and builds need the owner's approval first.** The sweep's tarballs (tens of MB), React Native's headers artifact for the drift target, and the builds below. -- **Spike gate (device, before group D2 is built):** a bare 0.88.1 build with a hand-added `RNXtoolBuildStamp` in its - Info.plist; check the key in the packed `App.app` and in `Lookup`'s answer over Wi‑Fi and over USB (open question 1). +- **Spike gate (device, before group D2 is built):** a bare 0.88.1 build with each carrier candidate of D2 added by + hand to its Info.plist; check each in the packed `App.app` and in `Lookup`'s answer over Wi‑Fi and over USB, and list + every attribute `Lookup` returns (R9). +- **Response-file capture (before group B's golden test):** reference builds on the owner's machine, one at a time + (approved by the owner on 2026-11-06), keep Swift Build's response files of the App target's compiles; they are + normalised (home folders become `/home/me`) and checked by `scan:private` before they enter `tests/fixtures/` (R12). - **Build-only proofs**, on copies of the reference apps: 1. The Objective-C fixture app with seeded faults, one per build: a missing app header (F2), the bare include dirs removed (F3), `CLANG_CXX_LANGUAGE_STANDARD` removed (F4), an `@import` in a header its `.mm` includes (F5). Each is @@ -769,22 +879,16 @@ USB, the disk, GitHub's mention parser, npm and the drift watch's runners. Until the owner confirms these, the CHANGELOG calls the stamp and the USB retry build-verified only. -## Open questions +## The questions the draft left open -1. **Does a custom Info.plist key survive xtool's packing, and does installd return it in `Lookup`?** Proposed: the - spike gate answers both before group D2 is built, and lists every attribute `Lookup` returns for a development app. - If xtool drops the key, the stamp needs another carrier in the signed bundle; if installd does not return it, the - owner picks, from that list, an attribute that changes with every build. Either way the D2 rows stay as written. -2. **The owner's calls in the failure walk**, each with a proposed ruling: rows 5, 10, 11, 13, 23, 29, 37, 39, 46, 47, - 54, 57, 65, 75, 78, 79, 82, 86, 96, 103 and 112. -3. **The sweep's library list** (F1): the builder proposes about 30 (the production app's 20 and the most installed - React Native libraries with an iOS podspec), the owner approves it with the size it adds to CI. -4. **N for the logs** (D1): proposed 10 per command. +All are ruled (see Rulings): the stamp's carrier is decided by the device spike (R9), the failure walk's open rows by +R1–R8 and R10, the sweep's set by R11 (source and date in F1), and log retention by R13 (ten per command). ## Left to the builder -- Exact names: the shim's file and its JSON keys, the `precheck` step, the env variable of row 5, the flag of row 39, - the `knownLimits` key of row 65, the state fields, the log file pattern beyond the decided folder. +- Exact names: the shim's file and its JSON keys, the `precheck` step's name, the state fields, the log file pattern + beyond the decided folder. `RN_XTOOL_PODSPEC_READER=reduced`, `--skip-precheck` and `no-objc-classes:` are + decided (R2, R7). - The Ruby floor the shim supports, from what it uses. - Whether `get_folly_config` loads React Native's `helpers.rb` or holds the shared values. - Whether B2 synthesises module maps for clang targets or skips the Swift file (row 44). From ee4e699494a1bcef5812c2681f5a47fdb287966c Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 11:18:16 -0600 Subject: [PATCH 03/53] docs: add alpha.8 plan 1, the podspec reader --- .../plans/2026-11-06-alpha-8-fail-early.md | 3 + ...026-11-06-alpha-8-plan-1-podspec-reader.md | 1072 +++++++++++++++++ 2 files changed, 1075 insertions(+) create mode 100644 docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md diff --git a/docs/design/plans/2026-11-06-alpha-8-fail-early.md b/docs/design/plans/2026-11-06-alpha-8-fail-early.md index 608894d..29d1559 100644 --- a/docs/design/plans/2026-11-06-alpha-8-fail-early.md +++ b/docs/design/plans/2026-11-06-alpha-8-fail-early.md @@ -4,6 +4,9 @@ Status: skeleton, 2026-11-06. The [alpha.8 design](../specs/2026-11-06-alpha-8-f its rulings R1–R13. This file lists the task groups and the failure-walk rows each group owns; every row 1–118 has exactly one owner. The tasks, their tests and the execution order are written next. +Plans: [plan 1, the podspec reader](2026-11-06-alpha-8-plan-1-podspec-reader.md) covers group A (rows 1–28), F1 (rows +104–108), F3 (rows 112–115) and records row 29 as deferred. + Two gates come before the groups that depend on them: - **The device spike** (R9) runs first of all: it decides the build stamp's carrier (`RNXtoolBuildStamp`, then diff --git a/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md b/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md new file mode 100644 index 0000000..7defc82 --- /dev/null +++ b/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md @@ -0,0 +1,1072 @@ +# Release 0.1.0-alpha.8, plan 1: the podspec reader runs real Ruby — Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or +> superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Read every podspec with the system `ruby` and a shim of CocoaPods and React Native's helpers, fail loudly +where the shim does not model something, keep the JavaScript evaluator as the visible no-Ruby fallback, and guard the +reader with a permanent sweep in CI and the docs with a bare-mention check. + +**Architecture:** A new Ruby file, `read-podspec-shim.rb`, ships next to `read-podspec.js` in both copies of React +Native's scaffolder (`vendor/rn-spm/spm/` and the two 0.88 patches). `read-podspec.js` picks the reader once per +process (`podspecReader()`), runs the shim per podspec with a fixed environment, and hands its JSON (CocoaPods' JSON +form) to the existing consumer `flattenSubspecs`, which learns the `ios` merge. `pod ipc spec` is removed. Each read is +appended to a JSON-lines file that the `rn-spm` step turns into the one `⚠` line, and `doctor --report` into its +reader and `ENV` lines. A vitest sweep reads about 45 pinned library tarballs with both readers against reviewed +goldens. + +**Tech Stack:** Ruby ≥ 2.7 (stdlib only), Node 22 (CommonJS for the vendored scripts, TypeScript ESM for `src/`), +vitest, GitHub Actions. + +**Spec:** [`docs/design/specs/2026-11-06-alpha-8-fail-early-design.md`](../specs/2026-11-06-alpha-8-fail-early-design.md) +(decision A, rulings R1–R5, R10, R11, design A and F.1/F.3, failure-walk rows 1–29 and 104–108, 112–115). Index of all +groups: [`2026-11-06-alpha-8-fail-early.md`](2026-11-06-alpha-8-fail-early.md). Plans 2–4 cover groups B, C, D, E, G and +F2. + +**Branch:** cut the execution branch with `git switch -c feature/alpha-8-podspec-reader --no-track `; never track `develop`/`main`; push only with `git push -u origin feature/alpha-8-podspec-reader`, then check +that `@{u}` is `origin/feature/alpha-8-podspec-reader`. + +## Global Constraints + +- Linux only, no Mac, no Xcode tools. `doctor --project` keeps working without Swift, xtool or a network. +- The scaffolder ships twice and stays byte-identical: `vendor/rn-spm/spm/` and `patches/react-native+0.88.{0,1}.patch`, + regenerated from the vendored copy by the recipe in `docs/RELEASING.md` "Scaffolder changes" step 2, never edited as + text. The shim is a new file in both. +- Revision rule: a change to what a scaffold writes bumps `RN_XTOOL_SCAFFOLD_REVISION` + (`vendor/rn-spm/spm/scaffold-package-swift.js:139`) and `SCAFFOLD_REVISION` (`src/pipeline/patches.ts:362`) together, + from 7 to 8, with a CHANGELOG "Upgrading" note. +- The podspec's environment: `RCT_NEW_ARCH_ENABLED='1'`, `RCT_HERMES_V1_ENABLED='1'` (`RN_POD_ENV`, + `read-podspec.js:230`), every other variable unset; the child gets `PATH`, `HOME`, `LANG` and those two only. +- One Ruby process per podspec, working directory the podspec's folder, 30 s timeout. +- The escape is exactly `RN_XTOOL_PODSPEC_READER=reduced`; it prints a `⚠` line naming itself and `doctor --report` + records it (R2). +- `ENV` names a podspec read go to the reads file and `doctor --report`, never to the terminal (R4). +- No fallback without a line naming it; no check that blocks a working app where it is not certain (anti-goals). +- Mechanisms over versions: every rule follows a content fact, never a library name or version. +- Downloads and builds on the owner's machine need the owner's approval first; device runs are the owner's (and go + through a delegated session, never this one). +- Before every commit: `git add` the task's files, then `npm run scan:private` (must print `scan-private: clean`). No + absolute home paths, Team ID, UDID, e-mail, IP or production-app name in any committed file; tests normalise temp + roots to `` or ``. No bare `` `@word` `` outside code spans in any markdown (Task 14 enforces it). +- Commits: Conventional Commits, English, subject ≤ 50 characters, imperative, no body; one logical change each. +- Scaffolder tasks end with `npx vitest run tests/vendor-rn-spm.test.ts tests/patches.test.ts + tests/patches-upstream.test.ts tests/rn-scaffolder.test.ts` green with none of the provenance, identical-patch, + upstream dry-run or "the patched RN files carry the patch" tests skipped (`node scripts/fetch-test-tarballs.mjs` + first). + +## Review Focus + +1. **A machine whose locale is `C` or unset** (`LANG=C`, CI containers): a package.json description with non-ASCII + text read through `JSON.parse(File.read(...))` must come out in the model unchanged, not as an encoding error. + Pinned in Task 2 (`it("writes UTF-8 values when LANG is C")`). +2. **A podspec or a script it runs that reads standard input** (a `gets`, a `node` script prompting): the read must end + at once, not hang to the timeout on the user's terminal. Pinned in Task 3 (`it("gives the podspec an empty stdin")`). +3. **A library reached through a symlink** (pnpm, a monorepo link, a hoisted package): `__dir__`, `require_relative` + and the installation root must follow the path autolinking gave, as CocoaPods does. Pinned in Task 3 + (`it("reads a library reached through a symlink")`). +4. **Ruby older than the one CI runs** (Ubuntu 22.04's 3.0; the floor 2.7): the shim must parse and run there, or the + reader is unusable for those users with only a crash text. Pinned in Task 1 (the `shim-ruby-floor` CI job runs + `tests/podspecShim.test.ts` on the floor Ruby). +5. **A mistyped escape** (`RN_XTOOL_PODSPEC_READER=REDUCED`, `=1`, `=ruby`): it must not silently do nothing. Pinned in + Task 3 (`it("names an unknown RN_XTOOL_PODSPEC_READER value")`) and printed in Task 10. + +## Interfaces later plans consume + +- **The shim's model** (Task 1) and `PodspecModel.reader`, `.spmDependencies` (Tasks 4, 5): plan C's glob comparison + reads `source_files`/`exclude_files` of the selected layers from it and adds a `--glob` mode to the shim's command + line next to `--probe`. +- **`podspecReader()`** (Task 3, `read-podspec.js`) and **`podspecReaderHere()`** (Task 8, `src/tools/podspecReader.ts`): + plan C uses them to pick Ruby's `Dir.glob` or the JavaScript expansion. +- **The marker line** `// rn-xtool-podspec-reader: ruby|reduced` (Task 7) and `scaffoldReaderOf(patchText)` (Task 9). +- **The reads file** `ios/build/rn-xtool-podspec-reads.jsonl`, `readPodspecReads()` and `podspecEnvLines()` (Task 10): + plan D's log writes `podspecEnvLines()` to the build log only. +- **`doctor --report`'s `podspec reader:` line** (Task 10): plan B adds its `precheck:` line (`--skip-precheck`) beside it. + +--- + +### Task 1: The shim's DSL and command line + +**Files:** +- Create: `vendor/rn-spm/spm/read-podspec-shim.rb` +- Create: `tests/podspecShim.test.ts`, `tests/support/ruby.ts` +- Modify: `patches/react-native+0.88.0.patch`, `patches/react-native+0.88.1.patch` (regenerated) +- Modify: `tests/rn-scaffolder.test.ts` ("the patched RN files carry the patch", after the fix 28 hunk test at :213), + `tests/packageFiles.test.ts` +- Modify: `.github/workflows/ci.yml` (a `ruby --version` step before Test; a `shim-ruby-floor` job) + +**Interfaces:** +- Consumes: nothing. +- Produces: the command line + - `ruby --probe` → stdout `{"ruby":"","floor":"2.7.0","usable":true}` or + `{"ruby":"2.6.10","floor":"2.7.0","usable":false,"why":"ruby 2.6.10 is older than 2.7.0"}`, exit 0. The floor check + is the shim's first statement and prints without the `json` library; `require 'json'` follows. + - `ruby `, run by Task 3 in the podspec's folder → exit 0 with the + model in ``, or exit 1 with `{"error":{"kind":K,"message":M}}` in ``. Nothing of the shim's own + goes to stdout; the podspec's prints do. + - The model, CocoaPods' JSON form (what `pod ipc spec` printed, so `flattenSubspecs`, `read-podspec.js:2011`, reads + it unchanged): + + ```text + { "name": String, // a subspec's base name ("common"), never "Pod/common" + : value as the podspec gave it; Symbol → String, Hash keys → String, Pathname → String, + "platforms": { "": String|null }, + "dependencies": { "[/]": [ "", … ] }, + "default_subspecs": [ String, … ] | "none", + "subspecs": [ ], "testspecs": [ ], "appspecs": [ ], + "ios"|"osx"|"tvos"|"visionos"|"watchos": { : value, "dependencies": {…} }, + "__rn_xtool__": { "env": [String], "helpers": [String], "ui": [String], // root only, sorted, unique + "spm_dependencies": [ { "url", "requirement", "products" } ] } } + ``` + + A singular alias is stored under its plural key (`framework` → `frameworks`, `author` → `authors`, + `swift_version` → `swift_versions`, `script_phase` → `script_phases`, `resource_bundle` → `resource_bundles`, …). + - Error kinds and their exact messages (`` is `:` for a frame in the podspec, else + ` (:)` for the first frame in another of the library's files): + `method` → `: the podspec calls (…), which rn-xtool's podspec reader does not model`; + `constant` → `: the podspec uses , which rn-xtool's podspec reader does not model`; + `attribute` → `: the podspec sets ., which CocoaPods does not define`; + `require` → `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2`; + `raised` → `: ` (also `abort`, `exit` and syntax errors); + `not-a-spec` → `: the podspec does not evaluate to a Pod::Spec`. + +- [ ] **Step 1: Write the failing tests** in `tests/podspecShim.test.ts`, with `tests/support/ruby.ts` exporting + `SHIM` (the vendored path), `needsRuby` (`""` or `" (needs ruby)"`; on CI, where `process.env.CI === "true"`, a + missing Ruby fails the file instead) and `runShim(body: string, opts?: { files?: Record; env?: + Record; root?: string }): { status: number; json: any; stdout: string; podspec: string }` (writes `Foo.podspec` and + `files` into a temp folder, runs the shim there with `env: { PATH, HOME, LANG, RCT_NEW_ARCH_ENABLED: "1", + RCT_HERMES_V1_ENABLED: "1", ...env }`). + + ```ts + it("--probe prints the Ruby version and the floor", () => { + expect(JSON.parse(tool("ruby", [SHIM, "--probe"]).stdout)).toEqual({ ruby: expect.stringMatching(/^\d+\.\d+\.\d+/), floor: "2.7.0", usable: true }); + }); + it("writes the spec in CocoaPods' JSON form", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo"\n s.version = "1.2.3"\n s.source_files = "ios/**/*.{h,m}"\n s.dependency "React-Core"\n s.dependency "Bar", "~> 1.0"\n s.pod_target_xcconfig = { "OTHER_CFLAGS" => "-DX=1" }\n s.ios.deployment_target = "15.1"\n s.source = { :git => "x", :tag => "v#{s.version}" }\nend`); + expect(r.status).toBe(0); + expect(r.json).toEqual({ name: "Foo", version: "1.2.3", source_files: "ios/**/*.{h,m}", dependencies: { "React-Core": [], Bar: ["~> 1.0"] }, + pod_target_xcconfig: { OTHER_CFLAGS: "-DX=1" }, platforms: { ios: "15.1" }, source: { git: "x", tag: "v1.2.3" }, + __rn_xtool__: { env: [], helpers: [], ui: [], spm_dependencies: [] } }); + }); + it("nests subspecs under their base name and keeps test specs apart", () => { /* subspec "core" with ss.name read + into ss.summary → subspecs[0] = { name: "core", summary: "Foo/core", … }; s.default_subspec = "core" → + default_subspecs: ["core"]; s.default_subspecs = :none → "none"; s.test_spec "Tests" → testspecs[0].name "Tests", + no "Tests" in subspecs */ }); + it("stores platform-scoped attributes under their platform", () => { /* s.ios.exclude_files = "a", s.osx.exclude_files + = "b", ss.ios.dependency "X" → ios: { exclude_files: "a" }, osx: { exclude_files: "b" }, subspecs[0].ios.dependencies + { X: [] }; s.platform = :ios, "12.0" → platforms { ios: "12.0" }; s.respond_to?(:visionos) is true */ }); + it("stores a singular alias under the plural key", () => { /* s.framework = "UIKit" → frameworks: "UIKit"; s.author = "a" → authors: "a" */ }); + it("refuses an attribute CocoaPods does not define", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo"\n s.not_an_attribute = 1\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "attribute"]); + expect(r.json.error.message).toBe(`${r.podspec}:3: the podspec sets s.not_an_attribute, which CocoaPods does not define`); + }); + it("names an unmodeled method with its line", () => { /* line 2 `sources_for("ios")` → kind "method", message + `:2: the podspec calls sources_for(…), which rn-xtool's podspec reader does not model` */ }); + it("names an unmodeled constant", () => { /* `Foo::Bar.baz` → kind "constant", message names Foo */ }); + it("names the library file a failure comes from", () => { /* require_relative "scripts/x" whose line 4 calls + nope() → message starts ` (scripts/x.rb:4): the podspec calls nope(…)` */ }); + it("passes the podspec's own raise on with its line", () => { /* line 2 `raise "boom"` → kind "raised", message `:2: boom` */ }); + it("refuses a file that is not a spec", () => { /* body `42` → kind "not-a-spec" */ }); + it("keeps the model out of the podspec's prints", () => { /* puts "{ not json }" before Pod::Spec.new → status 0, json.name "Foo", stdout contains "{ not json }" */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecShim.test.ts`. Expected: FAIL (the + shim file does not exist). + +- [ ] **Step 3: Write `vendor/rn-spm/spm/read-podspec-shim.rb`.** Header: the MIT notice React Native's scripts carry + without a copyright line (`# This source code is licensed under the MIT license found in the LICENSE file in the + root directory of this source tree.`). Ruby ≤ 2.7 syntax only. Decisions the tests do not fix: + - Evaluation as CocoaPods-core does it: `module Pod; def self._eval_podspec(string, path) eval(string, nil, path) + end; end`, so `self` is `Pod`, a podspec's top-level `def` lands on `Pod` (`Pod.respond_to?(:reactNativeWorkletsPath)` + works) and `Spec`, `Config`, `UI` resolve inside `Pod`. The source is read as UTF-8. The result must be a + `Pod::Specification` (`not-a-spec` otherwise). `Pod::Spec = Pod::Specification`. + - `Pod::Specification.new(parent = nil, name = nil) { |s| }` with the attribute table of CocoaPods 1.16's DSL, each + a setter and a getter (the getter returns what was set, `nil` otherwise): `name version swift_versions + cocoapods_version authors social_media_url license homepage readme changelog source summary description + screenshots documentation_url prepare_command static_framework deprecated deprecated_in_favor_of platforms + requires_arc frameworks weak_frameworks libraries compiler_flags pod_target_xcconfig user_target_xcconfig xcconfig + prefix_header_contents prefix_header_file module_name header_dir header_mappings_dir script_phases + on_demand_resources info_plist source_files public_header_files project_header_files private_header_files + vendored_frameworks vendored_libraries resource_bundles resources exclude_files preserve_paths module_map + default_subspecs requires_app_host app_host_name scheme test_type`, the singular aliases of the plural ones, and + the methods `dependency(name, *requirements)`, `platform=(value)`, `subspec`, `test_spec`, `app_spec`, and the + proxies `ios osx macos tvos visionos watchos` (each with `deployment_target=` and every non-root attribute; `macos` + stores under `osx`). Anything else through `method_missing` → `attribute`. `name` of a subspec reads `Parent/base`. + - `to_model` writes the shape of the Interfaces block; `__rn_xtool__` is filled by Task 2 and written as empty lists + here. + - Failures: rescue `NoMethodError`/`NameError` whose receiver is `Pod`, the main object or a shim object as + `method` (`e.name`; a capitalised name of a `NameError` as `constant`), any other `NoMethodError` (a `nil` + receiver) as `raised` with Ruby's message; `ScriptError`, `StandardError`, `SystemExit` as `raised`; then write the + error file and `exit 1`. + +- [ ] **Step 4: Run the tests to verify they pass.** Run: `npx vitest run tests/podspecShim.test.ts`. Expected: PASS. + +- [ ] **Step 5: Add the fix 29 hunk test** to "the patched RN files carry the patch": + `it("the scaffolder has the fix 29 shim", () => expect(existsSync(path.join(SPM, "read-podspec-shim.rb"))).toBe(true))`, + and to `tests/packageFiles.test.ts` ("the npm package", :29) `it("ships the podspec reader's shim")` asserting the + pack list holds `vendor/rn-spm/spm/read-podspec-shim.rb` (row 26). + +- [ ] **Step 6: Add the CI guards** to `.github/workflows/ci.yml`: a step `ruby --version` named "Ruby (the podspec + reader needs it)" before Test, and a job `shim-ruby-floor` on `ubuntu-22.04` (`actions/checkout@v7`, + `actions/setup-node@v7` node 22, `ruby/setup-ruby@v1` with `ruby-version: "2.7"`, `npm ci`, `npx vitest run + tests/podspecShim.test.ts`). When `setup-ruby` has no 2.7 for that runner, use the oldest it has and set the shim's + floor to it in the same commit: the floor is what CI proves. + +- [ ] **Step 7: Regenerate both 0.88 patches** with `docs/RELEASING.md` "Scaffolder changes" step 2, from the repo root. + `git diff --stat patches/` shows both files changed by the same amount and `cmp patches/react-native+0.88.0.patch + patches/react-native+0.88.1.patch` prints nothing. + +- [ ] **Step 8: Run the byte tests.** Run: `npx vitest run tests/vendor-rn-spm.test.ts tests/patches.test.ts + tests/patches-upstream.test.ts tests/rn-scaffolder.test.ts`. Expected: PASS, none of the provenance, identical-patch, + upstream dry-run or "carry the patch" tests skipped. + +- [ ] **Step 9: Commit.** + + ```bash + git add vendor/rn-spm/spm/read-podspec-shim.rb patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch \ + tests/podspecShim.test.ts tests/support/ruby.ts tests/rn-scaffolder.test.ts tests/packageFiles.test.ts .github/workflows/ci.yml + npm run scan:private + git commit -m "feat: add the podspec reader's Ruby shim" + ``` + +### Task 2: The shim's CocoaPods and React Native environment + +**Files:** +- Modify: `vendor/rn-spm/spm/read-podspec-shim.rb` +- Modify: `tests/podspecShim.test.ts` +- Modify: both 0.88 patches (regenerated) + +**Interfaces:** +- Consumes: Task 1's command line, model and error kinds. +- Produces: `__rn_xtool__` filled: `env` (every `ENV` name read), `helpers` (`install_modules_dependencies`, + `add_dependency`, `get_folly_config`, `min_ios_version_supported`, `spm_dependency`, as called), `ui` (each + `Pod::UI` line), `spm_dependencies`. + +The surface, verified by a static scan (Ruby's `Ripper`, nothing evaluated) of 31 distinct podspecs of the reference +apps and the Expo SDK 57/58 references, 15 of the one-off sweep of 2026-11-06, the 7 fixtures in +`tests/fixtures/podspecs/`, and the 7 `scripts/*.rb` files they `require_relative`: + +| Call | Where | Shim | +|---|---|---| +| `Pod::Spec.new`, attributes, `subspec`, `test_spec`, `s.ios/osx/tvos/visionos.*`, `dependency`, `s.respond_to?(:visionos)`, getters `s.name`/`s.version`/`s.summary` | all | Task 1 | +| `install_modules_dependencies` (28), `respond_to?(:install_modules_dependencies, true)` (4), `defined?(install_modules_dependencies…)` (4) | podspecs | recorded; a private method on `Object` | +| `add_dependency` (5) | gesture-handler, Expo | `spec.dependency(subspec ? "#{pod}/#{subspec}" : pod, *[version].compact)`, recorded | +| `get_folly_config` (4) | Expo | fresh `{ version: "2024.11.18.00", git: "https://github.com/facebook/folly.git", compiler_flags: "-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32" }` per call (callers mutate it), recorded | +| `min_ios_version_supported` | spec A.3 | `"15.1"`, recorded | +| `spm_dependency(spec, url:, requirement:, products:)` | spec A.3, row 12 | recorded with its arguments | +| `use_expo_modules!` under `defined?` (2) | `Expo.podspec` | not defined: `defined?` answers `nil` | +| `Expo::PackagesConfig.instance.coreFeatures` (under `defined?`) and `.try_link_with_prebuilt_xcframework(s)` (unconditional) | `ExpoModulesCore.podspec` | singleton: `coreFeatures` → `[]`, `try_link_with_prebuilt_xcframework` → `false` (a source build), as expo-modules-autolinking's `packages_config.rb` answers without prebuilt modules | +| `Pod::UI.puts` (6); `Pod::UI.warn`/`.info` (spec A.3) | vision-camera, video, screens | captured into `ui`, not printed | +| `Pod::Config.instance` (13): `installation_root` (9), `project_root` (4), `project_pods_root` (6), `instance_variable_defined?(:@podfile)` | Expo, worklets, reanimated, svg, gesture-handler scripts | `Pathname`s from the fourth argument; `project_pods_root` = root + `Pods`; no `@podfile` | +| `Pod::VERSION` with `Gem::Version` (5) | Expo modules | `"1.16.2"`; RubyGems stays enabled (no `--disable-gems`: `Gem::Version` is needed) | +| `require 'json'` (all), `require 'rubygems'`, `require 'colored2'` (2), `require_relative` (10), `Pathname` (6) | all | a name on Ruby's own `$LOAD_PATH` (captured at start, before any gem activates) loads; `colored2` loads a stub whose `String` colour methods return the string; any other name → `require` | +| backticks (13) and `system` (5) running `node`, `abort` (2), `raise` (7) | worklets, reanimated, Expo, vision-camera | real Ruby | +| `ENV[…]`, `ENV.fetch`, `ENV.key?`/`include?`: 13 names in podspecs, 2 more in scripts | — | names recorded into `env` | +| globals `$VCEnable*`, `$RNVideoUse*` (under `defined?`), `$ExpoUseSources&.`, `$expo_warned_about_missing_autolinking` | — | plain Ruby: unset | + +React Native's other helpers of fact 8 (`folly_flags`, `resolve_use_frameworks`, `create_header_search_path_for_frameworks`, +`podspec_sources`, `get_*_config` other than folly, `set_*_config`, `rct_cxx_language_standard`, `rncore_pod`, +`mark_as_react_native_build`, `use_react_native!`) are called by none of the scanned podspecs: they stay undefined +and a call fails as `method`. Task 13 adds one when the sweep meets it. + +- [ ] **Step 1: Write the failing tests** in `tests/podspecShim.test.ts`, `describe("the environment")`: + + ```ts + it("captures Pod::UI and does not print it", () => { /* Pod::UI.puts "hi"; Pod::UI.warn "w" → ui ["hi", "w"], stdout "" */ }); + it("answers Pod::Config with the installation root", () => { /* s.summary = [installation_root, project_root, + project_pods_root].map(&:to_s).join("|") with root "/r/ios" → "/r/ios|/r/ios|/r/ios/Pods"; + instance_variable_defined?(:@podfile) false */ }); + it("is CocoaPods 1.16.2 to Gem::Version checks", () => { /* s.summary = (Gem::Version.new(Pod::VERSION) >= Gem::Version.new("1.13.0")).to_s → "true" */ }); + it("records React Native's helpers", () => { /* install_modules_dependencies(s); add_dependency(s, "React-Codegen", + subspec: "x"); f = get_folly_config()[:compiler_flags]; f << " -DMORE"; s.compiler_flags = get_folly_config()[:compiler_flags]; + s.ios.deployment_target = min_ios_version_supported; spm_dependency(s, url: "u", requirement: {kind: "exact"}, products: ["P"]) + → dependencies has "React-Codegen/x"; compiler_flags equals the folly string without " -DMORE"; platforms.ios "15.1"; + helpers sorted; spm_dependencies [{url:"u", requirement:{kind:"exact"}, products:["P"]}]; no React-Core added */ }); + it("answers defined? and respond_to? as React Native's Podfile does", () => { /* defined?(install_modules_dependencies()) → "method"; + respond_to?(:install_modules_dependencies, true) → true; defined?(use_expo_modules!) → nil; folly_flags() → kind "method" */ }); + it("answers Expo's PackagesConfig for a source build", () => { /* coreFeatures → []; try_link_with_prebuilt_xcframework(s) → false */ }); + it("stubs colored2 and refuses other gems", () => { /* require 'colored2'; s.summary = "x".yellow → "x"; + require 'xcodeproj' → kind "require", message `: cannot load such file -- xcodeproj; rn-xtool's podspec reader stubs only colored2` */ }); + it("records the ENV names a podspec reads", () => { /* ENV['A']; ENV.fetch('B', nil); ENV.key?('C'); + s.summary = ENV['RCT_NEW_ARCH_ENABLED'] → env ["A","B","C","RCT_NEW_ARCH_ENABLED"], summary "1" */ }); + it("runs node from the installation root", () => { /* root has node_modules/react-native/package.json {version "0.88.1"}; + s.version = `cd "#{Pod::Config.instance.installation_root}" && node --print "require('react-native/package.json').version"`.strip; + s.summary = system("node -e 'process.exit(0)'").to_s → version "0.88.1", summary "true" */ }); + it("passes worklets 0.8.3's own stop on", () => { /* the fixture tests/fixtures/podspecs/RNWorklets-0.8.3 copied into a + project without react-native → kind "raised", message starts ` (scripts/worklets_utils.rb:31): [Worklets] Unable to recognize your` (row 7) */ }); + it("writes UTF-8 values when LANG is C", () => { /* package.json description "Ünïcødé ❤️", env LANG=C, + s.summary = JSON.parse(File.read(File.join(__dir__, "package.json")))["description"] → summary "Ünïcødé ❤️" */ }); + it.skipIf(...)("holds the folly flags and iOS floor every supported line defines", () => { /* for each cached + react-native@0.85.0, 0.86.3, 0.87.1, 0.88.0, 0.88.1: package/scripts/cocoapods/helpers.rb contains the shim's + compiler_flags string, `return '15.1'` in min_ios_version_supported; skip with needsTarball's text */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecShim.test.ts`. Expected: FAIL (the + helpers, `Pod::UI`, `Pod::Config`, `Pod::VERSION` and the stubs are undefined). + +- [ ] **Step 3: Implement the table above in the shim.** `Encoding.default_external = Encoding::UTF_8` before anything + reads a file. `ENV` recording prepends a module to `ENV.singleton_class` for `[] fetch key? has_key? include? + member? values_at`. + +- [ ] **Step 4: Run the tests to verify they pass.** Run: `npx vitest run tests/podspecShim.test.ts`. Expected: PASS. + +- [ ] **Step 5: Regenerate both 0.88 patches** (RELEASING step 2) and **run the byte tests** (Global Constraints). + Expected: PASS, nothing skipped. + +- [ ] **Step 6: Commit.** + + ```bash + git add vendor/rn-spm/spm/read-podspec-shim.rb patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch tests/podspecShim.test.ts + npm run scan:private + git commit -m "feat: model CocoaPods and React Native helpers" + ``` + +### Task 3: Choosing the reader and running the shim + +**Files:** +- Modify: `vendor/rn-spm/spm/read-podspec.js` (new section after the requires, before "Regex fallback" at :165) +- Create: `tests/podspecReader.test.ts` +- Modify: both 0.88 patches (regenerated) + +**Interfaces:** +- Consumes: Task 1's command line, probe output and error file. +- Produces (exported from `read-podspec.js`): + - `podspecReader(opts?: {env?: {[string]: ?string}, shim?: string}): PodspecReaderChoice`, where + `PodspecReaderChoice = {reader: 'ruby', ruby: string, forced: false, warning: ?string} | {reader: 'reduced', why: + string, forced: boolean, warning: ?string}`. `why` is one of `Ruby was not found`, `ruby is older than `, + `ruby cannot load json`, `ruby could not run the podspec reader ()`, `the podspec reader's Ruby + shim is missing from `, `RN_XTOOL_PODSPEC_READER=reduced is set` (`forced: true`). Any other value of the + variable sets `warning` to `RN_XTOOL_PODSPEC_READER= is not a reader rn-xtool knows (only reduced); reading + podspecs with Ruby` and is otherwise ignored. The probe (`ruby --probe`, 10 s) is memoised per `PATH`; the + variable is read on every call. + - `runPodspecShim(podspecPath: string, opts?: {timeoutMs?: number, installationRoot?: string}): {raw: RawSpec, + output: string}` — throws `PodspecReadError`. + - `class PodspecReadError extends Error` with `code = 'RN_SPM_PODSPEC_READ'`, `kind`, and `isPodspecReadError(e: + mixed): boolean`. + - `installationRootFor(podspecPath: string): string` — `process.env.RN_SPM_APP_IOS_DIR` when set, else the path as + given (not resolved through symlinks) cut before its first `/node_modules/` segment plus `/ios`, else the podspec's + folder. + +- [ ] **Step 1: Write the failing tests** in `tests/podspecReader.test.ts` (loads the vendored `read-podspec.js`; fake + `ruby` scripts are shell files in a temp `bin` put first on a stubbed `PATH`): + + ```ts + it("reads with the reduced reader when Ruby is not found", () => expect(podspecReader({ env: { PATH: emptyBin } })).toEqual({ reader: "reduced", why: "Ruby was not found", forced: false, warning: null })); + it("says why a Ruby is unusable", () => { /* fake ruby printing {"ruby":"2.5.1","floor":"2.7.0","usable":false,"why":"ruby 2.5.1 is older than 2.7.0"} + → why "ruby 2.5.1 is older than 2.7.0"; fake ruby `echo "cannot load such file -- json" >&2; exit 1` → "ruby cannot load json"; + fake ruby `echo "syntax error, unexpected" >&2; exit 1` → "ruby could not run the podspec reader (syntax error, unexpected)" */ }); + it("is forced to the reduced reader by RN_XTOOL_PODSPEC_READER=reduced", () => { /* → { reader: "reduced", why: "RN_XTOOL_PODSPEC_READER=reduced is set", forced: true } */ }); + it("names an unknown RN_XTOOL_PODSPEC_READER value", () => { /* "REDUCED" → reader "ruby", warning "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby" */ }); + it("says when the shim is missing", () => { /* shim: "/none.rb" → why "the podspec reader's Ruby shim is missing from /none.rb" */ }); + it("probes Ruby once per PATH", () => { /* fake ruby appending to a counter file; three calls → one line */ }); + it("runs the podspec with a fixed environment", () => { /* parent env RUBYOPT=-rnonexistent, BUNDLE_GEMFILE=/x, GEM_HOME=/y, + RCT_NEW_ARCH_ENABLED=0 → read succeeds; s.summary = [ENV['RUBYOPT'], ENV['GEM_HOME'], ENV['RCT_NEW_ARCH_ENABLED']].inspect → '[nil, nil, "1"]' */ }); + it("runs the podspec in its folder", () => { /* podspec reads File.read("./flags.json") → its value */ }); + it("gives the podspec an empty stdin", () => { /* s.summary = $stdin.read.to_s.length.to_s → "0", in under 5 s */ }); + it("stops a podspec that does not finish", () => { /* sleep 5 with timeoutMs 1000 → PodspecReadError " did not finish in 1 s. Set RN_XTOOL_PODSPEC_READER=reduced …" */ }); + it("ends a shim gap with how to go on", () => { /* sources_for("ios") → message === `${shimMessage} Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report.` and kind "method"; a podspec's own raise keeps the shim's message alone */ }); + it("finds the installation root", () => { /* RN_SPM_APP_IOS_DIR=/a/ios → "/a/ios"; unset: "/p/node_modules/@s/x/X.podspec" → "/p/ios"; + "/p/node_modules/expo/node_modules/y/ios/Y.podspec" → "/p/ios"; "/q/X.podspec" → "/q" */ }); + it("reads a library reached through a symlink", () => { /* /node_modules/lib → symlink to /lib whose podspec + require_relative's scripts/v.rb and reads __dir__/package.json; read through the link path → status ok, version from + package.json, installation root "/ios" */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecReader.test.ts`. Expected: FAIL + (`podspecReader` is not exported). + +- [ ] **Step 3: Implement the four exports in `read-podspec.js`.** `runPodspecShim` spawns `spawnSync('ruby', [shim, + podspec, out, root], {cwd: dirname(podspec), env: {PATH, HOME, LANG, ...RN_POD_ENV}, stdio: ['ignore', 'pipe', + 'pipe'], timeout, killSignal: 'SIGKILL', maxBuffer: 8 MiB})` with `out` in a fresh `fs.mkdtempSync(os.tmpdir())` + folder removed afterwards; no out file → `PodspecReadError` `: ruby exited with : `. The shim path is `path.join(__dirname, 'read-podspec-shim.rb')`. A timeout says `did not finish in + s`. Gap kinds (`method`, `constant`, `attribute`, `require`, `not-a-spec`) and the timeout get the + remedy sentence; `raised` keeps the shim's message. + +- [ ] **Step 4: Run the tests to verify they pass.** Run: `npx vitest run tests/podspecReader.test.ts`. Expected: PASS. + +- [ ] **Step 5: Regenerate both 0.88 patches and run the byte tests** (Global Constraints). Expected: PASS, nothing + skipped. + +- [ ] **Step 6: Commit.** + + ```bash + git add vendor/rn-spm/spm/read-podspec.js patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch tests/podspecReader.test.ts + npm run scan:private + git commit -m "feat: pick the podspec reader and run the shim" + ``` + +### Task 4: `readPodspec` reads with the shim, never `pod ipc spec` + +**Files:** +- Modify: `vendor/rn-spm/spm/read-podspec.js` (remove `patchPodspecForPodIpc` :57–84, `runPodIpcSpec` :86–156, + `cleanupPatchedPodspec` :158–167 and the export at :2660; rewrite `readPodspec` :2512–2535, `readPodspecCached` + :2572–2588, the advice in `unresolvedSourcesReason` :2478–2499; the file comment :15–28) +- Modify: `vendor/rn-spm/spm/spm-types.js` (`PodspecModel`, :423–478) +- Modify: `tests/podspecReader.test.ts`, `tests/rn-scaffolder.test.ts` (:155–160, :1518–1537, `podspecCopy`'s comment + :70–80), `tests/vendor-rn-spm.test.ts` (E2 test :96–118) +- Modify: both 0.88 patches (regenerated) + +**Interfaces:** +- Consumes: `podspecReader`, `runPodspecShim`, `PodspecReadError` (Task 3). +- Produces: + - `readPodspec(path, opts)`: with `reader === 'ruby'`, `flattenSubspecs(runPodspecShim(path).raw, opts)` and no + fallback (a `PodspecReadError` propagates); else `regexPodspec` as today. On both paths `name`, `moduleName` and + `version` are `regexPodspec(path)`'s literal readings (`IDENTITY_FIELDS`, :299; row 15). + - `PodspecModel` gains `reader: 'ruby' | 'reduced'`; `partial` is true only for the reduced reader; + `usesInstallModulesDependencies` is `__rn_xtool__.helpers.includes('install_modules_dependencies')` on the Ruby + path and today's source regex on the reduced one. + - `readPodspecCached` keys on path, the sorted `dropSubspecs` and the reader. + - Each read that is not a cache hit appends one JSON line to `process.env.RN_SPM_PODSPEC_READS` when set: + `{"podspec": , "reader", "why"?, "forced", "ruby"?, "warning"?, "env": [], "helpers": [], "ok": + boolean, "error"?: }`. Consumed by Task 10. + - `unresolvedSourcesReason`'s last sentence: `Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as + CocoaPods does, or give the library a Package.swift of its own.` + +- [ ] **Step 1: Write the failing tests** in `tests/podspecReader.test.ts`, `describe("readPodspec")`: + + ```ts + it("reads with Ruby and says so", () => { /* model.reader "ruby", partial false */ }); + it("never falls back after a shim failure", () => { /* sources_for("ios") podspec → readPodspec throws PodspecReadError (kind "method") */ }); + it("reads with the reduced reader when forced", () => { /* stubEnv RN_XTOOL_PODSPEC_READER=reduced → reader "reduced", partial true */ }); + it("keeps the literal identity fields", () => { /* s.name = package['name'], s.version = package['version'], package.json + name "react-native-foo" → name "" and version "" under both readers; s.module_name = "Foo" → "Foo" under both */ }); + it("marks React core from the helper actually called", () => { /* `install_modules_dependencies(s) if false` → false with Ruby, true reduced */ }); + it("caches per reader", () => { /* readPodspecCached twice, forced reduced in between → two models, readers ruby then reduced */ }); + it("never runs pod", () => { /* a `pod` stub on PATH that touches a marker file → no marker; "runPodIpcSpec" not exported */ }); + it("appends each read to RN_SPM_PODSPEC_READS", () => { /* one ok line {reader:"ruby", env:[…], helpers:[…], ok:true}; a failing + podspec adds {ok:false, error:}; a cache hit adds none */ }); + it("tells a refused glob to install Ruby", () => { /* forced reduced, s.source_files = sources_for("ios") → unresolvedSourcesReason ends with the sentence above */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecReader.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the Interfaces block** and update the file comment (:15–28) and `PodspecModel`'s comments on + `dependencies`, `partial` and `usesInstallModulesDependencies` to the shim. Keep `RN_POD_ENV` (the evaluator and the + shim's environment use it) and `findPodspecs`' skip of `.spm-scaffold-*` leftovers. + +- [ ] **Step 4: Pin the reduced reader where a test asserts its behaviour.** Run `npm test` with Ruby on `PATH`. A + failing test whose assertion is the reduced reader's (a `! … Left out of` warning, fix 28's refusal text, `partial`, + `__unresolved__`, an inline podspec that is not valid Ruby) gets `vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")` + in its `describe`'s `beforeEach` (in `tests/rn-scaffolder.test.ts` the fixes 1–28 blocks, in + `tests/vendor-rn-spm.test.ts` the E2 test). Replace the fix 14–19 hunk assertion `toContain("env: {...process.env, + ...RN_POD_ENV}")` (:158) with `toContain("...RN_POD_ENV")` (the shim's environment, Task 3), and the fix 19 test (:1518) with + `it("19: the shim reads both variables as 1, whatever the environment says")` (stub both to `0`, `""`, `true`; + `s.summary = ENV['RCT_NEW_ARCH_ENABLED'] + ENV['RCT_HERMES_V1_ENABLED']` → `"11"`). Any other failure is a + difference between the readers: list it in the task's report, do not pin it. + +- [ ] **Step 5: Run the tests to verify they pass.** Run: `npm test`. Expected: PASS (skips only those that skipped + before). + +- [ ] **Step 6: Regenerate both 0.88 patches and run the byte tests.** Expected: PASS, nothing skipped. + +- [ ] **Step 7: Commit.** + + ```bash + git add vendor/rn-spm/spm/read-podspec.js vendor/rn-spm/spm/spm-types.js patches/react-native+0.88.0.patch \ + patches/react-native+0.88.1.patch tests/podspecReader.test.ts tests/rn-scaffolder.test.ts tests/vendor-rn-spm.test.ts + npm run scan:private + git commit -m "feat: read podspecs with Ruby, drop pod ipc spec" + ``` + +### Task 5: The consumer: the `ios` merge, unapplied keys, `spm_dependency` + +**Files:** +- Modify: `vendor/rn-spm/spm/read-podspec.js` (`flattenSubspecs`, :2011–2470; a new `spmDependencyReason` beside + `unresolvedSourcesReason`) +- Modify: `vendor/rn-spm/spm/scaffold-package-swift.js` (after the unresolved check at :2294) +- Modify: `vendor/rn-spm/spm/spm-types.js`, `tests/podspecReader.test.ts`, both 0.88 patches + +**Interfaces:** +- Consumes: the model (Task 1), `readPodspec` (Task 4). +- Produces: + - `flattenSubspecs` merges each layer's `ios` object over the layer as CocoaPods' consumer does for an iOS target: + arrays (or a string read as a one-element array) concatenated, root first; hashes merged key by key with two + string values joined by one space; anything else the platform's value. `osx`, `tvos`, `visionos`, `watchos` are + never read. `dropSubspecs` applies unchanged. + - A warning per key a CocoaPods build applies and the scaffold does not, in any selected layer or its `ios`: + `script_phases`, `prepare_command`, `info_plist`, `module_map` → `The podspec sets , which a CocoaPods build + applies and rn-xtool's scaffold does not.` (printed by the driver as ` ! : …`). + - `PodspecModel.spmDependencies: Array<{url: string, products: Array}>` from `__rn_xtool__`. + - `spmDependencyReason(podspecPath, model): ?string` → `: uses spm_dependency(url: , products: + ), which rn-xtool does not map yet`; the scaffold returns `status: 'error'` with it (row 12). + +- [ ] **Step 1: Write the failing tests** (`describe("flattenSubspecs on the shim's model")`; the JSON ones need no Ruby): + + ```ts + it("merges ios attributes over each layer", () => { + const m = flattenSubspecs({ name: "Foo", source_files: "a/**/*.m", exclude_files: "x", ios: { exclude_files: "**/*.macos.m" }, + osx: { exclude_files: "**/*.ios.m" }, pod_target_xcconfig: { OTHER_CFLAGS: "-DA" }, subspecs: [{ name: "c", ios: { pod_target_xcconfig: { OTHER_CFLAGS: "-DB" } } }] }); + expect(m.excludeFiles).toEqual(["x", "**/*.macos.m"]); + expect(m.preprocessorDefines.map((d) => d.name)).toEqual(["A", "B"]); + }); + it("warns about keys the scaffold does not apply", () => { /* script_phases on the root, info_plist in ios → two warnings with the text above */ }); + it("refuses a library that declares a SwiftPM dependency", () => { /* __rn_xtool__.spm_dependencies [{url:"https://x/y", products:["Y"]}] + → scaffoldPackageSwiftForDep status "error", reason ": uses spm_dependency(url: https://x/y, products: Y), which rn-xtool does not map yet" */ }); + it("reads react-native-svg 15.16.0's iOS excludes with Ruby", () => { /* tarball podspec: excludeFiles contains "**/*.macos.{h,m,mm}", + not "**/*.ios.{h,m,mm}", not "apple/Utils/RNSVGFabricConversions.h" */ }); + it("reads react-native-screens 4.24.0's locals with Ruby", () => { /* fixture: sourceFiles contains "ios/**/*.{h,m,mm,cpp,swift}", + excludeFiles ["ios/gamma/**/*.{h,m,mm,cpp,swift}"], and the common subspec's globs */ }); + it("selects gesture-handler 2.32.0's subspecs with Ruby as with the reduced reader", () => { /* fixture: sourceFiles and dependencies equal under both readers */ }); + it("drops a subspec on Ruby's model as on the reduced one", () => { /* a vision-camera-shaped podspec: subspec "FrameProcessors" + under `if enableFrameProcessors` with `ss.dependency "react-native-worklets-core"`, $VCEnableFrameProcessors under defined?, + Pod::UI.puts lines → dropSubspecs ["FrameProcessors"] leaves its sources and dependency out under both readers */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecReader.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the Interfaces block.** The merge happens once per layer before every reader in + `flattenSubspecs` uses `layers` (:2045). + +- [ ] **Step 4: Run the tests to verify they pass.** Run: `npx vitest run tests/podspecReader.test.ts + tests/rn-scaffolder.test.ts`. Expected: PASS. + +- [ ] **Step 5: Regenerate both 0.88 patches and run the byte tests.** Expected: PASS, nothing skipped. + +- [ ] **Step 6: Commit.** + + ```bash + git add vendor/rn-spm/spm/read-podspec.js vendor/rn-spm/spm/scaffold-package-swift.js vendor/rn-spm/spm/spm-types.js \ + patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch tests/podspecReader.test.ts + npm run scan:private + git commit -m "feat: merge ios attributes of the shim's model" + ``` + +### Task 6: Reader failures propagate from autolinking and name reads + +**Files:** +- Modify: `vendor/rn-spm/spm/generate-spm-autolinking.js` (`extractPodspecHeaderSearchPaths`, :827–849) +- Modify: `vendor/rn-spm/spm/expand-spm-dependencies.js` (`podspecFor`, :305–314; `defaultReadPodspec`, :470–486) +- Modify: `tests/podspecReader.test.ts`, both 0.88 patches + +**Interfaces:** +- Consumes: `isPodspecReadError` (Task 3). +- Produces: the three catches rethrow when `isPodspecReadError(e)`; any other error keeps today's result (`[]`, + `null`). The driver prints the message as `rn-spm-generate: ` and exits 1, so `rn-spm` stops with it in its + tail (R3, row 10). + +- [ ] **Step 1: Write the failing tests:** + + ```ts + it("stops autolinking on a shim failure", () => { /* autolinkingDepToSpmTarget (generate-spm-autolinking.js:872) for a dep whose + podspec calls sources_for → throws a PodspecReadError naming the podspec */ }); + it("stops name resolution on a shim failure", () => { /* defaultReadPodspec(root, podspec) with s.name = compute_name() (no literal) → throws */ }); + it("keeps the old answer for an unreadable file", () => { /* podspec path that does not exist → defaultReadPodspec null, header paths [] */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecReader.test.ts`. Expected: FAIL (the + catches return `[]`/`null`). + +- [ ] **Step 3: Rethrow in the three catches.** + +- [ ] **Step 4: Run the tests to verify they pass.** Expected: PASS. + +- [ ] **Step 5: Regenerate both 0.88 patches and run the byte tests.** Expected: PASS, nothing skipped. + +- [ ] **Step 6: Commit.** + + ```bash + git add vendor/rn-spm/spm/generate-spm-autolinking.js vendor/rn-spm/spm/expand-spm-dependencies.js \ + patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch tests/podspecReader.test.ts + npm run scan:private + git commit -m "fix: stop rn-spm on a podspec reader failure" + ``` + +### Task 7: The reader in the scaffold marker, revision 8, fix 29 + +**Files:** +- Modify: `vendor/rn-spm/spm/scaffold-package-swift.js` (revision :121–139; marker emission :1944–1947; the result of + `scaffoldPackageSwiftForDep` at :2503) +- Modify: `src/pipeline/patches.ts:362` (`SCAFFOLD_REVISION = 8`) +- Modify: `scripts/rn-spm-generate.js` (`writeResults`, :225–243: copies `reader`) +- Modify: `tests/rn-scaffolder.test.ts` (revision literals :160, :1112, :1125, :1132, :1217, :1320, :1335, :2154, + :2166; the golden test :1202–1221), `tests/capabilities.test.ts:608`, `tests/support/rnScaffold.ts`, + `tests/fixtures/scaffold-golden/**` (regenerated) +- Modify: `docs/upstream/react-native-scaffolder.md` (a "29." section before "Known limitation", :876; the Tests + paragraph :886), `vendor/rn-spm/README.md:9` ("The 29 fixes"), both 0.88 patches + +**Interfaces:** +- Consumes: `PodspecModel.reader` (Task 4). +- Produces: each scaffolded manifest's marker block ends with `// rn-xtool-podspec-reader: `, after the + slot comment (`slotComment`, :1662), so the existing adjacency of the revision, importer-paths, pods and slot lines + is unchanged; the scaffold result and the driver's results file carry `reader`. Consumed by Task 9 and plan C. + +- [ ] **Step 1: Write the failing tests** in `tests/rn-scaffolder.test.ts`: + + ```ts + it("29: records the podspec reader in the marker", () => { /* scaffold a fixture with Ruby → manifest matches + /^\/\/ Cache slot: .+\n\/\/ rn-xtool-podspec-reader: ruby$/m; forced reduced → "reduced"; result.reader equals it */ }); + ``` + + and change every `revision: 7` literal listed above to 8 and `RN_XTOOL_SCAFFOLD_REVISION = 7` (:160) to 8. + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/rn-scaffolder.test.ts + tests/capabilities.test.ts tests/patches.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the marker line and the revision.** `RN_XTOOL_SCAFFOLD_REVISION = 8`, with the comment + "Revision 8 (fix 29): podspecs read by real Ruby through read-podspec-shim.rb, `ios` attributes merged, and the + reader recorded in the marker." `SCAFFOLD_REVISION = 8` in `src/pipeline/patches.ts`. + +- [ ] **Step 4: Make the golden run under Ruby.** `scaffoldLibraries` (`tests/support/rnScaffold.ts:81`) writes + `/app/package.json` (`{"name":"app","version":"1.0.0"}`) and `/node_modules/react-native/package.json` + (version 0.86.3, as `withRnRoot`) and sets `RN_SPM_APP_IOS_DIR` to `/app/ios` for the run. The golden test + skips without Ruby (`needsRuby` in its title) and, with `RN_XTOOL_WRITE_GOLDEN=1`, writes `statuses.json` and the + files instead of comparing (a `writeGolden()` beside `readGolden()`). + +- [ ] **Step 5: Run the tests to verify they pass, then regenerate the scaffold goldens.** Run: `npx vitest run + tests/rn-scaffolder.test.ts tests/capabilities.test.ts tests/patches.test.ts` (PASS), then + `RN_XTOOL_WRITE_GOLDEN=1 npx vitest run tests/rn-scaffolder.test.ts -t golden` with the reference app at `../app` + (or `RN_XTOOL_REF_APP`), then once more without the variable (PASS). Read `git diff tests/fixtures/scaffold-golden`: + every change is the revision line, the reader line, or a difference the shim explains (the `ios` merge, values fix 28 + left out). List each non-marker change in the task's report. + +- [ ] **Step 6: Document fix 29** in `docs/upstream/react-native-scaffolder.md`: what failed (fact 6's ignored `ios` + keys on the `pod` path, fact 4's stripped helpers, fix 28's partial reads), the shim's surface (Task 2's table in + prose), the failure kinds, the reads file, and the marker line; the Tests paragraph names `tests/podspecShim.test.ts`, + `tests/podspecReader.test.ts` and the sweep. `vendor/rn-spm/README.md`: "The 29 fixes". + +- [ ] **Step 7: Regenerate both 0.88 patches and run the byte tests.** Expected: PASS, nothing skipped. + +- [ ] **Step 8: Commit.** + + ```bash + git add vendor/rn-spm/spm/scaffold-package-swift.js src/pipeline/patches.ts scripts/rn-spm-generate.js tests/rn-scaffolder.test.ts \ + tests/capabilities.test.ts tests/support/rnScaffold.ts tests/fixtures/scaffold-golden docs/upstream/react-native-scaffolder.md \ + vendor/rn-spm/README.md patches/react-native+0.88.0.patch patches/react-native+0.88.1.patch + npm run scan:private + git commit -m "feat: record the podspec reader, revision 8" + ``` + +### Task 8: `ruby` in `doctor` and `setup` + +**Files:** +- Create: `src/tools/podspecReader.ts` +- Modify: `src/commands/doctor.ts` (`DoctorProbes` :60–95, `realProbes` :171–225, a `ruby` check after `node` at + :535–540, for both the full run and `projectOnly` :541–547) +- Modify: `src/commands/setup.ts` (`SetupDeps` :19–31; a line before the "Nothing to do" return :333–336 and on every + other path) +- Modify: `tests/doctor.test.ts` (`good` :69), `tests/report.test.ts` (`probes` :70), `tests/setup.test.ts`, + `tests/podspecReader.test.ts` + +**Interfaces:** +- Consumes: `podspecReader()` (Task 3) through `createRequire` of `vendor/rn-spm/spm/read-podspec.js`, as + `earlyChecks.ts:89–100` loads the vendored Expo readers. +- Produces: + - `podspecReaderHere(env?: NodeJS.ProcessEnv): PodspecReaderChoice` and the TS type `PodspecReaderChoice` (same + shape as Task 3's). Consumed by Tasks 9, 10 and plan C. + - `rubyCheck(c: PodspecReaderChoice): Omit`: `ok` `3.3.8`; Ruby with `warning` → `warn` + `3.3.8; `; forced → `warn` `RN_XTOOL_PODSPEC_READER=reduced is set — podspecs are read with the reduced + reader`; otherwise `warn` ` — podspecs are read with the reduced reader; + sudo apt install ruby`. + - `DoctorProbes.podspecReader: () => PodspecReaderChoice`; `SetupDeps.podspecReader`. + - `setup` prints `✔ ruby ` or `⚠ : rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo + apt install ruby`, and installs nothing. + +- [ ] **Step 1: Write the failing tests:** + + ```ts + // tests/doctor.test.ts + it("reports Ruby", async () => { /* podspecReader → {reader:"ruby", ruby:"3.3.8"} → check { name: "ruby", status: "ok", detail: "3.3.8" } right after node */ }); + it("warns without Ruby, also under --project", async () => { /* {reader:"reduced", why:"Ruby was not found"} with projectOnly + → { name: "ruby", status: "warn", detail: "not found — podspecs are read with the reduced reader; sudo apt install ruby" }, report.ok true */ }); + it("names the forced reduced reader", async () => { /* forced → detail "RN_XTOOL_PODSPEC_READER=reduced is set — podspecs are read with the reduced reader" */ }); + // tests/setup.test.ts + it("says whether Ruby is there and installs nothing", async () => { /* nothing to do + no Ruby → log contains the ⚠ line above; with Ruby "✔ ruby 3.3.8" */ }); + // tests/podspecReader.test.ts + it("doctor and the scaffolder pick the same reader", () => { /* podspecReaderHere({ ...process.env, RN_XTOOL_PODSPEC_READER: "reduced" }) equals the JS podspecReader's answer */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/doctor.test.ts tests/setup.test.ts + tests/report.test.ts tests/podspecReader.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the Interfaces block**; add `podspecReader` to the `good` and `probes` fixtures. + +- [ ] **Step 4: Run the tests to verify they pass.** Same command. Expected: PASS. Then `npm run lint`: clean. + +- [ ] **Step 5: Commit.** + + ```bash + git add src/tools/podspecReader.ts src/commands/doctor.ts src/commands/setup.ts tests/doctor.test.ts tests/report.test.ts \ + tests/setup.test.ts tests/podspecReader.test.ts + npm run scan:private + git commit -m "feat: report Ruby in doctor and setup" + ``` + +### Task 9: Persisted scaffolds name their reader + +**Files:** +- Modify: `src/pipeline/patches.ts` (`scaffoldPatchFindings` :433–503, `scaffoldPatchWarnings` :513–520) +- Modify: `tests/patches.test.ts` (the scaffold patch helper :874) + +**Interfaces:** +- Consumes: the marker line (Task 7), `podspecReaderHere` (Task 8). +- Produces: `scaffoldReaderOf(patchText: string): "ruby" | "reduced" | undefined` (regex `^\+\/\/ + rn-xtool-podspec-reader: (ruby|reduced)\s*$`); a finding kind `"reader"` checked after `slot` and `revision` and + before `pins`, using `podspecReaderHere()` computed once per call, only when a patch has the line (an injectable + `reader?: PodspecReaderChoice` last parameter for tests): + - patch `reduced`, here Ruby: `⚠ patches/ was written by the reduced podspec reader; Ruby is available here: + delete it so rn-xtool regenerates it ` (`tail` as today, :467); + - patch `ruby`, here reduced: `⚠ patches/ was written by the Ruby podspec reader, and this machine reads + podspecs with the reduced one (): keep the patch, and install Ruby (sudo apt install ruby) before you + regenerate it`. + +- [ ] **Step 1: Write the failing tests:** + + ```ts + it("warns when a reduced-reader scaffold meets Ruby", () => { /* patch with reader reduced, reader {ruby} → the first line above */ }); + it("warns when a Ruby scaffold meets the reduced reader", () => { /* reader ruby, here {reduced, why:"Ruby was not found"} → the second line */ }); + it("says nothing when the readers agree or the patch is older", () => { /* same reader → no line; revision 7 without the line → the revision line only */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/patches.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the Interfaces block.** + +- [ ] **Step 4: Run the tests to verify they pass.** Expected: PASS; `npm run lint` clean. + +- [ ] **Step 5: Commit.** + + ```bash + git add src/pipeline/patches.ts tests/patches.test.ts + npm run scan:private + git commit -m "feat: warn when a scaffold's reader differs" + ``` + +### Task 10: `rn-spm` records the reads; the `⚠` line; `doctor --report` + +**Files:** +- Create: `src/pipeline/podspecReads.ts` +- Modify: `src/paths.ts` (:22, :50: `podspecReads: join(iosBuild, "rn-xtool-podspec-reads.jsonl")`) +- Modify: `src/pipeline/rnSpm.ts` (`rnSpmEnv` :231–237; `runRnSpm` :484–640) +- Modify: `src/commands/report.ts` (`renderIssueReport` :257–280, `doctorReport` :315–345) +- Modify: `docs/troubleshooting.md` (a new `### Podspec reader` under "Build and patches", before "Scaffolded + libraries" :974) +- Modify: `tests/rnSpm.test.ts` (:213, :256), `tests/report.test.ts`, `tests/podspecReads.test.ts` (create) + +**Interfaces:** +- Consumes: the JSON lines of Task 4, `troubleshootingUrl` (`src/docs.ts`). +- Produces: + - `rnSpmEnv` adds `RN_SPM_PODSPEC_READS: paths.podspecReads` and `RN_SPM_APP_IOS_DIR: paths.ios`. + - `interface PodspecRead { podspec: string; reader: "ruby" | "reduced"; why?: string; forced: boolean; ruby?: + string; warning?: string; env: string[]; helpers: string[]; ok: boolean; error?: string }`; + `readPodspecReads(file: string): PodspecRead[]` (`[]` without the file; an unparsable line skipped); + `readerLines(reads: PodspecRead[]): string[]` — at most two lines: the first read's `warning` as `⚠ `, + and, when any read used the reduced reader, `⚠ , so rn-xtool read the podspecs with its reduced reader, which + evaluates a subset of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does. See + `, or when forced `⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool + read the podspecs with its reduced reader, which evaluates a subset of Ruby; unset it to read them as CocoaPods + does. See <…>`; `podspecEnvLines(reads: PodspecRead[], root: string): string[]` — `ℹ podspec ENV — : A, B` per read with names, sorted (consumed by plan D's log). + - `runRnSpm` removes `paths.podspecReads` before its first run and, in a `finally`, logs `readerLines(...)` once. + - `doctor --report` adds `ruby: ` after `xtool:`, then `podspec reader: > (last rn-spm, podspecs)` or `podspec reader: not recorded`, then `podspec ENV:` and one + indented `: A, B` line per read with names; all inside the redacted block (R2, R4). + +- [ ] **Step 1: Write the failing tests:** + + ```ts + // tests/podspecReads.test.ts + it("prints the reduced reader once per run", () => { /* two reduced reads → readerLines one line starting "⚠ Ruby was not found, so rn-xtool read the podspecs" + and ending "See https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader" */ }); + it("names the forced reader", () => { /* forced → "⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read …" */ }); + it("says nothing when Ruby read every podspec", () => expect(readerLines([rubyRead])).toEqual([])); + it("lists the ENV names per podspec", () => { /* → ["ℹ podspec ENV — node_modules/x/X.podspec: RCT_NEW_ARCH_ENABLED, USE_FRAMEWORKS"] */ }); + // tests/rnSpm.test.ts + it("hands the scaffolder the reads file and the iOS folder", () => { /* rnSpmEnv(...) includes RN_SPM_PODSPEC_READS and RN_SPM_APP_IOS_DIR */ }); + it("prints the reader line after rn-spm, also when it fails", async () => { /* fake runner writes two reduced lines then exits 1 → log has the ⚠ line once, then the error */ }); + // tests/report.test.ts + it("records the last build's reader and ENV names", async () => { /* reads file with a forced read → report has "podspec reader: reduced: RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 2 podspecs)" for two forced reads and "podspec ENV:" */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/podspecReads.test.ts tests/rnSpm.test.ts + tests/report.test.ts tests/docsLinks.test.ts`. Expected: FAIL. + +- [ ] **Step 3: Implement the Interfaces block**, and write `### Podspec reader` in troubleshooting: the two `⚠` lines + and what to do; that rn-xtool reads podspecs with only `RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED` set (`1`) + and the names a podspec read are in `doctor --report` (row 11); the stop texts of Task 1 and the escape for one run; + how to report (`rn-xtool doctor --report`). + +- [ ] **Step 4: Run the tests to verify they pass.** Same command. Expected: PASS (`docsLinks` finds the anchor); + `npm run lint` clean. + +- [ ] **Step 5: Commit.** + + ```bash + git add src/pipeline/podspecReads.ts src/paths.ts src/pipeline/rnSpm.ts src/commands/report.ts docs/troubleshooting.md \ + tests/podspecReads.test.ts tests/rnSpm.test.ts tests/report.test.ts + npm run scan:private + git commit -m "feat: say which podspec reader rn-spm used" + ``` + +### Task 11: The user docs and the CHANGELOG + +**Files:** +- Modify: `docs/how-it-works.md` ("CocoaPods-only libraries", the reader bullet that starts at :355) +- Modify: `docs/troubleshooting.md` (`### Podspec reader`, Task 10) +- Modify: `CHANGELOG.md` (`## [Unreleased]`, :6) + +**Interfaces:** +- Consumes: the texts of Tasks 1–10. +- Produces: present-tense user text; no new code. + +- [ ] **Step 1: Rewrite the reader bullet in how-it-works**: rn-xtool reads a podspec with the system Ruby and a shim + of CocoaPods and React Native's helpers, the way CocoaPods runs it on a Mac and with the same trust as installing + the library (its Ruby and `node` scripts run, row 18); it never runs `pod ipc spec`, so a machine with CocoaPods + reads a podspec as any machine with Ruby (row 13); without Ruby the reduced reader (the subset the old bullet lists) + reads it, with the `⚠` line; the reads file; the marker line. + +- [ ] **Step 2: Complete troubleshooting's section**: podspecs read as with a Podfile that sets no globals + (vision-camera's location APIs on, frame processors only when react-native-worklets-core is installed, row 14); + delete a library's patch after changing its feature flags or installing an optional sibling (row 16); a persisted + scaffold's reader warning (Task 9). + +- [ ] **Step 3: Write the CHANGELOG entries** under `[Unreleased]`: an `### Upgrading` note (revision 8: every + persisted scaffold patch gets the "older rn-xtool scaffolder (revision 7, now 8)" warning; delete each and rebuild; + install Ruby, `sudo apt install ruby`, to read podspecs as CocoaPods does), `### Changed` (the Ruby reader, `pod ipc + spec` no longer run, the `ios` merge, autolinking stops on a reader failure, `spm_dependency` refused by name, the + `!` lines for unapplied keys), `### Added` (`ruby` in doctor and setup, `RN_XTOOL_PODSPEC_READER=reduced`, the + report lines, the reader sweep and the mention check in CI). + +- [ ] **Step 4: Verify.** Run: `npx vitest run tests/docsLinks.test.ts`. Expected: PASS. Every `@` in the new text sits + in a code span (Task 14's test checks it from then on). + +- [ ] **Step 5: Commit.** + + ```bash + git add docs/how-it-works.md docs/troubleshooting.md CHANGELOG.md + npm run scan:private + git commit -m "docs: describe the Ruby podspec reader" + ``` + +### Task 12: The reader sweep + +**Files:** +- Create: `tests/podspecReaderSweep.test.ts`, `tests/support/podspecSweep.ts`, `tests/podspec-sweep.json`, + `tests/fixtures/podspec-sweep/**` (goldens) +- Modify: `src/pipeline/scaffoldResources.ts` (export `podspecResources`, :100) + +**Interfaces:** +- Consumes: `readPodspec`, `readPodspecNames`, `defaultReadPodspec` (vendored), `podspecFiles`, `podspecLines`, + `unconditionalLineIndexes`, `podDependencies` (`src/project/podspecs.ts`), `podspecResources`, `tarballPath`, + `packageFromTarball`, `needsTarball` (`tests/support/tarballs.ts`), `needsRuby` (Task 1). +- Produces: + - `tests/podspec-sweep.json`: `[{ "spec": "@", "rn": "react-native@", "with"?: ["", …] + }]`; every `spec`, `rn` and `with` entry is pinned in `tests/tarballs.json`. + - `sweepProject(entry): { root: string; podspecs: string[] }`: a temp `/package.json`, `/ios/`, + `/node_modules/` and each `with` package extracted, and `/node_modules/react-native` holding the + `rn` tarball's `package.json` and `scripts/`; `podspecs` are `podspecFiles()` that exist. + - The golden per podspec, `tests/fixtures/podspec-sweep//.json`, + with the temp root written as ``: + + ```text + { "shim": | { "error": String }, + "reduced": { "differs": { : , … } } | { "error": String } | { "refused": String }, + "names": { "shim": {name, moduleName, headerDir} | null, "reduced": {…} | null }, + "env": [String], "helpers": [String], + "tsReaders": { "dependencies": { "onlyTs": [], "onlyShim": [] }, "resourceBundles": { "onlyTs": [], "onlyShim": [] } } } + ``` + + `tsReaders` lists where the early checks' dependency lines and the resource reader disagree with the shim (row 29, + fixed in alpha.9). + - `RN_XTOOL_SWEEP_WRITE=1` writes the goldens instead of comparing. + +- [ ] **Step 1: Write the failing test file** with the entries already cached (`react-native-screens@4.30.0`, + `react-native-svg@15.16.0`, `react-native-gesture-handler@3.4.0`, `rn` `react-native@0.88.1`): + + ```ts + for (const entry of SWEEP) for (const podspec of podspecsOf(entry)) + it.skipIf(skip(entry))(`reads ${entry.spec} ${podspec} as its golden${skipReason(entry)}`, () => { + expect(record(entry, podspec)).toEqual(golden(entry, podspec)); + }); + it("keeps every library's names under both readers", () => expect(nameDifferences()).toEqual([])); + it("has a golden for every podspec and no other", () => expect(orphanGoldens()).toEqual([])); + it.runIf(process.env.CI === "true")("runs with Ruby on CI", () => expect(podspecReaderHere().reader).toBe("ruby")); + ``` + + `skip` is `needsTarball` for the entry's tarballs, and `needsRuby` off CI only (on CI a missing Ruby fails the last + test, and a missing tarball fails, since CI fetched them). + +- [ ] **Step 2: Run it to verify it fails.** Run: `npx vitest run tests/podspecReaderSweep.test.ts`. Expected: FAIL + (no golden). + +- [ ] **Step 3: Implement `tests/support/podspecSweep.ts`** (`sweepProject`, `record`, `golden`, `podspecsOf`, + `nameDifferences`, `orphanGoldens`), with `RN_SPM_RN_ROOT` and `RN_SPM_APP_IOS_DIR` set per project and the reduced + read under `vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")`. + +- [ ] **Step 4: Write and read the goldens.** Run: `RN_XTOOL_SWEEP_WRITE=1 npx vitest run + tests/podspecReaderSweep.test.ts`, then without the variable. Expected: PASS. Read each golden: a `shim.error` that + is a shim gap is fixed in the shim first (Task 2's rule, with a `podspecShim` test), never written as the golden. + +- [ ] **Step 5: Commit.** + + ```bash + git add tests/podspecReaderSweep.test.ts tests/support/podspecSweep.ts tests/podspec-sweep.json tests/fixtures/podspec-sweep \ + src/pipeline/scaffoldResources.ts + npm run scan:private + git commit -m "test: sweep the podspec readers over libraries" + ``` + +### Task 13: The sweep's set (network, with the owner's approval) + +**Files:** +- Modify: `tests/tarballs.json`, `tests/podspec-sweep.json`, `tests/fixtures/podspec-sweep/**` +- Modify: `vendor/rn-spm/spm/read-podspec-shim.rb`, `tests/podspecShim.test.ts`, both 0.88 patches (only for a gap + the sweep finds) +- Modify: `.github/workflows/ci.yml` (cache `tests/.cache`; `timeout-minutes`) + +**Interfaces:** +- Consumes: Task 12's harness. +- Produces: R11's set pinned and swept. + +- [ ] **Step 1: Ask the owner before downloading.** Show the list below (about 45 new tarballs, a few hundred MB, into + `tests/.cache`) and wait for approval. The list, deduplicated against what `tests/tarballs.json` already pins: + - R11's 30 (spec F.1, verbatim): `react-native-safe-area-context@5.11.1`, `react-native-screens@4.30.1`, + `react-native-reanimated@4.7.1`, `react-native-gesture-handler@3.5.0`, `react-native-worklets@0.13.1`, + `react-native-svg@15.16.1`, `@react-native-async-storage/async-storage@3.1.1`, + `@react-native-masked-view/masked-view@0.3.2`, `react-native-webview@14.0.1`, `@sentry/react-native@8.34.0`, + `@react-native-community/netinfo@12.0.1`, `react-native-keyboard-controller@1.23.0`, + `@react-native-community/datetimepicker@9.3.0`, `react-native-get-random-values@2.1.0`, + `react-native-nitro-modules@0.37.2`, `react-native-mmkv@4.3.2`, `@react-native-firebase/app@27.1.0`, + `@shopify/react-native-skia@2.14.0`, `lottie-react-native@7.5.0`, `react-native-view-shot@6.2.1`, + `@react-native-community/slider@5.2.2`, `react-native-pager-view@10.0.0`, `react-native-maps@1.29.11`, + `react-native-device-info@15.0.2`, `@react-native-google-signin/google-signin@17.0.0`, + `react-native-blob-util@0.25.1`, `react-native-purchases@11.0.1`, `@react-native-picker/picker@2.11.4`, + `@react-native-clipboard/clipboard@1.16.3`, `react-native-permissions@5.6.3`; `rn` `react-native@0.88.1`; + - the trial's: `react-native-screens@4.24.0`, `react-native-worklets@0.8.1`, `react-native-worklets@0.8.3`, `rn` + `react-native@0.85.0`; and `react-native-vision-camera@4.7.3` (row 22's subspec case); + - the reference apps' libraries at the versions installed in `../app-bare`, `../app-bare-086`, `../app-bare-087` + (read each `node_modules//package.json`; `rn` the app's React Native); + - the Expo SDK 57 and 58 template packages that ship a podspec where autolinking looks (`podspecFiles`), at the + versions installed in `../app-expo-57` (SDK 57, `rn` 0.86.3) and `../app` (SDK 58 default template, `rn` 0.88.1). + A podspec that raises without a sibling by design (`ExpoModulesWorkletsAdapter.podspec` without + react-native-worklets) gets the sibling in `with`. + +- [ ] **Step 2: Pin and fetch (network step, after approval).** For each new spec: `npm pack + --pack-destination tests/.cache --json`, and append `{spec, file, integrity}` from its output to + `tests/tarballs.json`. Then `node scripts/fetch-test-tarballs.mjs`: every line says `cached`. Record the total size + of the new files (`du -ch` over them). + +- [ ] **Step 3: Write the goldens and close the gaps.** Run: `RN_XTOOL_SWEEP_WRITE=1 npx vitest run + tests/podspecReaderSweep.test.ts`. For each `shim.error`: a CocoaPods DSL name or a helper of fact 8 → model it in + the shim with a `tests/podspecShim.test.ts` test, regenerate both 0.88 patches, run the byte tests, write again; a + sibling the podspec needs → `with`; anything else → stop and bring it to the owner as a decision. Then run without + the variable: PASS, and `nameDifferences()` empty (a difference goes to the owner as a decision, row 15). + +- [ ] **Step 4: The owner reviews the goldens once** (spec Verification): give him, per library, the reduced reader's + differing fields, the `env` names and the `tsReaders` lists, and wait for his approval before committing. + +- [ ] **Step 5: CI.** In `.github/workflows/ci.yml`, an `actions/cache` step for `tests/.cache` keyed on + `hashFiles('tests/tarballs.json')` before "Fetch the test tarballs"; set `timeout-minutes` to twice a measured local + `node scripts/fetch-test-tarballs.mjs` from empty plus `npm test`, at least 15. + +- [ ] **Step 6: Run everything.** Run: `npm test && npm run lint`. Expected: PASS, clean. + +- [ ] **Step 7: Commit** (the shim's gaps, if any, first as their own `feat:` commit with the patches). + + ```bash + git add tests/tarballs.json tests/podspec-sweep.json tests/fixtures/podspec-sweep .github/workflows/ci.yml + npm run scan:private + git commit -m "test: sweep R11's library set in CI" + ``` + +### Task 14: The mention check + +**Files:** +- Create: `scripts/check-mentions.mjs`, `tests/mentions.test.ts`, `.github/workflows/mentions.yml` +- Modify: `package.json` (`"check:mentions": "node scripts/check-mentions.mjs"`) +- Modify: `docs/RELEASING.md` ("Release", :34–44: a "Pull requests and release notes" paragraph) +- Modify: `CHANGELOG.md:47`, `docs/troubleshooting.md:292`, `:918`, `docs/upstream/react-native-scaffolder.md:498`, + `docs/design/specs/2026-11-04-library-compat-design.md:44`, `docs/research/compat-suite-proposal.md:264`, + `docs/research/rn-087-recon.md:41`, `:42`, `:46` (the fifteen of fact 32) + +**Interfaces:** +- Consumes: nothing. +- Produces: `mentions(text: string): { line: number; word: string }[]` — outside fenced blocks (` ``` `, `~~~`) and + code spans (a backtick run closed by a run of the same length), a `@` not preceded by a letter, digit, `_`, `` ` ``, + `/`, `.`, `-` or `@`, followed by a GitHub login (`[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}`) not followed by `/` or a + login character; a scoped `@scope/name` passes (R10). A code span that crosses a line break counts as one span. + `node scripts/check-mentions.mjs [file…]` checks the files (no file: every `git ls-files '*.md'`), prints + `:: @ notifies a GitHub user; put it in a code span or drop the @` per hit and exits 1, else + prints nothing and exits 0. Not shipped (`package.json` `files` lists scripts by name). + +- [ ] **Step 1: Write the failing tests** in `tests/mentions.test.ts`: + + ```ts + it("finds a bare user mention", () => expect(mentions("use @import here\n")).toEqual([{ line: 1, word: "import" }])); + it("passes code spans, fences, scoped names and e-mail addresses", () => + expect(mentions("`@import` and ``a `@x` b``\n```\n@y\n```\n@scope/name a@b.c\n")).toEqual([])); + it("refuses hunk numbers written as mentions", () => expect(mentions("at @54 and @d11")).toEqual([{ line: 1, word: "54" }, { line: 1, word: "d11" }])); + it("finds none in the tracked markdown or the local PR and notes files", () => { /* git ls-files '*.md' plus .superpowers/*.md when the folder exists → [] */ }); + ``` + +- [ ] **Step 2: Run them to verify they fail.** Run: `npx vitest run tests/mentions.test.ts`. Expected: FAIL (no + script; then fifteen hits). + +- [ ] **Step 3: Write the script** and fix the fifteen mentions: `` `@import` `` in code spans; `` `@react-navigation` `` + and `` `@d11` `` in code spans; the hunk numbers as "line 54", "line 113", "line 170", "line 844", "line 1099". + +- [ ] **Step 4: Write the workflow** `.github/workflows/mentions.yml`: `on: pull_request: types: [opened, edited, + reopened, synchronize]`, `permissions: contents: read`, one job that checks out, writes the body through an env + variable (`BODY: ${{ github.event.pull_request.body }}`, then `printf '%s' "$BODY" > "$RUNNER_TEMP/body.md"`, never + the expression inline in the script) and runs `node scripts/check-mentions.mjs "$RUNNER_TEMP/body.md"`. + +- [ ] **Step 5: RELEASING.** Under "Release": write the PR text and the release notes into files, run `npm run + check:mentions -- ` on each before `gh pr create --body-file ` and `gh release create + --notes-file `, and publish release notes from the checked file only, never typed into GitHub's page (rows + 113, 114). + +- [ ] **Step 6: Run the tests to verify they pass.** Run: `npx vitest run tests/mentions.test.ts tests/packageFiles.test.ts + tests/docsLinks.test.ts`. Expected: PASS. + +- [ ] **Step 7: Commit.** + + ```bash + git add scripts/check-mentions.mjs tests/mentions.test.ts .github/workflows/mentions.yml package.json docs/RELEASING.md \ + CHANGELOG.md docs/troubleshooting.md docs/upstream/react-native-scaffolder.md docs/design/specs/2026-11-04-library-compat-design.md \ + docs/research/compat-suite-proposal.md docs/research/rn-087-recon.md + npm run scan:private + git commit -m "feat: refuse bare mentions in markdown" + ``` + +### Task 15: Build-only proof on the reference apps (the owner's approval first) + +**Files:** +- None committed but `CHANGELOG.md` if a result changes its text; results go to the task's report. + +**Interfaces:** +- Consumes: everything above, built (`npm run build`). +- Produces: the evidence spec Verification asks for group A. + +- [ ] **Step 1: Ask the owner** for the builds (each is minutes and gigabytes of SwiftPM output). Runs go through a + delegated session, one build at a time, on copies of the reference apps, never the apps themselves. + +- [ ] **Step 2: Bare 0.86, 0.87, 0.88 and Expo SDK 57, 58 with Ruby.** Per copy: delete `patches/*` scaffold patches, + `rn-xtool build --clean`. Expected: the build finishes, no new stop, no `⚠` but the revision-8 lines; each + scaffold's marker says `ruby`; each scaffolded library's `Package.swift` matches the sweep's golden model (same + sources and defines). Record `rn-spm`'s time (row 24). A bare 0.85 reference, when the owner approves creating one + with the drift watch's pinned CLI; otherwise recorded as not run. + +- [ ] **Step 3: The same bare 0.88 copy with `RN_XTOOL_PODSPEC_READER=reduced`.** Expected: one `⚠ + RN_XTOOL_PODSPEC_READER=reduced is set …` line at `rn-spm`, markers say `reduced`, `doctor --report` shows the + `podspec reader: reduced: …` and `podspec ENV:` lines; `rn-spm`'s time recorded. + +- [ ] **Step 4: Without Ruby on `PATH`** (`PATH` stripped of Ruby's folder for one `doctor` and one `doctor + --project`): `⚠ ruby — not found — podspecs are read with the reduced reader; sudo apt install ruby`. + +- [ ] **Step 5: Hand the production app to the owner**: build it with the branch's `npm pack`; expected: scaffolds + regenerated at revision 8 by Ruby, no new stop, react-native-screens' sources under `ios/` in its manifest. He runs + it himself and reports. + +- [ ] **Step 6: Report** each result, the times, and any difference from the goldens, to the owner. No commit unless + a text changed. + +--- + +## Deferred + +- **Row 29** (the TypeScript readers in `src/project/earlyChecks.ts` and `src/pipeline/scaffoldResources.ts` keep + their line readers): deferred to alpha.9, "one podspec model for every reader" (R5). Meanwhile Task 12's goldens list + their disagreements with the shim per library (`tsReaders`). +- **Row 17** (one process per podspec), **row 24** (cost, measured in Task 15), **row 27** (the reduced reader's + limits): accepted by the spec; nothing to build. From d9f739ae716a5f91a6af283ef66a463ad7bf970e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 13:43:35 -0600 Subject: [PATCH 04/53] fix: write new-file headers patch-package reads --- docs/RELEASING.md | 6 +++++- tests/patches.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 43f1f8d..8321fa1 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -63,10 +63,14 @@ and `vendor/rn-spm/rn-xtool-edits.patch` (E1–E5) applied, for 0.85–0.87 and "$T/b/node_modules/react-native/scripts/" patch -R -p1 -F0 -d "$T/b/node_modules/react-native/scripts" -i "$PWD/vendor/rn-spm/rn-xtool-edits.patch" (cd "$T" && git diff --no-index --no-color --src-prefix= --dst-prefix= \ - a/node_modules/react-native/scripts b/node_modules/react-native/scripts) > "$T/rn.patch" + a/node_modules/react-native/scripts b/node_modules/react-native/scripts) \ + | sed -E 's#^diff --git [ab]/([^ ]+) [ab]/#diff --git a/\1 b/#' > "$T/rn.patch" cp "$T/rn.patch" patches/react-native+0.88.0.patch && cp "$T/rn.patch" patches/react-native+0.88.1.patch ``` + The `sed` gives a new file's header the `a/` side patch-package reads (`git diff --no-index` names both sides + `b/`, and patch-package then refuses the whole patch). + When the reverse `patch` fails, the change moved the context of an E-edit. That `b/` is half-reversed and holds `.rej` files, so a diff from it would drop the E-edit from `rn-xtool-edits.patch` and move it into the 0.88 patch. Copy the vendored files into a new `b/`, rerun the reverse without `-F0` (`patch -R -p1 --no-backup-if-mismatch`), diff --git a/tests/patches.test.ts b/tests/patches.test.ts index 31f387c..2c4501d 100644 --- a/tests/patches.test.ts +++ b/tests/patches.test.ts @@ -1,5 +1,6 @@ import { lstat, mkdir, mkdtemp, readlink, rm, writeFile } from "node:fs/promises"; import { existsSync, readdirSync, readFileSync } from "node:fs"; +import { createRequire } from "node:module"; import { tmpdir } from "node:os"; import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; @@ -102,6 +103,18 @@ describe("patches", () => { expect(read("0.88.0").equals(read("0.88.1"))).toBe(true); }); + it("every bundled patch parses as patch-package reads it", () => { + // patch-package reads each file's header as `diff --git a/ b/`; `git diff --no-index` writes a new + // file's as `b/ b/`, which the RELEASING recipe rewrites. + const { parsePatchFile } = createRequire(import.meta.url)("patch-package/dist/patch/parse.js") as { + parsePatchFile(text: string): unknown[]; + }; + const dir = path.join(packageRoot(), "patches"); + for (const f of readdirSync(dir).filter((n) => n.endsWith(".patch"))) { + expect(() => parsePatchFile(readFileSync(path.join(dir, f), "utf8")), f).not.toThrow(); + } + }); + it("applyPatchesArgv passes the staged dir relative to the project root", () => { const root = path.join(packageRoot(), "..", "proj"); const staged = projectPaths(root).patchesDir; From ce361b1b683baafe4bdbadc4fd28d60a65da9f9c Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 13:43:42 -0600 Subject: [PATCH 05/53] feat: add the podspec reader's Ruby shim --- .github/workflows/ci.yml | 24 ++ patches/react-native+0.88.0.patch | 304 +++++++++++++++++++++++++ patches/react-native+0.88.1.patch | 304 +++++++++++++++++++++++++ tests/ci/workflow.test.ts | 51 +++-- tests/packageFiles.test.ts | 4 + tests/podspecShim.test.ts | 112 +++++++++ tests/rn-scaffolder.test.ts | 1 + tests/support/ruby.ts | 61 +++++ vendor/rn-spm/spm/read-podspec-shim.rb | 298 ++++++++++++++++++++++++ 9 files changed, 1142 insertions(+), 17 deletions(-) create mode 100644 tests/podspecShim.test.ts create mode 100644 tests/support/ruby.ts create mode 100644 vendor/rn-spm/spm/read-podspec-shim.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 518e0c5..c132881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,6 @@ # CI: on every pull request to main and every push to main, install, fetch the pinned upstream tarballs the tests # read, type-check, scan the tracked files for private identifiers and run the whole test suite. +# A second job runs the podspec reader's Ruby shim tests on the oldest Ruby the shim supports. # # Nothing is compiled for iOS and no device is touched: there is no Swift, no Darwin SDK and no iPhone here. Tests that # need a real app, a toolchain or a device are skipped, and the run summary lists them by name (and, on a red run, the @@ -46,9 +47,32 @@ jobs: # Before the tests: a leak is reported even when the suite is red. - name: Scan for private identifiers run: npm run scan:private + # The runner image ships Ruby; tests/podspecShim.test.ts fails here without it, instead of skipping. + - name: Ruby (the podspec reader needs it) + run: ruby --version - name: Test run: npm test -- --reporter=default --reporter=json --outputFile=test-results.json # Runs after a failed test step too, so a red run still says what did not run. - name: List skipped tests if: ${{ !cancelled() }} run: node scripts/ci-skipped.mjs test-results.json >> "$GITHUB_STEP_SUMMARY" + + # The podspec reader's Ruby shim on the oldest Ruby it supports: the floor its --probe reports is what this job runs. + shim-ruby-floor: + runs-on: ubuntu-22.04 + timeout-minutes: 15 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: npm + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.7" + - name: Install and build + run: npm ci + - name: Test the shim on Ruby 2.7 + run: npx vitest run tests/podspecShim.test.ts diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 6062e3f..824e311 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -1,3 +1,307 @@ +diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb +new file mode 100644 +index 0000000..d4f4cf1 +--- /dev/null ++++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb +@@ -0,0 +1,298 @@ ++# This source code is licensed under the MIT license found in the ++# LICENSE file in the root directory of this source tree. ++ ++# rn-xtool's podspec reader: runs a podspec with the system Ruby as CocoaPods runs it, against a shim of CocoaPods' ++# DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). ++# ++# ruby read-podspec-shim.rb --probe ++# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. ++# ruby read-podspec-shim.rb ++# run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. ++# Nothing of the shim's own goes to stdout; the podspec's prints do. ++# ++# Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. ++ ++RN_XTOOL_RUBY_FLOOR = '2.7.0' ++if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 ++ why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" ++ abort why unless ARGV == ['--probe'] ++ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) ++ exit 0 ++end ++ ++require 'json' ++ ++if ARGV == ['--probe'] ++ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) ++ exit 0 ++end ++ ++module Pod ++ # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. ++ class Specification ++ # Set on the root spec only, never per platform. ++ ROOT_ATTRIBUTES = %w[ ++ name version swift_versions cocoapods_version authors social_media_url license homepage readme changelog source ++ summary description screenshots documentation_url prepare_command static_framework deprecated ++ deprecated_in_favor_of ++ ].freeze ++ # Also set per platform (`s.ios.frameworks = ...`). ++ PLATFORM_ATTRIBUTES = %w[ ++ requires_arc frameworks weak_frameworks libraries compiler_flags pod_target_xcconfig user_target_xcconfig xcconfig ++ prefix_header_contents prefix_header_file module_name header_dir header_mappings_dir script_phases ++ on_demand_resources info_plist source_files public_header_files project_header_files private_header_files ++ vendored_frameworks vendored_libraries resource_bundles resources exclude_files preserve_paths module_map ++ requires_app_host app_host_name scheme test_type ++ ].freeze ++ ATTRIBUTES = (ROOT_ATTRIBUTES + %w[platforms default_subspecs] + PLATFORM_ATTRIBUTES).freeze ++ # Stored under the plural key. ++ SINGULAR_ALIASES = { ++ 'swift_version' => 'swift_versions', 'author' => 'authors', 'screenshot' => 'screenshots', ++ 'framework' => 'frameworks', 'weak_framework' => 'weak_frameworks', 'library' => 'libraries', ++ 'compiler_flag' => 'compiler_flags', 'script_phase' => 'script_phases', ++ 'vendored_framework' => 'vendored_frameworks', 'vendored_library' => 'vendored_libraries', ++ 'resource_bundle' => 'resource_bundles', 'resource' => 'resources', 'preserve_path' => 'preserve_paths', ++ 'default_subspec' => 'default_subspecs' ++ }.freeze ++ # The platform proxies, and the platform each stores under. ++ PLATFORMS = { ++ 'ios' => 'ios', 'osx' => 'osx', 'macos' => 'osx', 'tvos' => 'tvos', 'visionos' => 'visionos', ++ 'watchos' => 'watchos' ++ }.freeze ++ ++ def initialize(parent = nil, name = nil) ++ @parent = parent ++ @attributes = {} ++ @attributes['name'] = name if name ++ @subspecs = [] ++ @testspecs = [] ++ @appspecs = [] ++ yield self if block_given? ++ end ++ ++ ATTRIBUTES.each do |attribute| ++ define_method("#{attribute}=") { |value| @attributes[attribute] = value } ++ define_method(attribute) { @attributes[attribute] } unless attribute == 'name' ++ end ++ SINGULAR_ALIASES.each do |singular, plural| ++ define_method("#{singular}=") { |value| @attributes[plural] = value } ++ end ++ PLATFORMS.each do |proxy, platform| ++ define_method(proxy) { PlatformProxy.new(@attributes, platform) } ++ end ++ ++ # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. ++ def name ++ @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] ++ end ++ ++ def platform=(value) ++ platform, deployment_target = value ++ @attributes['platforms'] = platform ? { PLATFORMS.fetch(platform.to_s, platform.to_s) => deployment_target } : {} ++ end ++ ++ def dependency(name, *requirements) ++ (@attributes['dependencies'] ||= {})[name] = requirements ++ end ++ ++ def subspec(name, &block) ++ add(@subspecs, name, &block) ++ end ++ ++ def test_spec(name = 'Tests', &block) ++ add(@testspecs, name, &block) ++ end ++ ++ def app_spec(name = 'App', &block) ++ add(@appspecs, name, &block) ++ end ++ ++ # The spec in CocoaPods' JSON form. ++ def to_model ++ model = RnXtoolShim.plain(@attributes) ++ if model.key?('default_subspecs') ++ model['default_subspecs'] = Array(model['default_subspecs']) unless model['default_subspecs'] == 'none' ++ end ++ { 'subspecs' => @subspecs, 'testspecs' => @testspecs, 'appspecs' => @appspecs }.each do |key, specs| ++ model[key] = specs.map(&:to_model) unless specs.empty? ++ end ++ model ++ end ++ ++ private ++ ++ def add(list, name, &block) ++ spec = Specification.new(self, name, &block) ++ list << spec ++ spec ++ end ++ ++ # `s.ios`, `s.osx` (and `s.macos`), `s.tvos`, `s.visionos`, `s.watchos`: stores under the spec's platform key. ++ class PlatformProxy ++ def initialize(attributes, platform) ++ @attributes = attributes ++ @platform = platform ++ end ++ ++ PLATFORM_ATTRIBUTES.each do |attribute| ++ define_method("#{attribute}=") { |value| scoped[attribute] = value } ++ end ++ SINGULAR_ALIASES.each do |singular, plural| ++ define_method("#{singular}=") { |value| scoped[plural] = value } if PLATFORM_ATTRIBUTES.include?(plural) ++ end ++ ++ def deployment_target=(value) ++ (@attributes['platforms'] ||= {})[@platform] = value ++ end ++ ++ def dependency(name, *requirements) ++ (scoped['dependencies'] ||= {})[name] = requirements ++ end ++ ++ private ++ ++ def scoped ++ @attributes[@platform] ||= {} ++ end ++ end ++ end ++ ++ Spec = Specification ++ ++ # As CocoaPods-core evaluates a podspec: `self` is `Pod`, and `Spec` resolves inside it. ++ def self._eval_podspec(string, path) ++ eval(string, nil, path) ++ end ++end ++ ++# The command line's run: evaluate, then write the model or the error file. ++module RnXtoolShim ++ module_function ++ ++ # Writes the model, or the error, to `out`; whether the podspec read. ++ def run(podspec, out) ++ spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) ++ unless spec.is_a?(Pod::Specification) ++ write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) ++ return false ++ end ++ write(out, spec.to_model.merge( ++ '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } ++ )) ++ true ++ rescue ScriptError, StandardError, SystemExit => e ++ kind, message = failure(e, podspec) ++ write(out, 'error' => { 'kind' => kind, 'message' => message }) ++ false ++ end ++ ++ def write(out, value) ++ File.write(out, JSON.generate(value)) ++ end ++ ++ # A value as CocoaPods' JSON form writes it: symbols, hash keys and Pathnames as strings. ++ def plain(value) ++ case value ++ when Hash then value.each_with_object({}) { |(key, item), out| out[key.to_s] = plain(item) } ++ when Array then value.map { |item| plain(item) } ++ when String, Numeric, true, false, nil then value ++ else value.to_s ++ end ++ end ++ ++ # [kind, message] of an exception the podspec's run raised. ++ def failure(error, podspec) ++ where = where(error, podspec) ++ if error.is_a?(NameError) ++ receiver = receiver_of(error) ++ name = error.name.to_s ++ if receiver.is_a?(Pod::Specification) || receiver.is_a?(Pod::Specification::PlatformProxy) ++ attribute = name.chomp('=') ++ return ['attribute', "#{where}: the podspec sets #{receiver_text(error, podspec, receiver, attribute)}.#{attribute}, " \ ++ 'which CocoaPods does not define'] ++ end ++ if modeled?(receiver) ++ if !error.is_a?(NoMethodError) && name.match?(/\A[A-Z]/) ++ return ['constant', "#{where}: the podspec uses #{name}, which rn-xtool's podspec reader does not model"] ++ end ++ return ['method', "#{where}: the podspec calls #{name}(…), which rn-xtool's podspec reader does not model"] ++ end ++ end ++ message = error.message ++ message = message.sub(/\A.+?:\d+: /, '') if error.is_a?(SyntaxError) ++ ['raised', "#{where}: #{message.rstrip}"] ++ end ++ ++ # The error's receiver, or nil when Ruby kept none. ++ def receiver_of(error) ++ error.receiver ++ rescue ArgumentError ++ nil ++ end ++ ++ # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. ++ def modeled?(receiver) ++ return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) ++ ++ namespace = Module === receiver ? receiver : receiver.class ++ namespace.name.to_s.split('::').first == 'Pod' ++ end ++ ++ # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. ++ def receiver_text(error, podspec, receiver, attribute) ++ path, line = frame(error, podspec) ++ source = path && source_line(path, line) ++ found = source && source[/([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*\.\s*#{Regexp.escape(attribute)}(?!\w)/, 1] ++ return found if found ++ ++ receiver.is_a?(Pod::Specification) ? 'spec' : "spec.#{receiver.instance_variable_get(:@platform)}" ++ end ++ ++ def source_line(path, line) ++ File.readlines(path, encoding: 'UTF-8')[line - 1] ++ rescue SystemCallError ++ nil ++ end ++ ++ # `:` for a frame in the podspec, ` (:)` for one in another of the library's ++ # files (relative to the podspec's folder), or `` alone. ++ def where(error, podspec) ++ path, line = frame(error, podspec) ++ return podspec unless path ++ return "#{podspec}:#{line}" if File.expand_path(path) == File.expand_path(podspec) ++ ++ "#{podspec} (#{relative(path, podspec)}:#{line})" ++ end ++ ++ # The innermost [path, line] of the error in the podspec or another of the library's files, never the shim's. ++ def frame(error, podspec) ++ frames = (error.backtrace_locations || []).map { |location| [location.path, location.lineno] } ++ # A syntax error names its place only in its message. ++ frames.unshift([Regexp.last_match(1), Regexp.last_match(2).to_i]) if error.is_a?(SyntaxError) && error.message =~ /\A(.+?):(\d+): / ++ frames.find do |path, _| ++ next true if File.expand_path(path) == File.expand_path(podspec) ++ ++ # Ruby's own frames (``, `(eval)`) have no absolute path. ++ path.start_with?('/') && File.expand_path(path) != File.expand_path(__FILE__) && !relative(path, podspec).nil? ++ end ++ end ++ ++ # `path` relative to the podspec's folder (as given or with its links resolved), or nil outside it. ++ def relative(path, podspec) ++ full = File.expand_path(path) ++ folder = File.dirname(File.expand_path(podspec)) ++ [folder, real(folder)].each do |root| ++ return full[(root.length + 1)..-1] if full.start_with?("#{root}/") ++ end ++ nil ++ end ++ ++ def real(folder) ++ File.realpath(folder) ++ rescue SystemCallError ++ folder ++ end ++end ++ ++abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 ++exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js index 8fcf04b..6897fdb 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 6062e3f..824e311 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -1,3 +1,307 @@ +diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb +new file mode 100644 +index 0000000..d4f4cf1 +--- /dev/null ++++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb +@@ -0,0 +1,298 @@ ++# This source code is licensed under the MIT license found in the ++# LICENSE file in the root directory of this source tree. ++ ++# rn-xtool's podspec reader: runs a podspec with the system Ruby as CocoaPods runs it, against a shim of CocoaPods' ++# DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). ++# ++# ruby read-podspec-shim.rb --probe ++# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. ++# ruby read-podspec-shim.rb ++# run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. ++# Nothing of the shim's own goes to stdout; the podspec's prints do. ++# ++# Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. ++ ++RN_XTOOL_RUBY_FLOOR = '2.7.0' ++if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 ++ why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" ++ abort why unless ARGV == ['--probe'] ++ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) ++ exit 0 ++end ++ ++require 'json' ++ ++if ARGV == ['--probe'] ++ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) ++ exit 0 ++end ++ ++module Pod ++ # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. ++ class Specification ++ # Set on the root spec only, never per platform. ++ ROOT_ATTRIBUTES = %w[ ++ name version swift_versions cocoapods_version authors social_media_url license homepage readme changelog source ++ summary description screenshots documentation_url prepare_command static_framework deprecated ++ deprecated_in_favor_of ++ ].freeze ++ # Also set per platform (`s.ios.frameworks = ...`). ++ PLATFORM_ATTRIBUTES = %w[ ++ requires_arc frameworks weak_frameworks libraries compiler_flags pod_target_xcconfig user_target_xcconfig xcconfig ++ prefix_header_contents prefix_header_file module_name header_dir header_mappings_dir script_phases ++ on_demand_resources info_plist source_files public_header_files project_header_files private_header_files ++ vendored_frameworks vendored_libraries resource_bundles resources exclude_files preserve_paths module_map ++ requires_app_host app_host_name scheme test_type ++ ].freeze ++ ATTRIBUTES = (ROOT_ATTRIBUTES + %w[platforms default_subspecs] + PLATFORM_ATTRIBUTES).freeze ++ # Stored under the plural key. ++ SINGULAR_ALIASES = { ++ 'swift_version' => 'swift_versions', 'author' => 'authors', 'screenshot' => 'screenshots', ++ 'framework' => 'frameworks', 'weak_framework' => 'weak_frameworks', 'library' => 'libraries', ++ 'compiler_flag' => 'compiler_flags', 'script_phase' => 'script_phases', ++ 'vendored_framework' => 'vendored_frameworks', 'vendored_library' => 'vendored_libraries', ++ 'resource_bundle' => 'resource_bundles', 'resource' => 'resources', 'preserve_path' => 'preserve_paths', ++ 'default_subspec' => 'default_subspecs' ++ }.freeze ++ # The platform proxies, and the platform each stores under. ++ PLATFORMS = { ++ 'ios' => 'ios', 'osx' => 'osx', 'macos' => 'osx', 'tvos' => 'tvos', 'visionos' => 'visionos', ++ 'watchos' => 'watchos' ++ }.freeze ++ ++ def initialize(parent = nil, name = nil) ++ @parent = parent ++ @attributes = {} ++ @attributes['name'] = name if name ++ @subspecs = [] ++ @testspecs = [] ++ @appspecs = [] ++ yield self if block_given? ++ end ++ ++ ATTRIBUTES.each do |attribute| ++ define_method("#{attribute}=") { |value| @attributes[attribute] = value } ++ define_method(attribute) { @attributes[attribute] } unless attribute == 'name' ++ end ++ SINGULAR_ALIASES.each do |singular, plural| ++ define_method("#{singular}=") { |value| @attributes[plural] = value } ++ end ++ PLATFORMS.each do |proxy, platform| ++ define_method(proxy) { PlatformProxy.new(@attributes, platform) } ++ end ++ ++ # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. ++ def name ++ @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] ++ end ++ ++ def platform=(value) ++ platform, deployment_target = value ++ @attributes['platforms'] = platform ? { PLATFORMS.fetch(platform.to_s, platform.to_s) => deployment_target } : {} ++ end ++ ++ def dependency(name, *requirements) ++ (@attributes['dependencies'] ||= {})[name] = requirements ++ end ++ ++ def subspec(name, &block) ++ add(@subspecs, name, &block) ++ end ++ ++ def test_spec(name = 'Tests', &block) ++ add(@testspecs, name, &block) ++ end ++ ++ def app_spec(name = 'App', &block) ++ add(@appspecs, name, &block) ++ end ++ ++ # The spec in CocoaPods' JSON form. ++ def to_model ++ model = RnXtoolShim.plain(@attributes) ++ if model.key?('default_subspecs') ++ model['default_subspecs'] = Array(model['default_subspecs']) unless model['default_subspecs'] == 'none' ++ end ++ { 'subspecs' => @subspecs, 'testspecs' => @testspecs, 'appspecs' => @appspecs }.each do |key, specs| ++ model[key] = specs.map(&:to_model) unless specs.empty? ++ end ++ model ++ end ++ ++ private ++ ++ def add(list, name, &block) ++ spec = Specification.new(self, name, &block) ++ list << spec ++ spec ++ end ++ ++ # `s.ios`, `s.osx` (and `s.macos`), `s.tvos`, `s.visionos`, `s.watchos`: stores under the spec's platform key. ++ class PlatformProxy ++ def initialize(attributes, platform) ++ @attributes = attributes ++ @platform = platform ++ end ++ ++ PLATFORM_ATTRIBUTES.each do |attribute| ++ define_method("#{attribute}=") { |value| scoped[attribute] = value } ++ end ++ SINGULAR_ALIASES.each do |singular, plural| ++ define_method("#{singular}=") { |value| scoped[plural] = value } if PLATFORM_ATTRIBUTES.include?(plural) ++ end ++ ++ def deployment_target=(value) ++ (@attributes['platforms'] ||= {})[@platform] = value ++ end ++ ++ def dependency(name, *requirements) ++ (scoped['dependencies'] ||= {})[name] = requirements ++ end ++ ++ private ++ ++ def scoped ++ @attributes[@platform] ||= {} ++ end ++ end ++ end ++ ++ Spec = Specification ++ ++ # As CocoaPods-core evaluates a podspec: `self` is `Pod`, and `Spec` resolves inside it. ++ def self._eval_podspec(string, path) ++ eval(string, nil, path) ++ end ++end ++ ++# The command line's run: evaluate, then write the model or the error file. ++module RnXtoolShim ++ module_function ++ ++ # Writes the model, or the error, to `out`; whether the podspec read. ++ def run(podspec, out) ++ spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) ++ unless spec.is_a?(Pod::Specification) ++ write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) ++ return false ++ end ++ write(out, spec.to_model.merge( ++ '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } ++ )) ++ true ++ rescue ScriptError, StandardError, SystemExit => e ++ kind, message = failure(e, podspec) ++ write(out, 'error' => { 'kind' => kind, 'message' => message }) ++ false ++ end ++ ++ def write(out, value) ++ File.write(out, JSON.generate(value)) ++ end ++ ++ # A value as CocoaPods' JSON form writes it: symbols, hash keys and Pathnames as strings. ++ def plain(value) ++ case value ++ when Hash then value.each_with_object({}) { |(key, item), out| out[key.to_s] = plain(item) } ++ when Array then value.map { |item| plain(item) } ++ when String, Numeric, true, false, nil then value ++ else value.to_s ++ end ++ end ++ ++ # [kind, message] of an exception the podspec's run raised. ++ def failure(error, podspec) ++ where = where(error, podspec) ++ if error.is_a?(NameError) ++ receiver = receiver_of(error) ++ name = error.name.to_s ++ if receiver.is_a?(Pod::Specification) || receiver.is_a?(Pod::Specification::PlatformProxy) ++ attribute = name.chomp('=') ++ return ['attribute', "#{where}: the podspec sets #{receiver_text(error, podspec, receiver, attribute)}.#{attribute}, " \ ++ 'which CocoaPods does not define'] ++ end ++ if modeled?(receiver) ++ if !error.is_a?(NoMethodError) && name.match?(/\A[A-Z]/) ++ return ['constant', "#{where}: the podspec uses #{name}, which rn-xtool's podspec reader does not model"] ++ end ++ return ['method', "#{where}: the podspec calls #{name}(…), which rn-xtool's podspec reader does not model"] ++ end ++ end ++ message = error.message ++ message = message.sub(/\A.+?:\d+: /, '') if error.is_a?(SyntaxError) ++ ['raised', "#{where}: #{message.rstrip}"] ++ end ++ ++ # The error's receiver, or nil when Ruby kept none. ++ def receiver_of(error) ++ error.receiver ++ rescue ArgumentError ++ nil ++ end ++ ++ # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. ++ def modeled?(receiver) ++ return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) ++ ++ namespace = Module === receiver ? receiver : receiver.class ++ namespace.name.to_s.split('::').first == 'Pod' ++ end ++ ++ # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. ++ def receiver_text(error, podspec, receiver, attribute) ++ path, line = frame(error, podspec) ++ source = path && source_line(path, line) ++ found = source && source[/([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*\.\s*#{Regexp.escape(attribute)}(?!\w)/, 1] ++ return found if found ++ ++ receiver.is_a?(Pod::Specification) ? 'spec' : "spec.#{receiver.instance_variable_get(:@platform)}" ++ end ++ ++ def source_line(path, line) ++ File.readlines(path, encoding: 'UTF-8')[line - 1] ++ rescue SystemCallError ++ nil ++ end ++ ++ # `:` for a frame in the podspec, ` (:)` for one in another of the library's ++ # files (relative to the podspec's folder), or `` alone. ++ def where(error, podspec) ++ path, line = frame(error, podspec) ++ return podspec unless path ++ return "#{podspec}:#{line}" if File.expand_path(path) == File.expand_path(podspec) ++ ++ "#{podspec} (#{relative(path, podspec)}:#{line})" ++ end ++ ++ # The innermost [path, line] of the error in the podspec or another of the library's files, never the shim's. ++ def frame(error, podspec) ++ frames = (error.backtrace_locations || []).map { |location| [location.path, location.lineno] } ++ # A syntax error names its place only in its message. ++ frames.unshift([Regexp.last_match(1), Regexp.last_match(2).to_i]) if error.is_a?(SyntaxError) && error.message =~ /\A(.+?):(\d+): / ++ frames.find do |path, _| ++ next true if File.expand_path(path) == File.expand_path(podspec) ++ ++ # Ruby's own frames (``, `(eval)`) have no absolute path. ++ path.start_with?('/') && File.expand_path(path) != File.expand_path(__FILE__) && !relative(path, podspec).nil? ++ end ++ end ++ ++ # `path` relative to the podspec's folder (as given or with its links resolved), or nil outside it. ++ def relative(path, podspec) ++ full = File.expand_path(path) ++ folder = File.dirname(File.expand_path(podspec)) ++ [folder, real(folder)].each do |root| ++ return full[(root.length + 1)..-1] if full.start_with?("#{root}/") ++ end ++ nil ++ end ++ ++ def real(folder) ++ File.realpath(folder) ++ rescue SystemCallError ++ folder ++ end ++end ++ ++abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 ++exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js index 8fcf04b..6897fdb 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js diff --git a/tests/ci/workflow.test.ts b/tests/ci/workflow.test.ts index 6fa0020..6b51e58 100644 --- a/tests/ci/workflow.test.ts +++ b/tests/ci/workflow.test.ts @@ -21,6 +21,7 @@ type Workflow = { const text = (): string => readFileSync(WORKFLOW, "utf8"); const doc = (): Workflow => parse(text()) as Workflow; const steps = (): Step[] => Object.values(doc().jobs).flatMap((j) => j.steps); +const jobSteps = (job: string): Step[] => doc().jobs[job]!.steps; const lines = (): string[] => text().split("\n"); const indent = (l: string): number => l.length - l.trimStart().length; @@ -47,9 +48,14 @@ const RUNS = [ "npm run lint", // The scan runs before the tests, so a red suite never hides a leak. "npm run scan:private", + // The podspec shim's tests fail without Ruby on CI: the step says which Ruby they ran on. + "ruby --version", "npm test -- --reporter=default --reporter=json --outputFile=test-results.json", 'node scripts/ci-skipped.mjs test-results.json >> "$GITHUB_STEP_SUMMARY"', ]; +/** The shim-ruby-floor job: the podspec shim's tests on the oldest Ruby the shim supports. */ +const FLOOR_RUNS = ["npm ci", "npx vitest run tests/podspecShim.test.ts"]; +const SHIM = path.join(root, "vendor", "rn-spm", "spm", "read-podspec-shim.rb"); describe("CI workflow", () => { it("runs on PRs to main and on pushes to main", () => { @@ -68,9 +74,9 @@ describe("CI workflow", () => { it("keeps credentials and secrets out", () => { const checkouts = steps().filter((s) => s.uses?.startsWith("actions/checkout")); - expect(checkouts).toHaveLength(1); + expect(checkouts).toHaveLength(2); for (const c of checkouts) expect(c.with?.["persist-credentials"]).toBe(false); - expect(text().match(/persist-credentials: false/g)).toHaveLength(1); + expect(text().match(/persist-credentials: false/g)).toHaveLength(2); expect(text()).not.toMatch(/secrets\./); expect(text()).not.toContain("GH_TOKEN"); expect(text()).not.toMatch(/\btoken\b/i); @@ -78,25 +84,33 @@ describe("CI workflow", () => { it("never puts an expression into run text", () => { const runs = runBlocks(); - expect(runs).toHaveLength(RUNS.length); + expect(runs).toHaveLength(RUNS.length + FLOOR_RUNS.length); for (const r of runs) expect(r).not.toContain("${{"); for (const s of steps()) if (s.run !== undefined) expect(s.run).not.toContain("${{"); }); - it("uses Node 22 on hosted Ubuntu and two actions", () => { - const uses = steps().flatMap((s) => (s.uses ? [s.uses] : [])); - expect(uses).toEqual(["actions/checkout@v7", "actions/setup-node@v7"]); - const node = steps().find((s) => s.uses === "actions/setup-node@v7")!; - expect(node.with?.["node-version"]).toBe(22); - expect(node.with?.["cache"]).toBe("npm"); + it("uses Node 22 on hosted Ubuntu, and setup-ruby only for the Ruby floor", () => { + const uses = (job: string) => jobSteps(job).flatMap((s) => (s.uses ? [s.uses] : [])); + expect(uses("test")).toEqual(["actions/checkout@v7", "actions/setup-node@v7"]); + expect(uses("shim-ruby-floor")).toEqual(["actions/checkout@v7", "actions/setup-node@v7", "ruby/setup-ruby@v1"]); + for (const node of steps().filter((s) => s.uses === "actions/setup-node@v7")) { + expect(node.with?.["node-version"]).toBe(22); + expect(node.with?.["cache"]).toBe("npm"); + } const runsOn = Object.values(doc().jobs).map((j) => j["runs-on"]); - expect(runsOn).toEqual(["ubuntu-latest"]); + expect(runsOn).toEqual(["ubuntu-latest", "ubuntu-22.04"]); + }); + + it("runs the shim's tests on the Ruby floor the shim reports", () => { + const ruby = jobSteps("shim-ruby-floor").find((s) => s.uses === "ruby/setup-ruby@v1")!; + const floor = /^RN_XTOOL_RUBY_FLOOR = '(\d+\.\d+)\.\d+'$/m.exec(readFileSync(SHIM, "utf8"))?.[1]; + expect(ruby.with?.["ruby-version"]).toBe(floor); }); it("stops a stuck job after 15 minutes", () => { // The fetch script's npm pack has no timeout of its own; the job's covers it. - expect(Object.keys(doc().jobs)).toEqual(["test"]); - expect(doc().jobs["test"]!["timeout-minutes"]).toBe(15); + expect(Object.keys(doc().jobs)).toEqual(["test", "shim-ruby-floor"]); + for (const job of Object.values(doc().jobs)) expect(job["timeout-minutes"]).toBe(15); }); it("cancels the older run of the same PR, never a run on main", () => { @@ -117,11 +131,14 @@ describe("CI workflow", () => { }); it("runs the steps in order", () => { - const runs = steps().flatMap((s) => (s.run !== undefined ? [s.run.trim()] : [])); - expect(runs).toEqual(RUNS); - const all = steps(); - expect(all.findIndex((s) => s.uses?.startsWith("actions/checkout"))).toBe(0); - expect(all.findIndex((s) => s.uses?.startsWith("actions/setup-node"))).toBe(1); + const runs = (job: string) => jobSteps(job).flatMap((s) => (s.run !== undefined ? [s.run.trim()] : [])); + expect(runs("test")).toEqual(RUNS); + expect(runs("shim-ruby-floor")).toEqual(FLOOR_RUNS); + for (const job of Object.keys(doc().jobs)) { + const all = jobSteps(job); + expect(all.findIndex((s) => s.uses?.startsWith("actions/checkout")), job).toBe(0); + expect(all.findIndex((s) => s.uses?.startsWith("actions/setup-node")), job).toBe(1); + } }); it("lists the skipped tests in the summary, even when the tests fail", () => { diff --git a/tests/packageFiles.test.ts b/tests/packageFiles.test.ts index 9ea8044..074143e 100644 --- a/tests/packageFiles.test.ts +++ b/tests/packageFiles.test.ts @@ -45,4 +45,8 @@ describe("the npm package", () => { it("ships the pod table and the vendors' terms", () => { expect(listed()).toEqual(expect.arrayContaining(["data/pods.json", "data/pod-terms.json"])); }); + + it("ships the podspec reader's shim", () => { + expect(listed()).toContain("vendor/rn-spm/spm/read-podspec-shim.rb"); + }); }); diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts new file mode 100644 index 0000000..740bc7f --- /dev/null +++ b/tests/podspecShim.test.ts @@ -0,0 +1,112 @@ +import { describe, expect, it } from "vitest"; +import { SHIM, needsRuby, runShim } from "./support/ruby.js"; +import { tool } from "./support/tools.js"; + +// The podspec reader's Ruby shim (vendor/rn-spm/spm/read-podspec-shim.rb), run by the real `ruby` on podspecs written +// into temp folders. The shim-ruby-floor CI job runs this file on the oldest Ruby the shim supports. +const spec = (...lines: string[]) => ["Pod::Spec.new do |s|", ' s.name = "Foo"', ...lines, "end"].join("\n"); + +describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { + it("--probe prints the Ruby version and the floor", () => { + expect(JSON.parse(tool("ruby", [SHIM, "--probe"]).stdout)).toEqual({ ruby: expect.stringMatching(/^\d+\.\d+\.\d+/), floor: "2.7.0", usable: true }); + }); + + it("writes the spec in CocoaPods' JSON form", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo"\n s.version = "1.2.3"\n s.source_files = "ios/**/*.{h,m}"\n s.dependency "React-Core"\n s.dependency "Bar", "~> 1.0"\n s.pod_target_xcconfig = { "OTHER_CFLAGS" => "-DX=1" }\n s.ios.deployment_target = "15.1"\n s.source = { :git => "x", :tag => "v#{s.version}" }\nend`); + expect(r.status).toBe(0); + expect(r.json).toEqual({ name: "Foo", version: "1.2.3", source_files: "ios/**/*.{h,m}", dependencies: { "React-Core": [], Bar: ["~> 1.0"] }, + pod_target_xcconfig: { OTHER_CFLAGS: "-DX=1" }, platforms: { ios: "15.1" }, source: { git: "x", tag: "v1.2.3" }, + __rn_xtool__: { env: [], helpers: [], ui: [], spm_dependencies: [] } }); + }); + + it("nests subspecs under their base name and keeps test specs apart", () => { + const r = runShim(spec( + ' s.default_subspec = "core"', + ' s.subspec "core" do |ss|', + " ss.summary = ss.name", + ' ss.subspec "deep" do |d|', + " d.summary = d.name", + " end", + " end", + ' s.test_spec "Tests" do |t|', + ' t.source_files = "Tests/*.m"', + " end", + )); + expect(r.status).toBe(0); + expect(r.json.subspecs).toEqual([{ name: "core", summary: "Foo/core", subspecs: [{ name: "deep", summary: "Foo/core/deep" }] }]); + expect(r.json.default_subspecs).toEqual(["core"]); + expect(r.json.testspecs).toEqual([{ name: "Tests", source_files: "Tests/*.m" }]); + expect(r.json.subspecs.map((s: { name: string }) => s.name)).not.toContain("Tests"); + expect(runShim(spec(" s.default_subspecs = :none")).json.default_subspecs).toBe("none"); + }); + + it("stores platform-scoped attributes under their platform", () => { + const r = runShim(spec( + ' s.platform = :ios, "12.0"', + ' s.ios.exclude_files = "a"', + ' s.osx.exclude_files = "b"', + ' s.macos.frameworks = "AppKit"', + " s.summary = s.respond_to?(:visionos).to_s", + ' s.subspec "core" do |ss|', + ' ss.ios.dependency "X"', + " end", + )); + expect(r.status).toBe(0); + expect(r.json.platforms).toEqual({ ios: "12.0" }); + expect(r.json.ios).toEqual({ exclude_files: "a" }); + expect(r.json.osx).toEqual({ exclude_files: "b", frameworks: "AppKit" }); + expect(r.json.summary).toBe("true"); + expect(r.json.subspecs[0].ios).toEqual({ dependencies: { X: [] } }); + }); + + it("stores a singular alias under the plural key", () => { + const r = runShim(spec(' s.framework = "UIKit"', ' s.author = "a"')); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ frameworks: "UIKit", authors: "a" }); + expect(r.json).not.toHaveProperty("framework"); + expect(r.json).not.toHaveProperty("author"); + }); + + it("refuses an attribute CocoaPods does not define", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo"\n s.not_an_attribute = 1\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "attribute"]); + expect(r.json.error.message).toBe(`${r.podspec}:3: the podspec sets s.not_an_attribute, which CocoaPods does not define`); + }); + + it("names an unmodeled method with its line", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.source_files = sources_for("ios")\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "method"]); + expect(r.json.error.message).toBe(`${r.podspec}:2: the podspec calls sources_for(…), which rn-xtool's podspec reader does not model`); + }); + + it("names an unmodeled constant", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.version = Foo::Bar.baz\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "constant"]); + expect(r.json.error.message).toBe(`${r.podspec}:2: the podspec uses Foo, which rn-xtool's podspec reader does not model`); + }); + + it("names the library file a failure comes from", () => { + const r = runShim(`require_relative "scripts/x"\n${spec()}`, { files: { "scripts/x.rb": "# one\n# two\n# three\nnope()\n" } }); + expect([r.status, r.json.error.kind]).toEqual([1, "method"]); + expect(r.json.error.message).toBe(`${r.podspec} (scripts/x.rb:4): the podspec calls nope(…), which rn-xtool's podspec reader does not model`); + }); + + it("passes the podspec's own raise on with its line", () => { + const r = runShim(`Pod::Spec.new do |s|\n raise "boom"\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message).toBe(`${r.podspec}:2: boom`); + }); + + it("refuses a file that is not a spec", () => { + const r = runShim("42\n"); + expect([r.status, r.json.error.kind]).toEqual([1, "not-a-spec"]); + expect(r.json.error.message).toBe(`${r.podspec}: the podspec does not evaluate to a Pod::Spec`); + }); + + it("keeps the model out of the podspec's prints", () => { + const r = runShim(`puts "{ not json }"\n${spec()}`); + expect(r.status).toBe(0); + expect(r.json.name).toBe("Foo"); + expect(r.stdout).toContain("{ not json }"); + }); +}); diff --git a/tests/rn-scaffolder.test.ts b/tests/rn-scaffolder.test.ts index a4a9ded..6187408 100644 --- a/tests/rn-scaffolder.test.ts +++ b/tests/rn-scaffolder.test.ts @@ -217,6 +217,7 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () expect(reader).toContain("function unresolvedSourcesReason"); expect(src("scaffold-package-swift.js")).toContain("unresolvedSourcesReason(podspecPath, model)"); }); + it("the scaffolder has the fix 29 shim", () => expect(existsSync(path.join(SPM, "read-podspec-shim.rb"))).toBe(true)); }); it("gives the per-app header farm a header-less module map, so Objective-C imports it textually", () => { diff --git a/tests/support/ruby.ts b/tests/support/ruby.ts new file mode 100644 index 0000000..172deab --- /dev/null +++ b/tests/support/ruby.ts @@ -0,0 +1,61 @@ +/** + * The podspec reader's Ruby shim (`vendor/rn-spm/spm/read-podspec-shim.rb`), run on a podspec written into a temp + * folder, as rn-xtool runs it: in the podspec's folder, with `PATH`, `HOME`, `LANG` and React Native's two pod + * variables only. Each folder is removed after the test file. + */ +import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { afterAll } from "vitest"; +import { packageRoot } from "../../src/tools/exec.js"; +import { hasTool, tool } from "./tools.js"; + +export const SHIM = path.join(packageRoot(), "vendor", "rn-spm", "spm", "read-podspec-shim.rb"); + +const hasRuby = hasTool("ruby"); +// CI installs Ruby: a missing one there fails the file instead of skipping the shim's tests. +if (!hasRuby && process.env.CI === "true") throw new Error("ruby is not on PATH; CI must run the podspec shim's tests"); +/** `""` when `ruby` runs here, else a title suffix that says the tests need it. */ +export const needsRuby = hasRuby ? "" : " (needs ruby)"; + +const tmp: string[] = []; +afterAll(() => { + for (const d of tmp) rmSync(d, { recursive: true, force: true }); +}); + +export type ShimRun = { status: number; json: any; stdout: string; podspec: string }; + +/** + * Writes `body` as `Foo.podspec` and `files` (paths relative to it) into a temp library folder, runs the shim on it + * there with `ruby ` (`root` defaults to that folder), and returns the exit status, + * the parsed out file (undefined when the shim wrote none), the shim's stdout and the podspec's path. + */ +export function runShim( + body: string, + opts: { files?: Record; env?: Record; root?: string } = {}, +): ShimRun { + const base = mkdtempSync(path.join(tmpdir(), "rn-xtool-shim-")); + tmp.push(base); + const lib = path.join(base, "lib"); + mkdirSync(lib); + const podspec = path.join(lib, "Foo.podspec"); + writeFileSync(podspec, body); + for (const [file, text] of Object.entries(opts.files ?? {})) { + mkdirSync(path.dirname(path.join(lib, file)), { recursive: true }); + writeFileSync(path.join(lib, file), text); + } + const out = path.join(base, "out.json"); + const inherited = Object.fromEntries( + (["PATH", "HOME", "LANG"] as const).flatMap((k) => (process.env[k] === undefined ? [] : [[k, process.env[k]!]])), + ); + const r = tool("ruby", [SHIM, podspec, out, opts.root ?? lib], { + cwd: lib, + env: { ...inherited, RCT_NEW_ARCH_ENABLED: "1", RCT_HERMES_V1_ENABLED: "1", ...opts.env }, + }); + return { + status: r.status ?? -1, + json: existsSync(out) ? JSON.parse(readFileSync(out, "utf8")) : undefined, + stdout: r.stdout, + podspec, + }; +} diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb new file mode 100644 index 0000000..d4f4cf1 --- /dev/null +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -0,0 +1,298 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# rn-xtool's podspec reader: runs a podspec with the system Ruby as CocoaPods runs it, against a shim of CocoaPods' +# DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). +# +# ruby read-podspec-shim.rb --probe +# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. +# ruby read-podspec-shim.rb +# run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. +# Nothing of the shim's own goes to stdout; the podspec's prints do. +# +# Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. + +RN_XTOOL_RUBY_FLOOR = '2.7.0' +if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 + why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" + abort why unless ARGV == ['--probe'] + puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) + exit 0 +end + +require 'json' + +if ARGV == ['--probe'] + puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) + exit 0 +end + +module Pod + # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. + class Specification + # Set on the root spec only, never per platform. + ROOT_ATTRIBUTES = %w[ + name version swift_versions cocoapods_version authors social_media_url license homepage readme changelog source + summary description screenshots documentation_url prepare_command static_framework deprecated + deprecated_in_favor_of + ].freeze + # Also set per platform (`s.ios.frameworks = ...`). + PLATFORM_ATTRIBUTES = %w[ + requires_arc frameworks weak_frameworks libraries compiler_flags pod_target_xcconfig user_target_xcconfig xcconfig + prefix_header_contents prefix_header_file module_name header_dir header_mappings_dir script_phases + on_demand_resources info_plist source_files public_header_files project_header_files private_header_files + vendored_frameworks vendored_libraries resource_bundles resources exclude_files preserve_paths module_map + requires_app_host app_host_name scheme test_type + ].freeze + ATTRIBUTES = (ROOT_ATTRIBUTES + %w[platforms default_subspecs] + PLATFORM_ATTRIBUTES).freeze + # Stored under the plural key. + SINGULAR_ALIASES = { + 'swift_version' => 'swift_versions', 'author' => 'authors', 'screenshot' => 'screenshots', + 'framework' => 'frameworks', 'weak_framework' => 'weak_frameworks', 'library' => 'libraries', + 'compiler_flag' => 'compiler_flags', 'script_phase' => 'script_phases', + 'vendored_framework' => 'vendored_frameworks', 'vendored_library' => 'vendored_libraries', + 'resource_bundle' => 'resource_bundles', 'resource' => 'resources', 'preserve_path' => 'preserve_paths', + 'default_subspec' => 'default_subspecs' + }.freeze + # The platform proxies, and the platform each stores under. + PLATFORMS = { + 'ios' => 'ios', 'osx' => 'osx', 'macos' => 'osx', 'tvos' => 'tvos', 'visionos' => 'visionos', + 'watchos' => 'watchos' + }.freeze + + def initialize(parent = nil, name = nil) + @parent = parent + @attributes = {} + @attributes['name'] = name if name + @subspecs = [] + @testspecs = [] + @appspecs = [] + yield self if block_given? + end + + ATTRIBUTES.each do |attribute| + define_method("#{attribute}=") { |value| @attributes[attribute] = value } + define_method(attribute) { @attributes[attribute] } unless attribute == 'name' + end + SINGULAR_ALIASES.each do |singular, plural| + define_method("#{singular}=") { |value| @attributes[plural] = value } + end + PLATFORMS.each do |proxy, platform| + define_method(proxy) { PlatformProxy.new(@attributes, platform) } + end + + # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. + def name + @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] + end + + def platform=(value) + platform, deployment_target = value + @attributes['platforms'] = platform ? { PLATFORMS.fetch(platform.to_s, platform.to_s) => deployment_target } : {} + end + + def dependency(name, *requirements) + (@attributes['dependencies'] ||= {})[name] = requirements + end + + def subspec(name, &block) + add(@subspecs, name, &block) + end + + def test_spec(name = 'Tests', &block) + add(@testspecs, name, &block) + end + + def app_spec(name = 'App', &block) + add(@appspecs, name, &block) + end + + # The spec in CocoaPods' JSON form. + def to_model + model = RnXtoolShim.plain(@attributes) + if model.key?('default_subspecs') + model['default_subspecs'] = Array(model['default_subspecs']) unless model['default_subspecs'] == 'none' + end + { 'subspecs' => @subspecs, 'testspecs' => @testspecs, 'appspecs' => @appspecs }.each do |key, specs| + model[key] = specs.map(&:to_model) unless specs.empty? + end + model + end + + private + + def add(list, name, &block) + spec = Specification.new(self, name, &block) + list << spec + spec + end + + # `s.ios`, `s.osx` (and `s.macos`), `s.tvos`, `s.visionos`, `s.watchos`: stores under the spec's platform key. + class PlatformProxy + def initialize(attributes, platform) + @attributes = attributes + @platform = platform + end + + PLATFORM_ATTRIBUTES.each do |attribute| + define_method("#{attribute}=") { |value| scoped[attribute] = value } + end + SINGULAR_ALIASES.each do |singular, plural| + define_method("#{singular}=") { |value| scoped[plural] = value } if PLATFORM_ATTRIBUTES.include?(plural) + end + + def deployment_target=(value) + (@attributes['platforms'] ||= {})[@platform] = value + end + + def dependency(name, *requirements) + (scoped['dependencies'] ||= {})[name] = requirements + end + + private + + def scoped + @attributes[@platform] ||= {} + end + end + end + + Spec = Specification + + # As CocoaPods-core evaluates a podspec: `self` is `Pod`, and `Spec` resolves inside it. + def self._eval_podspec(string, path) + eval(string, nil, path) + end +end + +# The command line's run: evaluate, then write the model or the error file. +module RnXtoolShim + module_function + + # Writes the model, or the error, to `out`; whether the podspec read. + def run(podspec, out) + spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) + unless spec.is_a?(Pod::Specification) + write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) + return false + end + write(out, spec.to_model.merge( + '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } + )) + true + rescue ScriptError, StandardError, SystemExit => e + kind, message = failure(e, podspec) + write(out, 'error' => { 'kind' => kind, 'message' => message }) + false + end + + def write(out, value) + File.write(out, JSON.generate(value)) + end + + # A value as CocoaPods' JSON form writes it: symbols, hash keys and Pathnames as strings. + def plain(value) + case value + when Hash then value.each_with_object({}) { |(key, item), out| out[key.to_s] = plain(item) } + when Array then value.map { |item| plain(item) } + when String, Numeric, true, false, nil then value + else value.to_s + end + end + + # [kind, message] of an exception the podspec's run raised. + def failure(error, podspec) + where = where(error, podspec) + if error.is_a?(NameError) + receiver = receiver_of(error) + name = error.name.to_s + if receiver.is_a?(Pod::Specification) || receiver.is_a?(Pod::Specification::PlatformProxy) + attribute = name.chomp('=') + return ['attribute', "#{where}: the podspec sets #{receiver_text(error, podspec, receiver, attribute)}.#{attribute}, " \ + 'which CocoaPods does not define'] + end + if modeled?(receiver) + if !error.is_a?(NoMethodError) && name.match?(/\A[A-Z]/) + return ['constant', "#{where}: the podspec uses #{name}, which rn-xtool's podspec reader does not model"] + end + return ['method', "#{where}: the podspec calls #{name}(…), which rn-xtool's podspec reader does not model"] + end + end + message = error.message + message = message.sub(/\A.+?:\d+: /, '') if error.is_a?(SyntaxError) + ['raised', "#{where}: #{message.rstrip}"] + end + + # The error's receiver, or nil when Ruby kept none. + def receiver_of(error) + error.receiver + rescue ArgumentError + nil + end + + # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. + def modeled?(receiver) + return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) + + namespace = Module === receiver ? receiver : receiver.class + namespace.name.to_s.split('::').first == 'Pod' + end + + # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. + def receiver_text(error, podspec, receiver, attribute) + path, line = frame(error, podspec) + source = path && source_line(path, line) + found = source && source[/([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*\.\s*#{Regexp.escape(attribute)}(?!\w)/, 1] + return found if found + + receiver.is_a?(Pod::Specification) ? 'spec' : "spec.#{receiver.instance_variable_get(:@platform)}" + end + + def source_line(path, line) + File.readlines(path, encoding: 'UTF-8')[line - 1] + rescue SystemCallError + nil + end + + # `:` for a frame in the podspec, ` (:)` for one in another of the library's + # files (relative to the podspec's folder), or `` alone. + def where(error, podspec) + path, line = frame(error, podspec) + return podspec unless path + return "#{podspec}:#{line}" if File.expand_path(path) == File.expand_path(podspec) + + "#{podspec} (#{relative(path, podspec)}:#{line})" + end + + # The innermost [path, line] of the error in the podspec or another of the library's files, never the shim's. + def frame(error, podspec) + frames = (error.backtrace_locations || []).map { |location| [location.path, location.lineno] } + # A syntax error names its place only in its message. + frames.unshift([Regexp.last_match(1), Regexp.last_match(2).to_i]) if error.is_a?(SyntaxError) && error.message =~ /\A(.+?):(\d+): / + frames.find do |path, _| + next true if File.expand_path(path) == File.expand_path(podspec) + + # Ruby's own frames (``, `(eval)`) have no absolute path. + path.start_with?('/') && File.expand_path(path) != File.expand_path(__FILE__) && !relative(path, podspec).nil? + end + end + + # `path` relative to the podspec's folder (as given or with its links resolved), or nil outside it. + def relative(path, podspec) + full = File.expand_path(path) + folder = File.dirname(File.expand_path(podspec)) + [folder, real(folder)].each do |root| + return full[(root.length + 1)..-1] if full.start_with?("#{root}/") + end + nil + end + + def real(folder) + File.realpath(folder) + rescue SystemCallError + folder + end +end + +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) From 8ce7280b537963f45981917391e23764a40de0e3 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 13:53:06 -0600 Subject: [PATCH 06/53] test: cover the shim's raised paths --- tests/podspecShim.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index 740bc7f..d88409f 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -97,6 +97,31 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { expect(r.json.error.message).toBe(`${r.podspec}:2: boom`); }); + // Ruby words these messages differently from version to version: the tests pin the kind and the place only. + it("passes a syntax error in the podspec on with its line", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo" )\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message.startsWith(`${r.podspec}:2: `)).toBe(true); + }); + + it("passes a syntax error in a library file on with that file's line", () => { + const r = runShim(`require_relative "scripts/x"\n${spec()}`, { files: { "scripts/x.rb": 'x = "a" )\n' } }); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message.startsWith(`${r.podspec} (scripts/x.rb:1): `)).toBe(true); + }); + + it("passes a method called on nil on as the podspec's own failure", () => { + const r = runShim(`Pod::Spec.new do |s|\n s.name = nil.upcase\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message.startsWith(`${r.podspec}:2: `)).toBe(true); + }); + + it("passes the podspec's exit on as a failure", () => { + const r = runShim(`Pod::Spec.new do |s|\n exit 0\nend`); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message.startsWith(`${r.podspec}:2: `)).toBe(true); + }); + it("refuses a file that is not a spec", () => { const r = runShim("42\n"); expect([r.status, r.json.error.kind]).toEqual([1, "not-a-spec"]); From c20ca042246fcc54700910e182b7669291d380c0 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 14:06:25 -0600 Subject: [PATCH 07/53] feat: model CocoaPods and React Native helpers --- patches/react-native+0.88.0.patch | 210 +++++++++++++++++++++++-- patches/react-native+0.88.1.patch | 210 +++++++++++++++++++++++-- tests/podspecShim.test.ts | 153 +++++++++++++++++- tests/support/ruby.ts | 10 +- vendor/rn-spm/spm/read-podspec-shim.rb | 206 ++++++++++++++++++++++-- 5 files changed, 755 insertions(+), 34 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 824e311..0a34f8a 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -1,9 +1,9 @@ diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..d4f4cf1 +index 0000000..a85a5a8 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,298 @@ +@@ -0,0 +1,486 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -26,6 +26,11 @@ index 0000000..d4f4cf1 + exit 0 +end + ++# A podspec's files read as UTF-8 whatever the locale (`LANG=C` would make them US-ASCII). ++Encoding.default_external = Encoding::UTF_8 ++# Ruby's own load path, before any gem activates: the names a podspec's `require` may load. ++RN_XTOOL_LOAD_PATH = $LOAD_PATH.dup.freeze ++ +require 'json' + +if ARGV == ['--probe'] @@ -33,6 +38,9 @@ index 0000000..d4f4cf1 + exit 0 +end + ++require 'pathname' ++require 'singleton' ++ +module Pod + # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. + class Specification @@ -171,20 +179,188 @@ index 0000000..d4f4cf1 + end +end + -+# The command line's run: evaluate, then write the model or the error file. ++# ---- The podspec's environment ---- ++# What a Podfile that requires React Native's `react_native_pods.rb` (and Expo's autolinking) gives a podspec under ++# CocoaPods 1.16. Each part records what the podspec used. ++ ++module RnXtoolShim ++ # What the podspec's run used, written as the model's `__rn_xtool__`. ++ USED = { env: [], helpers: [], ui: [], spm_dependencies: [] }.freeze ++ ++ def self.used(kind, value) ++ USED.fetch(kind) << value ++ nil ++ end ++end ++ ++# CocoaPods: its version, `Pod::UI` and `Pod::Config`. ++module Pod ++ VERSION = '1.16.2' ++ ++ # What the podspec prints through CocoaPods: captured into `ui`, not printed. ++ module UI ++ def self.puts(message = '') ++ RnXtoolShim.used(:ui, message.to_s) ++ end ++ ++ def self.warn(message, _actions = [], _verbose_only = false) ++ RnXtoolShim.used(:ui, message.to_s) ++ end ++ ++ # CocoaPods runs the block under the message. ++ def self.info(message) ++ RnXtoolShim.used(:ui, message.to_s) ++ yield if block_given? ++ end ++ end ++ ++ # The app's `ios/` folder, from the command line's installation root; `Pods` in it need not exist. No Podfile. ++ class Config ++ class << self ++ attr_accessor :instance ++ end ++ ++ attr_reader :installation_root, :project_pods_root ++ alias project_root installation_root ++ ++ def initialize(installation_root) ++ @installation_root = Pathname.new(installation_root) ++ @project_pods_root = @installation_root + 'Pods' ++ end ++ end ++end ++ ++# Expo's autolinking (expo-modules-autolinking's `packages_config.rb`) as it answers for a build from sources: no core ++# features, no prebuilt xcframework linked. ++module Expo ++ class PackagesConfig ++ include Singleton ++ ++ attr_reader :coreFeatures ++ ++ def initialize ++ @coreFeatures = [] ++ end ++ ++ def try_link_with_prebuilt_xcframework(_spec) ++ false ++ end ++ end ++end ++ ++# React Native's Podfile helpers (scripts/react_native_pods.rb), with its signatures: a Podfile's `require` makes them ++# private methods of Object. Each call is recorded into `helpers`; the others of that file stay undefined. ++module RnXtoolShim ++ # React Native's `Helpers::Constants` (scripts/cocoapods/helpers.rb), the same in every supported line. ++ FOLLY_CONFIG = { ++ version: '2024.11.18.00', ++ git: 'https://github.com/facebook/folly.git', ++ compiler_flags: '-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 ' \ ++ '-Wno-comma -Wno-shorten-64-to-32' ++ }.freeze ++ MIN_IOS_VERSION_SUPPORTED = '15.1' ++end ++ ++class Object ++ private ++ ++ # Recorded only: the scaffold adds React Native's dependencies itself. ++ def install_modules_dependencies(spec, new_arch_enabled: true) ++ RnXtoolShim.used(:helpers, 'install_modules_dependencies') ++ end ++ ++ def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, ++ base_dir: 'PODS_CONFIGURATION_BUILD_DIR') ++ RnXtoolShim.used(:helpers, 'add_dependency') ++ spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) ++ end ++ ++ # A fresh hash per call: podspecs append to its flags. ++ def get_folly_config ++ RnXtoolShim.used(:helpers, 'get_folly_config') ++ RnXtoolShim::FOLLY_CONFIG.transform_values(&:dup) ++ end ++ ++ def min_ios_version_supported ++ RnXtoolShim.used(:helpers, 'min_ios_version_supported') ++ RnXtoolShim::MIN_IOS_VERSION_SUPPORTED.dup ++ end ++ ++ # Recorded with its arguments, so that the scaffold can refuse the library by name. ++ def spm_dependency(spec, url:, requirement:, products:) ++ RnXtoolShim.used(:helpers, 'spm_dependency') ++ RnXtoolShim.used(:spm_dependencies, { url: url, requirement: requirement, products: products }) ++ end ++end ++ ++# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` ++# of the library's own files is Ruby's. ++module RnXtoolShim ++ # colored2 (a gem CocoaPods brings): its String colours and effects. ++ COLORED2 = %w[ ++ black red green yellow blue magenta cyan white no_color bold dark italic underlined reversed plain normal ++ ].freeze ++ ++ # A `require` of a name that is neither on Ruby's own load path nor stubbed. ++ class Unstubbed < LoadError; end ++ ++ def self.on_load_path?(feature) ++ files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] ++ RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } ++ end ++ ++ # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. ++ def self.load_colored2 ++ return false if @colored2 ++ ++ COLORED2.each { |method| String.send(:define_method, method) { dup } } ++ @colored2 = true ++ end ++end ++ ++class Object ++ private ++ ++ def require(name) ++ feature = name.to_s ++ return RnXtoolShim.load_colored2 if feature == 'colored2' ++ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) ++ ++ super ++ end ++end ++ ++# `ENV` as the podspec reads it: each name read is recorded into `env`. ++module RnXtoolShim ++ module EnvReads ++ %i[[] fetch key? has_key? include? member?].each do |method| ++ define_method(method) do |name, *rest, &block| ++ RnXtoolShim.used(:env, name.to_s) ++ super(name, *rest, &block) ++ end ++ end ++ ++ def values_at(*names) ++ names.each { |name| RnXtoolShim.used(:env, name.to_s) } ++ super ++ end ++ end ++end ++ENV.singleton_class.prepend(RnXtoolShim::EnvReads) ++ ++# ---- The command line's run: evaluate, then write the model or the error file ---- +module RnXtoolShim + module_function + -+ # Writes the model, or the error, to `out`; whether the podspec read. -+ def run(podspec, out) ++ # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. ++ def run(podspec, out, root) ++ Pod::Config.instance = Pod::Config.new(root) + spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) + unless spec.is_a?(Pod::Specification) + write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) + return false + end -+ write(out, spec.to_model.merge( -+ '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } -+ )) ++ write(out, spec.to_model.merge('__rn_xtool__' => used_model)) + true + rescue ScriptError, StandardError, SystemExit => e + kind, message = failure(e, podspec) @@ -192,6 +368,14 @@ index 0000000..d4f4cf1 + false + end + ++ # `env` and `helpers` sorted and unique; `ui` and `spm_dependencies` as called. ++ def used_model ++ { ++ 'env' => USED[:env].uniq.sort, 'helpers' => USED[:helpers].uniq.sort, 'ui' => USED[:ui], ++ 'spm_dependencies' => plain(USED[:spm_dependencies]) ++ } ++ end ++ + def write(out, value) + File.write(out, JSON.generate(value)) + end @@ -208,6 +392,10 @@ index 0000000..d4f4cf1 + + # [kind, message] of an exception the podspec's run raised. + def failure(error, podspec) ++ if error.is_a?(Unstubbed) ++ return ['require', "#{podspec}: #{error.message}; rn-xtool's podspec reader stubs only colored2"] ++ end ++ + where = where(error, podspec) + if error.is_a?(NameError) + receiver = receiver_of(error) @@ -236,12 +424,12 @@ index 0000000..d4f4cf1 + nil + end + -+ # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. ++ # `Pod`, `Expo`, the main object, `Object` (a top-level constant) or an object of the shim's. + def modeled?(receiver) + return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) + + namespace = Module === receiver ? receiver : receiver.class -+ namespace.name.to_s.split('::').first == 'Pod' ++ %w[Pod Expo].include?(namespace.name.to_s.split('::').first) + end + + # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. @@ -301,7 +489,7 @@ index 0000000..d4f4cf1 +end + +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 -+exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) ++exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js index 8fcf04b..6897fdb 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 824e311..0a34f8a 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -1,9 +1,9 @@ diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..d4f4cf1 +index 0000000..a85a5a8 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,298 @@ +@@ -0,0 +1,486 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -26,6 +26,11 @@ index 0000000..d4f4cf1 + exit 0 +end + ++# A podspec's files read as UTF-8 whatever the locale (`LANG=C` would make them US-ASCII). ++Encoding.default_external = Encoding::UTF_8 ++# Ruby's own load path, before any gem activates: the names a podspec's `require` may load. ++RN_XTOOL_LOAD_PATH = $LOAD_PATH.dup.freeze ++ +require 'json' + +if ARGV == ['--probe'] @@ -33,6 +38,9 @@ index 0000000..d4f4cf1 + exit 0 +end + ++require 'pathname' ++require 'singleton' ++ +module Pod + # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. + class Specification @@ -171,20 +179,188 @@ index 0000000..d4f4cf1 + end +end + -+# The command line's run: evaluate, then write the model or the error file. ++# ---- The podspec's environment ---- ++# What a Podfile that requires React Native's `react_native_pods.rb` (and Expo's autolinking) gives a podspec under ++# CocoaPods 1.16. Each part records what the podspec used. ++ ++module RnXtoolShim ++ # What the podspec's run used, written as the model's `__rn_xtool__`. ++ USED = { env: [], helpers: [], ui: [], spm_dependencies: [] }.freeze ++ ++ def self.used(kind, value) ++ USED.fetch(kind) << value ++ nil ++ end ++end ++ ++# CocoaPods: its version, `Pod::UI` and `Pod::Config`. ++module Pod ++ VERSION = '1.16.2' ++ ++ # What the podspec prints through CocoaPods: captured into `ui`, not printed. ++ module UI ++ def self.puts(message = '') ++ RnXtoolShim.used(:ui, message.to_s) ++ end ++ ++ def self.warn(message, _actions = [], _verbose_only = false) ++ RnXtoolShim.used(:ui, message.to_s) ++ end ++ ++ # CocoaPods runs the block under the message. ++ def self.info(message) ++ RnXtoolShim.used(:ui, message.to_s) ++ yield if block_given? ++ end ++ end ++ ++ # The app's `ios/` folder, from the command line's installation root; `Pods` in it need not exist. No Podfile. ++ class Config ++ class << self ++ attr_accessor :instance ++ end ++ ++ attr_reader :installation_root, :project_pods_root ++ alias project_root installation_root ++ ++ def initialize(installation_root) ++ @installation_root = Pathname.new(installation_root) ++ @project_pods_root = @installation_root + 'Pods' ++ end ++ end ++end ++ ++# Expo's autolinking (expo-modules-autolinking's `packages_config.rb`) as it answers for a build from sources: no core ++# features, no prebuilt xcframework linked. ++module Expo ++ class PackagesConfig ++ include Singleton ++ ++ attr_reader :coreFeatures ++ ++ def initialize ++ @coreFeatures = [] ++ end ++ ++ def try_link_with_prebuilt_xcframework(_spec) ++ false ++ end ++ end ++end ++ ++# React Native's Podfile helpers (scripts/react_native_pods.rb), with its signatures: a Podfile's `require` makes them ++# private methods of Object. Each call is recorded into `helpers`; the others of that file stay undefined. ++module RnXtoolShim ++ # React Native's `Helpers::Constants` (scripts/cocoapods/helpers.rb), the same in every supported line. ++ FOLLY_CONFIG = { ++ version: '2024.11.18.00', ++ git: 'https://github.com/facebook/folly.git', ++ compiler_flags: '-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 ' \ ++ '-Wno-comma -Wno-shorten-64-to-32' ++ }.freeze ++ MIN_IOS_VERSION_SUPPORTED = '15.1' ++end ++ ++class Object ++ private ++ ++ # Recorded only: the scaffold adds React Native's dependencies itself. ++ def install_modules_dependencies(spec, new_arch_enabled: true) ++ RnXtoolShim.used(:helpers, 'install_modules_dependencies') ++ end ++ ++ def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, ++ base_dir: 'PODS_CONFIGURATION_BUILD_DIR') ++ RnXtoolShim.used(:helpers, 'add_dependency') ++ spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) ++ end ++ ++ # A fresh hash per call: podspecs append to its flags. ++ def get_folly_config ++ RnXtoolShim.used(:helpers, 'get_folly_config') ++ RnXtoolShim::FOLLY_CONFIG.transform_values(&:dup) ++ end ++ ++ def min_ios_version_supported ++ RnXtoolShim.used(:helpers, 'min_ios_version_supported') ++ RnXtoolShim::MIN_IOS_VERSION_SUPPORTED.dup ++ end ++ ++ # Recorded with its arguments, so that the scaffold can refuse the library by name. ++ def spm_dependency(spec, url:, requirement:, products:) ++ RnXtoolShim.used(:helpers, 'spm_dependency') ++ RnXtoolShim.used(:spm_dependencies, { url: url, requirement: requirement, products: products }) ++ end ++end ++ ++# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` ++# of the library's own files is Ruby's. ++module RnXtoolShim ++ # colored2 (a gem CocoaPods brings): its String colours and effects. ++ COLORED2 = %w[ ++ black red green yellow blue magenta cyan white no_color bold dark italic underlined reversed plain normal ++ ].freeze ++ ++ # A `require` of a name that is neither on Ruby's own load path nor stubbed. ++ class Unstubbed < LoadError; end ++ ++ def self.on_load_path?(feature) ++ files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] ++ RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } ++ end ++ ++ # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. ++ def self.load_colored2 ++ return false if @colored2 ++ ++ COLORED2.each { |method| String.send(:define_method, method) { dup } } ++ @colored2 = true ++ end ++end ++ ++class Object ++ private ++ ++ def require(name) ++ feature = name.to_s ++ return RnXtoolShim.load_colored2 if feature == 'colored2' ++ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) ++ ++ super ++ end ++end ++ ++# `ENV` as the podspec reads it: each name read is recorded into `env`. ++module RnXtoolShim ++ module EnvReads ++ %i[[] fetch key? has_key? include? member?].each do |method| ++ define_method(method) do |name, *rest, &block| ++ RnXtoolShim.used(:env, name.to_s) ++ super(name, *rest, &block) ++ end ++ end ++ ++ def values_at(*names) ++ names.each { |name| RnXtoolShim.used(:env, name.to_s) } ++ super ++ end ++ end ++end ++ENV.singleton_class.prepend(RnXtoolShim::EnvReads) ++ ++# ---- The command line's run: evaluate, then write the model or the error file ---- +module RnXtoolShim + module_function + -+ # Writes the model, or the error, to `out`; whether the podspec read. -+ def run(podspec, out) ++ # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. ++ def run(podspec, out, root) ++ Pod::Config.instance = Pod::Config.new(root) + spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) + unless spec.is_a?(Pod::Specification) + write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) + return false + end -+ write(out, spec.to_model.merge( -+ '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } -+ )) ++ write(out, spec.to_model.merge('__rn_xtool__' => used_model)) + true + rescue ScriptError, StandardError, SystemExit => e + kind, message = failure(e, podspec) @@ -192,6 +368,14 @@ index 0000000..d4f4cf1 + false + end + ++ # `env` and `helpers` sorted and unique; `ui` and `spm_dependencies` as called. ++ def used_model ++ { ++ 'env' => USED[:env].uniq.sort, 'helpers' => USED[:helpers].uniq.sort, 'ui' => USED[:ui], ++ 'spm_dependencies' => plain(USED[:spm_dependencies]) ++ } ++ end ++ + def write(out, value) + File.write(out, JSON.generate(value)) + end @@ -208,6 +392,10 @@ index 0000000..d4f4cf1 + + # [kind, message] of an exception the podspec's run raised. + def failure(error, podspec) ++ if error.is_a?(Unstubbed) ++ return ['require', "#{podspec}: #{error.message}; rn-xtool's podspec reader stubs only colored2"] ++ end ++ + where = where(error, podspec) + if error.is_a?(NameError) + receiver = receiver_of(error) @@ -236,12 +424,12 @@ index 0000000..d4f4cf1 + nil + end + -+ # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. ++ # `Pod`, `Expo`, the main object, `Object` (a top-level constant) or an object of the shim's. + def modeled?(receiver) + return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) + + namespace = Module === receiver ? receiver : receiver.class -+ namespace.name.to_s.split('::').first == 'Pod' ++ %w[Pod Expo].include?(namespace.name.to_s.split('::').first) + end + + # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. @@ -301,7 +489,7 @@ index 0000000..d4f4cf1 +end + +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 -+exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) ++exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js index 8fcf04b..6897fdb 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index d88409f..8aa1d88 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -1,10 +1,21 @@ +import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; import { describe, expect, it } from "vitest"; -import { SHIM, needsRuby, runShim } from "./support/ruby.js"; +import { packageRoot } from "../src/tools/exec.js"; +import { SHIM, needsRuby, runShim, tempDir } from "./support/ruby.js"; +import { needsTarball, tarballPath } from "./support/tarballs.js"; import { tool } from "./support/tools.js"; // The podspec reader's Ruby shim (vendor/rn-spm/spm/read-podspec-shim.rb), run by the real `ruby` on podspecs written // into temp folders. The shim-ruby-floor CI job runs this file on the oldest Ruby the shim supports. const spec = (...lines: string[]) => ["Pod::Spec.new do |s|", ' s.name = "Foo"', ...lines, "end"].join("\n"); +// React Native's folly compiler flags, as get_folly_config answers them. +const FOLLY_FLAGS = + "-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32"; +// The React Native lines rn-xtool supports, whose scripts/cocoapods/helpers.rb define the helpers' values. +const RN_LINES = ["0.85.0", "0.86.3", "0.87.1", "0.88.0", "0.88.1"].map((v) => `react-native@${v}`); +const NEEDS_RN = RN_LINES.map((line) => needsTarball(line)).find((needs) => needs !== "") ?? ""; +const WORKLETS = path.join(packageRoot(), "tests", "fixtures", "podspecs", "RNWorklets-0.8.3"); describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { it("--probe prints the Ruby version and the floor", () => { @@ -134,4 +145,144 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { expect(r.json.name).toBe("Foo"); expect(r.stdout).toContain("{ not json }"); }); + + describe("the environment", () => { + it("captures Pod::UI and does not print it", () => { + const r = runShim(`Pod::UI.puts "hi"\nPod::UI.warn "w"\n${spec()}`); + expect(r.status).toBe(0); + expect(r.json.__rn_xtool__.ui).toEqual(["hi", "w"]); + expect(r.stdout).toBe(""); + }); + + it("answers Pod::Config with the installation root", () => { + const r = runShim(spec( + " c = Pod::Config.instance", + ' s.summary = [c.installation_root, c.project_root, c.project_pods_root].map(&:to_s).join("|")', + ' s.readme = [c.installation_root, c.project_root, c.project_pods_root].map { |p| p.class.name }.uniq.join', + " s.description = c.instance_variable_defined?(:@podfile).to_s", + ), { root: "/r/ios" }); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "/r/ios|/r/ios|/r/ios/Pods", readme: "Pathname", description: "false" }); + }); + + it("is CocoaPods 1.16.2 to Gem::Version checks", () => { + const r = runShim(spec(' s.summary = (Gem::Version.new(Pod::VERSION) >= Gem::Version.new("1.13.0")).to_s', " s.description = Pod::VERSION")); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "true", description: "1.16.2" }); + }); + + it("records React Native's helpers", () => { + const r = runShim(spec( + " install_modules_dependencies(s)", + ' add_dependency(s, "React-Codegen", subspec: "x")', + " f = get_folly_config()[:compiler_flags]", + ' f << " -DMORE"', + " s.compiler_flags = get_folly_config()[:compiler_flags]", + " s.ios.deployment_target = min_ios_version_supported", + ' spm_dependency(s, url: "u", requirement: {kind: "exact"}, products: ["P"])', + )); + expect(r.status).toBe(0); + expect(r.json.dependencies).toEqual({ "React-Codegen/x": [] }); + expect(r.json.compiler_flags).toBe(FOLLY_FLAGS); + expect(r.json.platforms).toEqual({ ios: "15.1" }); + expect(r.json.__rn_xtool__.helpers).toEqual( + ["add_dependency", "get_folly_config", "install_modules_dependencies", "min_ios_version_supported", "spm_dependency"], + ); + expect(r.json.__rn_xtool__.spm_dependencies).toEqual([{ url: "u", requirement: { kind: "exact" }, products: ["P"] }]); + }); + + it("answers defined? and respond_to? as React Native's Podfile does", () => { + const r = runShim(spec( + " s.summary = defined?(install_modules_dependencies()).to_s", + ' s.description = [respond_to?(:install_modules_dependencies, true), respond_to?(:install_modules_dependencies)].join("|")', + " s.readme = defined?(use_expo_modules!).inspect", + )); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "method", description: "true|false", readme: "nil" }); + expect(r.json.__rn_xtool__.helpers).toEqual([]); + const f = runShim(`Pod::Spec.new do |s|\n s.compiler_flags = folly_flags()\nend`); + expect([f.status, f.json.error.kind]).toEqual([1, "method"]); + expect(f.json.error.message).toBe(`${f.podspec}:2: the podspec calls folly_flags(…), which rn-xtool's podspec reader does not model`); + }); + + it("answers Expo's PackagesConfig for a source build", () => { + const r = runShim(spec( + " s.summary = Expo::PackagesConfig.instance.coreFeatures.inspect", + " s.description = Expo::PackagesConfig.instance.try_link_with_prebuilt_xcframework(s).inspect", + )); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "[]", description: "false" }); + }); + + it("stubs colored2 and refuses other gems", () => { + const r = runShim(`require 'json'\nrequire 'rubygems'\nrequire 'colored2'\n${spec(' s.summary = "x".yellow')}`); + expect(r.status).toBe(0); + expect(r.json.summary).toBe("x"); + const g = runShim(`require 'json'\nrequire 'xcodeproj'\n${spec()}`); + expect([g.status, g.json.error.kind]).toEqual([1, "require"]); + expect(g.json.error.message).toBe(`${g.podspec}: cannot load such file -- xcodeproj; rn-xtool's podspec reader stubs only colored2`); + }); + + it("records the ENV names a podspec reads", () => { + const r = runShim(spec(" ENV['A']", " ENV.fetch('B', nil)", " ENV.key?('C')", " s.summary = ENV['RCT_NEW_ARCH_ENABLED']")); + expect(r.status).toBe(0); + expect(r.json.__rn_xtool__.env).toEqual(["A", "B", "C", "RCT_NEW_ARCH_ENABLED"]); + expect(r.json.summary).toBe("1"); + const more = runShim(spec(" ENV.has_key?('E')", " ENV.include?('D')", " ENV.member?('F')", " ENV.values_at('H', 'G')", " ENV['D']")); + expect(more.status).toBe(0); + expect(more.json.__rn_xtool__.env).toEqual(["D", "E", "F", "G", "H"]); + }); + + it("runs node from the installation root", () => { + const root = tempDir(); + mkdirSync(path.join(root, "node_modules", "react-native"), { recursive: true }); + writeFileSync(path.join(root, "node_modules", "react-native", "package.json"), JSON.stringify({ name: "react-native", version: "0.88.1" })); + const r = runShim(spec( + ' s.version = `cd "#{Pod::Config.instance.installation_root}" && node --print "require(\'react-native/package.json\').version"`.strip', + " s.summary = system(\"node -e 'process.exit(0)'\").to_s", + ), { root }); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ version: "0.88.1", summary: "true" }); + }); + + it("passes worklets 0.8.3's own stop on", () => { + // A project whose node_modules has no react-native; the variable is the one worklets' message asks for. + const project = tempDir(); + mkdirSync(path.join(project, "ios")); + mkdirSync(path.join(project, "node_modules")); + const r = runShim(readFileSync(path.join(WORKLETS, "RNWorklets.podspec"), "utf8"), { + files: { + "package.json": readFileSync(path.join(WORKLETS, "package.json"), "utf8"), + "scripts/worklets_utils.rb": readFileSync(path.join(WORKLETS, "scripts", "worklets_utils.rb"), "utf8"), + }, + root: path.join(project, "ios"), + env: { REACT_NATIVE_NODE_MODULES_DIR: path.join(project, "node_modules") }, + }); + expect([r.status, r.json.error.kind]).toEqual([1, "raised"]); + expect(r.json.error.message.startsWith(`${r.podspec} (scripts/worklets_utils.rb:31): [Worklets] Unable to recognize your`)).toBe(true); + }); + + it("writes UTF-8 values when LANG is C", () => { + const r = runShim(spec( + ' s.summary = JSON.parse(File.read(File.join(__dir__, "package.json")))["description"]', + ' s.description = File.read(File.join(__dir__, "package.json"))[/"description":"([^"]*)"/, 1]', + ), { + files: { "package.json": JSON.stringify({ description: "Ünïcødé ❤️" }) }, + env: { LANG: "C" }, + }); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "Ünïcødé ❤️", description: "Ünïcødé ❤️" }); + }); + + it.skipIf(NEEDS_RN !== "")(`holds the folly flags and iOS floor every supported line defines${NEEDS_RN}`, () => { + const r = runShim(spec(" s.compiler_flags = get_folly_config()[:compiler_flags]", " s.ios.deployment_target = min_ios_version_supported")); + expect(r.status).toBe(0); + for (const line of RN_LINES) { + const helpers = tool("tar", ["-xzOf", tarballPath(line)!, "package/scripts/cocoapods/helpers.rb"]); + expect(helpers.status, line).toBe(0); + expect(helpers.stdout, line).toContain(`:compiler_flags => '${r.json.compiler_flags}'`); + expect(helpers.stdout, line).toMatch(new RegExp(`def self\\.min_ios_version_supported\\s+return '${r.json.platforms.ios.replace(".", "\\.")}'`)); + } + }); + }); }); diff --git a/tests/support/ruby.ts b/tests/support/ruby.ts index 172deab..6efd1d9 100644 --- a/tests/support/ruby.ts +++ b/tests/support/ruby.ts @@ -23,6 +23,13 @@ afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); }); +/** A fresh temp folder, removed after the test file. */ +export function tempDir(): string { + const dir = mkdtempSync(path.join(tmpdir(), "rn-xtool-shim-")); + tmp.push(dir); + return dir; +} + export type ShimRun = { status: number; json: any; stdout: string; podspec: string }; /** @@ -34,8 +41,7 @@ export function runShim( body: string, opts: { files?: Record; env?: Record; root?: string } = {}, ): ShimRun { - const base = mkdtempSync(path.join(tmpdir(), "rn-xtool-shim-")); - tmp.push(base); + const base = tempDir(); const lib = path.join(base, "lib"); mkdirSync(lib); const podspec = path.join(lib, "Foo.podspec"); diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb index d4f4cf1..a85a5a8 100644 --- a/vendor/rn-spm/spm/read-podspec-shim.rb +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -20,6 +20,11 @@ exit 0 end +# A podspec's files read as UTF-8 whatever the locale (`LANG=C` would make them US-ASCII). +Encoding.default_external = Encoding::UTF_8 +# Ruby's own load path, before any gem activates: the names a podspec's `require` may load. +RN_XTOOL_LOAD_PATH = $LOAD_PATH.dup.freeze + require 'json' if ARGV == ['--probe'] @@ -27,6 +32,9 @@ exit 0 end +require 'pathname' +require 'singleton' + module Pod # A spec as CocoaPods 1.16's DSL builds it: each attribute is stored as the podspec gave it. class Specification @@ -165,20 +173,188 @@ def self._eval_podspec(string, path) end end -# The command line's run: evaluate, then write the model or the error file. +# ---- The podspec's environment ---- +# What a Podfile that requires React Native's `react_native_pods.rb` (and Expo's autolinking) gives a podspec under +# CocoaPods 1.16. Each part records what the podspec used. + +module RnXtoolShim + # What the podspec's run used, written as the model's `__rn_xtool__`. + USED = { env: [], helpers: [], ui: [], spm_dependencies: [] }.freeze + + def self.used(kind, value) + USED.fetch(kind) << value + nil + end +end + +# CocoaPods: its version, `Pod::UI` and `Pod::Config`. +module Pod + VERSION = '1.16.2' + + # What the podspec prints through CocoaPods: captured into `ui`, not printed. + module UI + def self.puts(message = '') + RnXtoolShim.used(:ui, message.to_s) + end + + def self.warn(message, _actions = [], _verbose_only = false) + RnXtoolShim.used(:ui, message.to_s) + end + + # CocoaPods runs the block under the message. + def self.info(message) + RnXtoolShim.used(:ui, message.to_s) + yield if block_given? + end + end + + # The app's `ios/` folder, from the command line's installation root; `Pods` in it need not exist. No Podfile. + class Config + class << self + attr_accessor :instance + end + + attr_reader :installation_root, :project_pods_root + alias project_root installation_root + + def initialize(installation_root) + @installation_root = Pathname.new(installation_root) + @project_pods_root = @installation_root + 'Pods' + end + end +end + +# Expo's autolinking (expo-modules-autolinking's `packages_config.rb`) as it answers for a build from sources: no core +# features, no prebuilt xcframework linked. +module Expo + class PackagesConfig + include Singleton + + attr_reader :coreFeatures + + def initialize + @coreFeatures = [] + end + + def try_link_with_prebuilt_xcframework(_spec) + false + end + end +end + +# React Native's Podfile helpers (scripts/react_native_pods.rb), with its signatures: a Podfile's `require` makes them +# private methods of Object. Each call is recorded into `helpers`; the others of that file stay undefined. +module RnXtoolShim + # React Native's `Helpers::Constants` (scripts/cocoapods/helpers.rb), the same in every supported line. + FOLLY_CONFIG = { + version: '2024.11.18.00', + git: 'https://github.com/facebook/folly.git', + compiler_flags: '-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 ' \ + '-Wno-comma -Wno-shorten-64-to-32' + }.freeze + MIN_IOS_VERSION_SUPPORTED = '15.1' +end + +class Object + private + + # Recorded only: the scaffold adds React Native's dependencies itself. + def install_modules_dependencies(spec, new_arch_enabled: true) + RnXtoolShim.used(:helpers, 'install_modules_dependencies') + end + + def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, + base_dir: 'PODS_CONFIGURATION_BUILD_DIR') + RnXtoolShim.used(:helpers, 'add_dependency') + spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) + end + + # A fresh hash per call: podspecs append to its flags. + def get_folly_config + RnXtoolShim.used(:helpers, 'get_folly_config') + RnXtoolShim::FOLLY_CONFIG.transform_values(&:dup) + end + + def min_ios_version_supported + RnXtoolShim.used(:helpers, 'min_ios_version_supported') + RnXtoolShim::MIN_IOS_VERSION_SUPPORTED.dup + end + + # Recorded with its arguments, so that the scaffold can refuse the library by name. + def spm_dependency(spec, url:, requirement:, products:) + RnXtoolShim.used(:helpers, 'spm_dependency') + RnXtoolShim.used(:spm_dependencies, { url: url, requirement: requirement, products: products }) + end +end + +# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` +# of the library's own files is Ruby's. +module RnXtoolShim + # colored2 (a gem CocoaPods brings): its String colours and effects. + COLORED2 = %w[ + black red green yellow blue magenta cyan white no_color bold dark italic underlined reversed plain normal + ].freeze + + # A `require` of a name that is neither on Ruby's own load path nor stubbed. + class Unstubbed < LoadError; end + + def self.on_load_path?(feature) + files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] + RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } + end + + # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. + def self.load_colored2 + return false if @colored2 + + COLORED2.each { |method| String.send(:define_method, method) { dup } } + @colored2 = true + end +end + +class Object + private + + def require(name) + feature = name.to_s + return RnXtoolShim.load_colored2 if feature == 'colored2' + raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) + + super + end +end + +# `ENV` as the podspec reads it: each name read is recorded into `env`. +module RnXtoolShim + module EnvReads + %i[[] fetch key? has_key? include? member?].each do |method| + define_method(method) do |name, *rest, &block| + RnXtoolShim.used(:env, name.to_s) + super(name, *rest, &block) + end + end + + def values_at(*names) + names.each { |name| RnXtoolShim.used(:env, name.to_s) } + super + end + end +end +ENV.singleton_class.prepend(RnXtoolShim::EnvReads) + +# ---- The command line's run: evaluate, then write the model or the error file ---- module RnXtoolShim module_function - # Writes the model, or the error, to `out`; whether the podspec read. - def run(podspec, out) + # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. + def run(podspec, out, root) + Pod::Config.instance = Pod::Config.new(root) spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) unless spec.is_a?(Pod::Specification) write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) return false end - write(out, spec.to_model.merge( - '__rn_xtool__' => { 'env' => [], 'helpers' => [], 'ui' => [], 'spm_dependencies' => [] } - )) + write(out, spec.to_model.merge('__rn_xtool__' => used_model)) true rescue ScriptError, StandardError, SystemExit => e kind, message = failure(e, podspec) @@ -186,6 +362,14 @@ def run(podspec, out) false end + # `env` and `helpers` sorted and unique; `ui` and `spm_dependencies` as called. + def used_model + { + 'env' => USED[:env].uniq.sort, 'helpers' => USED[:helpers].uniq.sort, 'ui' => USED[:ui], + 'spm_dependencies' => plain(USED[:spm_dependencies]) + } + end + def write(out, value) File.write(out, JSON.generate(value)) end @@ -202,6 +386,10 @@ def plain(value) # [kind, message] of an exception the podspec's run raised. def failure(error, podspec) + if error.is_a?(Unstubbed) + return ['require', "#{podspec}: #{error.message}; rn-xtool's podspec reader stubs only colored2"] + end + where = where(error, podspec) if error.is_a?(NameError) receiver = receiver_of(error) @@ -230,12 +418,12 @@ def receiver_of(error) nil end - # `Pod`, the main object, `Object` (a top-level constant) or an object of the shim's. + # `Pod`, `Expo`, the main object, `Object` (a top-level constant) or an object of the shim's. def modeled?(receiver) return true if receiver.equal?(TOPLEVEL_BINDING.receiver) || receiver.equal?(Object) namespace = Module === receiver ? receiver : receiver.class - namespace.name.to_s.split('::').first == 'Pod' + %w[Pod Expo].include?(namespace.name.to_s.split('::').first) end # How the podspec's line names the spec an unknown attribute was set on: `s`, `ss.ios`. @@ -295,4 +483,4 @@ def real(folder) end abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 -exit(RnXtoolShim.run(ARGV[0], ARGV[1]) ? 0 : 1) +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) From 47a339599bcc34eff6bdd49ec641bf3fd2a3b48e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 14:16:35 -0600 Subject: [PATCH 08/53] fix: keep the shim's ENV and require honest --- patches/react-native+0.88.0.patch | 43 ++++++++++++++++++++------ patches/react-native+0.88.1.patch | 43 ++++++++++++++++++++------ tests/podspecShim.test.ts | 19 +++++++++++- vendor/rn-spm/spm/read-podspec-shim.rb | 39 ++++++++++++++++++----- 4 files changed, 118 insertions(+), 26 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 0a34f8a..5cc80df 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -1,9 +1,9 @@ diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..a85a5a8 +index 0000000..1536aa7 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,486 @@ +@@ -0,0 +1,511 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -272,7 +272,8 @@ index 0000000..a85a5a8 + def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, + base_dir: 'PODS_CONFIGURATION_BUILD_DIR') + RnXtoolShim.used(:helpers, 'add_dependency') -+ spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) ++ # React Native's takes `subspec:` and does not pass it on. ++ spec.dependency(pod_name, *[version].compact) + end + + # A fresh hash per call: podspecs append to its flags. @@ -293,8 +294,9 @@ index 0000000..a85a5a8 + end +end + -+# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` -+# of the library's own files is Ruby's. ++# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the ++# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files ++# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. +module RnXtoolShim + # colored2 (a gem CocoaPods brings): its String colours and effects. + COLORED2 = %w[ @@ -304,11 +306,33 @@ index 0000000..a85a5a8 + # A `require` of a name that is neither on Ruby's own load path nor stubbed. + class Unstubbed < LoadError; end + -+ def self.on_load_path?(feature) ++ # A feature Ruby reads as a file's path rather than a name to look up on the load path. ++ def self.path?(feature) ++ feature.start_with?('/', './', '../', '~') ++ end ++ ++ # One of Ruby's own files: a name found on its load path, or a path inside it. ++ def self.ruby_own?(feature) ++ if path?(feature) ++ full = File.expand_path(feature) ++ return RN_XTOOL_LOAD_PATH.any? { |dir| full.start_with?("#{File.expand_path(dir)}/") } ++ end + files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] + RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } + end + ++ # Runs the block with `ENV` reads unrecorded. ++ def self.unrecorded ++ @unrecorded = (@unrecorded || 0) + 1 ++ yield ++ ensure ++ @unrecorded -= 1 ++ end ++ ++ def self.unrecorded? ++ (@unrecorded || 0).positive? ++ end ++ + # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. + def self.load_colored2 + return false if @colored2 @@ -324,7 +348,8 @@ index 0000000..a85a5a8 + def require(name) + feature = name.to_s + return RnXtoolShim.load_colored2 if feature == 'colored2' -+ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) ++ return RnXtoolShim.unrecorded { super } if RnXtoolShim.ruby_own?(feature) ++ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.path?(feature) + + super + end @@ -335,13 +360,13 @@ index 0000000..a85a5a8 + module EnvReads + %i[[] fetch key? has_key? include? member?].each do |method| + define_method(method) do |name, *rest, &block| -+ RnXtoolShim.used(:env, name.to_s) ++ RnXtoolShim.used(:env, name.to_s) unless RnXtoolShim.unrecorded? + super(name, *rest, &block) + end + end + + def values_at(*names) -+ names.each { |name| RnXtoolShim.used(:env, name.to_s) } ++ names.each { |name| RnXtoolShim.used(:env, name.to_s) } unless RnXtoolShim.unrecorded? + super + end + end diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 0a34f8a..5cc80df 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -1,9 +1,9 @@ diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..a85a5a8 +index 0000000..1536aa7 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,486 @@ +@@ -0,0 +1,511 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -272,7 +272,8 @@ index 0000000..a85a5a8 + def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, + base_dir: 'PODS_CONFIGURATION_BUILD_DIR') + RnXtoolShim.used(:helpers, 'add_dependency') -+ spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) ++ # React Native's takes `subspec:` and does not pass it on. ++ spec.dependency(pod_name, *[version].compact) + end + + # A fresh hash per call: podspecs append to its flags. @@ -293,8 +294,9 @@ index 0000000..a85a5a8 + end +end + -+# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` -+# of the library's own files is Ruby's. ++# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the ++# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files ++# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. +module RnXtoolShim + # colored2 (a gem CocoaPods brings): its String colours and effects. + COLORED2 = %w[ @@ -304,11 +306,33 @@ index 0000000..a85a5a8 + # A `require` of a name that is neither on Ruby's own load path nor stubbed. + class Unstubbed < LoadError; end + -+ def self.on_load_path?(feature) ++ # A feature Ruby reads as a file's path rather than a name to look up on the load path. ++ def self.path?(feature) ++ feature.start_with?('/', './', '../', '~') ++ end ++ ++ # One of Ruby's own files: a name found on its load path, or a path inside it. ++ def self.ruby_own?(feature) ++ if path?(feature) ++ full = File.expand_path(feature) ++ return RN_XTOOL_LOAD_PATH.any? { |dir| full.start_with?("#{File.expand_path(dir)}/") } ++ end + files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] + RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } + end + ++ # Runs the block with `ENV` reads unrecorded. ++ def self.unrecorded ++ @unrecorded = (@unrecorded || 0) + 1 ++ yield ++ ensure ++ @unrecorded -= 1 ++ end ++ ++ def self.unrecorded? ++ (@unrecorded || 0).positive? ++ end ++ + # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. + def self.load_colored2 + return false if @colored2 @@ -324,7 +348,8 @@ index 0000000..a85a5a8 + def require(name) + feature = name.to_s + return RnXtoolShim.load_colored2 if feature == 'colored2' -+ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) ++ return RnXtoolShim.unrecorded { super } if RnXtoolShim.ruby_own?(feature) ++ raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.path?(feature) + + super + end @@ -335,13 +360,13 @@ index 0000000..a85a5a8 + module EnvReads + %i[[] fetch key? has_key? include? member?].each do |method| + define_method(method) do |name, *rest, &block| -+ RnXtoolShim.used(:env, name.to_s) ++ RnXtoolShim.used(:env, name.to_s) unless RnXtoolShim.unrecorded? + super(name, *rest, &block) + end + end + + def values_at(*names) -+ names.each { |name| RnXtoolShim.used(:env, name.to_s) } ++ names.each { |name| RnXtoolShim.used(:env, name.to_s) } unless RnXtoolShim.unrecorded? + super + end + end diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index 8aa1d88..12f5f55 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -182,7 +182,8 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { ' spm_dependency(s, url: "u", requirement: {kind: "exact"}, products: ["P"])', )); expect(r.status).toBe(0); - expect(r.json.dependencies).toEqual({ "React-Codegen/x": [] }); + // React Native's add_dependency takes subspec: and drops it. + expect(r.json.dependencies).toEqual({ "React-Codegen": [] }); expect(r.json.compiler_flags).toBe(FOLLY_FLAGS); expect(r.json.platforms).toEqual({ ios: "15.1" }); expect(r.json.__rn_xtool__.helpers).toEqual( @@ -223,6 +224,22 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { expect(g.json.error.message).toBe(`${g.podspec}: cannot load such file -- xcodeproj; rn-xtool's podspec reader stubs only colored2`); }); + it("records no ENV name Ruby's own require reads", () => { + const r = runShim(`require 'fileutils'\nrequire 'set'\nrequire 'yaml'\n${spec()}`); + expect(r.status).toBe(0); + expect(r.json.__rn_xtool__.env).toEqual([]); + }); + + it("loads Ruby's own files and the library's own by path", () => { + const r = runShim(`require File.join(__dir__, 'scripts/helper')\n${spec( + " s.summary = Gem::SourceList.new.class.name", + " s.description = $helper_value", + )}`, { files: { "scripts/helper.rb": "$helper_value = \"loaded #{ENV['HELPER_X'].inspect}\"\n" } }); + expect(r.status).toBe(0); + expect(r.json).toMatchObject({ summary: "Gem::SourceList", description: "loaded nil" }); + expect(r.json.__rn_xtool__.env).toEqual(["HELPER_X"]); + }); + it("records the ENV names a podspec reads", () => { const r = runShim(spec(" ENV['A']", " ENV.fetch('B', nil)", " ENV.key?('C')", " s.summary = ENV['RCT_NEW_ARCH_ENABLED']")); expect(r.status).toBe(0); diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb index a85a5a8..1536aa7 100644 --- a/vendor/rn-spm/spm/read-podspec-shim.rb +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -266,7 +266,8 @@ def install_modules_dependencies(spec, new_arch_enabled: true) def add_dependency(spec, pod_name, subspec: nil, additional_framework_paths: [], framework_name: nil, version: nil, base_dir: 'PODS_CONFIGURATION_BUILD_DIR') RnXtoolShim.used(:helpers, 'add_dependency') - spec.dependency(subspec ? "#{pod_name}/#{subspec}" : pod_name, *[version].compact) + # React Native's takes `subspec:` and does not pass it on. + spec.dependency(pod_name, *[version].compact) end # A fresh hash per call: podspecs append to its flags. @@ -287,8 +288,9 @@ def spm_dependency(spec, url:, requirement:, products:) end end -# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, any other name fails. `require_relative` -# of the library's own files is Ruby's. +# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the +# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files +# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. module RnXtoolShim # colored2 (a gem CocoaPods brings): its String colours and effects. COLORED2 = %w[ @@ -298,11 +300,33 @@ module RnXtoolShim # A `require` of a name that is neither on Ruby's own load path nor stubbed. class Unstubbed < LoadError; end - def self.on_load_path?(feature) + # A feature Ruby reads as a file's path rather than a name to look up on the load path. + def self.path?(feature) + feature.start_with?('/', './', '../', '~') + end + + # One of Ruby's own files: a name found on its load path, or a path inside it. + def self.ruby_own?(feature) + if path?(feature) + full = File.expand_path(feature) + return RN_XTOOL_LOAD_PATH.any? { |dir| full.start_with?("#{File.expand_path(dir)}/") } + end files = File.extname(feature).empty? ? ["#{feature}.rb", "#{feature}.#{RbConfig::CONFIG['DLEXT']}"] : [feature] RN_XTOOL_LOAD_PATH.any? { |dir| files.any? { |file| File.file?(File.join(dir, file)) } } end + # Runs the block with `ENV` reads unrecorded. + def self.unrecorded + @unrecorded = (@unrecorded || 0) + 1 + yield + ensure + @unrecorded -= 1 + end + + def self.unrecorded? + (@unrecorded || 0).positive? + end + # The stub: colours and effects return the string uncoloured. False once loaded, as `require` answers. def self.load_colored2 return false if @colored2 @@ -318,7 +342,8 @@ class Object def require(name) feature = name.to_s return RnXtoolShim.load_colored2 if feature == 'colored2' - raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.on_load_path?(feature) + return RnXtoolShim.unrecorded { super } if RnXtoolShim.ruby_own?(feature) + raise RnXtoolShim::Unstubbed, "cannot load such file -- #{feature}" unless RnXtoolShim.path?(feature) super end @@ -329,13 +354,13 @@ module RnXtoolShim module EnvReads %i[[] fetch key? has_key? include? member?].each do |method| define_method(method) do |name, *rest, &block| - RnXtoolShim.used(:env, name.to_s) + RnXtoolShim.used(:env, name.to_s) unless RnXtoolShim.unrecorded? super(name, *rest, &block) end end def values_at(*names) - names.each { |name| RnXtoolShim.used(:env, name.to_s) } + names.each { |name| RnXtoolShim.used(:env, name.to_s) } unless RnXtoolShim.unrecorded? super end end From 16d6609b62dff848a509266dcb38515d8a7a5327 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 14:27:15 -0600 Subject: [PATCH 09/53] feat: pick the podspec reader and run the shim --- patches/react-native+0.88.0.patch | 339 ++++++++++++++++++++++++++--- patches/react-native+0.88.1.patch | 339 ++++++++++++++++++++++++++--- tests/podspecReader.test.ts | 257 ++++++++++++++++++++++ vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 272 +++++++++++++++++++++++ 5 files changed, 1158 insertions(+), 51 deletions(-) create mode 100644 tests/podspecReader.test.ts diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 5cc80df..a37347e 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -516,10 +516,18 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..6897fdb 100644 +index 8fcf04b..7ef3500 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js -@@ -102,13 +102,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { +@@ -29,6 +29,7 @@ + + const {spawnSync} = require('node:child_process'); + const fs = require('node:fs'); ++const os = require('node:os'); + const path = require('node:path'); + + /*:: +@@ -102,13 +103,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { maxBuffer: 8 * 1024 * 1024, // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` // (e.g. safe-area-context wraps its Fabric `common` + `fabric` @@ -539,7 +547,277 @@ index 8fcf04b..6897fdb 100644 }); } catch { cleanupPatchedPodspec(patchedPath); -@@ -170,58 +169,1412 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +@@ -166,62 +166,1682 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { + } + } + ++// --------------------------------------------------------------------------- ++// The podspec reader: Ruby or the reduced reader ++// --------------------------------------------------------------------------- ++ ++// The podspec reader runs each podspec with the system Ruby, against a shim of ++// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' ++// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, ++// the reduced reader (the evaluator below) reads it instead, and the choice ++// says why. ++ ++/*:: ++type PodspecReaderChoice = ++ | {reader: 'ruby', ruby: string, forced: false, warning: ?string} ++ | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; ++type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; ++*/ ++ ++const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); ++const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; ++const RUBY_PROBE_TIMEOUT_MS = 10000; ++const PODSPEC_TIMEOUT_MS = 30000; ++// What a read that stopped on a gap of the shim, or a podspec that did not ++// finish, says to do next. A podspec's own `raise` keeps the shim's message. ++const PODSPEC_READ_REMEDY = ++ 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + ++ 'for one run, and report it with rn-xtool doctor --report.'; ++const SHIM_GAP_KINDS = [ ++ 'method', ++ 'constant', ++ 'attribute', ++ 'require', ++ 'not-a-spec', ++]; ++ ++// One probe per `PATH` (and shim): the Ruby it finds does not change during a ++// run. ++const rubyProbes /*: Map */ = new Map(); ++ ++class PodspecReadError extends Error { ++ /*:: code: string; kind: string; */ ++ constructor(message /*: string */, kind /*: string */) { ++ super(message); ++ this.name = 'PodspecReadError'; ++ this.code = 'RN_SPM_PODSPEC_READ'; ++ this.kind = kind; ++ } ++} ++ ++// By `code` as well, so an error of another copy of this file (the vendored ++// scaffolder and the patched one) counts too. ++function isPodspecReadError(e /*: mixed */) /*: boolean */ { ++ return ( ++ e instanceof PodspecReadError || ++ (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') ++ ); ++} ++ ++// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's ++// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home ++// nor a `0` in the shell changes how a podspec reads. ++function podspecChildEnv( ++ env /*: {+[string]: ?string} */, ++) /*: {[string]: string} */ { ++ const child /*: {[string]: string} */ = {}; ++ for (const name of ['PATH', 'HOME', 'LANG']) { ++ const value = env[name]; ++ if (value != null) child[name] = value; ++ } ++ return {...child, ...RN_POD_ENV}; ++} ++ ++function nonEmptyLines(text /*: ?string */) /*: Array */ { ++ return String(text ?? '') ++ .split('\n') ++ .map(line => line.trim()) ++ .filter(line => line !== ''); ++} ++ ++// `` or `` of an ended child. ++function howRubyEnded( ++ result /*: {status: ?number, signal: ?string, ...} */, ++) /*: string */ { ++ return result.status != null ? String(result.status) : String(result.signal); ++} ++ ++function probeRuby( ++ shim /*: string */, ++ env /*: {+[string]: ?string} */, ++) /*: RubyProbe */ { ++ const result = spawnSync('ruby', [shim, '--probe'], { ++ encoding: 'utf8', ++ env: podspecChildEnv(env), ++ stdio: ['ignore', 'pipe', 'pipe'], ++ timeout: RUBY_PROBE_TIMEOUT_MS, ++ killSignal: 'SIGKILL', ++ }); ++ if (result.error != null && result.error.code === 'ENOENT') { ++ return {usable: false, why: 'Ruby was not found'}; ++ } ++ if (result.status === 0) { ++ let answer; ++ try { ++ answer = JSON.parse(result.stdout); ++ } catch { ++ answer = null; ++ } ++ if (answer?.usable === true && typeof answer.ruby === 'string') { ++ return {usable: true, ruby: answer.ruby}; ++ } ++ if (answer?.usable === false && typeof answer.why === 'string') { ++ return {usable: false, why: answer.why}; ++ } ++ } ++ const stderr = nonEmptyLines(result.stderr); ++ if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { ++ return {usable: false, why: 'ruby cannot load json'}; ++ } ++ let detail; ++ if (stderr.length > 0) { ++ detail = stderr[0]; ++ } else if (result.error != null && result.error.code === 'ETIMEDOUT') { ++ detail = `did not finish in ${RUBY_PROBE_TIMEOUT_MS / 1000} s`; ++ } else if (result.error != null) { ++ detail = result.error.message; ++ } else if (result.status === 0) { ++ detail = 'its probe printed no answer'; ++ } else { ++ detail = `exited with ${howRubyEnded(result)}`; ++ } ++ return { ++ usable: false, ++ why: `ruby could not run the podspec reader (${detail})`, ++ }; ++} ++ ++// Which reader reads the podspecs, and why when it is not Ruby. ++// RN_XTOOL_PODSPEC_READER is read on every call; the Ruby probe is memoised. ++function podspecReader( ++ opts /*: {env?: {+[string]: ?string}, shim?: string} */ = {}, ++) /*: PodspecReaderChoice */ { ++ const env = opts.env ?? process.env; ++ const shim = opts.shim ?? PODSPEC_SHIM; ++ const value = env[PODSPEC_READER_VAR]; ++ if (value === 'reduced') { ++ return { ++ reader: 'reduced', ++ why: `${PODSPEC_READER_VAR}=reduced is set`, ++ forced: true, ++ warning: null, ++ }; ++ } ++ // An empty value counts as unset. ++ const warning = ++ value != null && value !== '' ++ ? `${PODSPEC_READER_VAR}=${value} is not a reader rn-xtool knows ` + ++ '(only reduced); reading podspecs with Ruby' ++ : null; ++ if (!fs.existsSync(shim)) { ++ return { ++ reader: 'reduced', ++ why: `the podspec reader's Ruby shim is missing from ${shim}`, ++ forced: false, ++ warning, ++ }; ++ } ++ const key = `${shim}\0${env.PATH ?? ''}`; ++ let probe = rubyProbes.get(key); ++ if (probe == null) { ++ probe = probeRuby(shim, env); ++ rubyProbes.set(key, probe); ++ } ++ return probe.usable ++ ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} ++ : {reader: 'reduced', why: probe.why, forced: false, warning}; ++} ++ ++// The app's `ios/` folder, CocoaPods' installation root for the podspec: ++// RN_SPM_APP_IOS_DIR when set, else the folder that holds the first ++// `node_modules` of the podspec's path (as given, not through its links) plus ++// `ios`, else the podspec's own folder. ++function installationRootFor(podspecPath /*: string */) /*: string */ { ++ const appIosDir = process.env.RN_SPM_APP_IOS_DIR; ++ if (appIosDir != null && appIosDir !== '') return appIosDir; ++ const full = path.resolve(podspecPath); ++ const nodeModules = full.indexOf('/node_modules/'); ++ if (nodeModules >= 0) return path.join(full.slice(0, nodeModules), 'ios'); ++ return path.dirname(full); ++} ++ ++// Runs the podspec with Ruby through the shim, in the podspec's folder, with ++// an empty stdin and `podspecChildEnv`: its model, and what it printed. ++function runPodspecShim( ++ podspecPath /*: string */, ++ opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, ++) /*: {raw: RawSpec, output: string} */ { ++ const podspec = path.resolve(podspecPath); ++ const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; ++ const root = opts.installationRoot ?? installationRootFor(podspec); ++ const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); ++ const out = path.join(outDir, 'spec.json'); ++ let result; ++ let written = null; ++ try { ++ result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { ++ cwd: path.dirname(podspec), ++ encoding: 'utf8', ++ env: podspecChildEnv(process.env), ++ stdio: ['ignore', 'pipe', 'pipe'], ++ timeout: timeoutMs, ++ killSignal: 'SIGKILL', ++ maxBuffer: 8 * 1024 * 1024, ++ }); ++ if (fs.existsSync(out)) written = fs.readFileSync(out, 'utf8'); ++ } finally { ++ fs.rmSync(outDir, {recursive: true, force: true}); ++ } ++ if (result.error != null && result.error.code === 'ETIMEDOUT') { ++ throw new PodspecReadError( ++ `${podspec} did not finish in ${timeoutMs / 1000} s. ` + ++ PODSPEC_READ_REMEDY, ++ 'timeout', ++ ); ++ } ++ const stderr = nonEmptyLines(result.stderr); ++ const lastStderr = stderr.length > 0 ? `: ${stderr[stderr.length - 1]}` : ''; ++ if (written == null) { ++ const error = result.error; ++ if (error != null && result.status == null && result.signal == null) { ++ throw new PodspecReadError( ++ `${podspec}: ruby could not run (${error.message})`, ++ 'exit', ++ ); ++ } ++ throw new PodspecReadError( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ 'exit', ++ ); ++ } ++ let model; ++ try { ++ model = JSON.parse(written); ++ } catch (e) { ++ throw new PodspecReadError( ++ `${podspec}: the podspec reader wrote no JSON (${e.message})`, ++ 'exit', ++ ); ++ } ++ if (model != null && typeof model.error === 'object' && model.error != null) { ++ const kind = String(model.error.kind); ++ const message = String(model.error.message); ++ throw new PodspecReadError( ++ SHIM_GAP_KINDS.includes(kind) ++ ? `${message} ${PODSPEC_READ_REMEDY}` ++ : message, ++ kind, ++ ); ++ } ++ if (result.status !== 0) { ++ throw new PodspecReadError( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ 'exit', ++ ); ++ } ++ return {raw: model, output: result.stdout}; ++} ++ + // --------------------------------------------------------------------------- // Regex fallback // --------------------------------------------------------------------------- @@ -1980,7 +2258,7 @@ index 8fcf04b..6897fdb 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1588,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1855,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2011,7 +2289,7 @@ index 8fcf04b..6897fdb 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1620,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1887,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2054,7 +2332,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1661,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1928,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2085,7 +2363,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1694,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1961,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2102,7 +2380,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1719,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1986,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2111,7 +2389,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,15 +1730,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,15 +1997,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2167,7 +2445,7 @@ index 8fcf04b..6897fdb 100644 ); } if (/install_modules_dependencies/.test(content)) { -@@ -354,26 +1790,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -354,26 +2057,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { ); } @@ -2284,7 +2562,7 @@ index 8fcf04b..6897fdb 100644 }; } -@@ -423,6 +1936,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,6 +2203,58 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2343,7 +2621,7 @@ index 8fcf04b..6897fdb 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2003,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2270,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2361,7 +2639,7 @@ index 8fcf04b..6897fdb 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -456,7 +2029,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -456,7 +2296,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // - `default_subspecs`: array of names (or undefined → use all subspecs) const subspecs = Array.isArray(rawSpec.subspecs) ? rawSpec.subspecs : []; let selected = subspecs; @@ -2375,7 +2653,7 @@ index 8fcf04b..6897fdb 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2042,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,6 +2309,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2386,7 +2664,7 @@ index 8fcf04b..6897fdb 100644 const layers = [rawSpec, ...selected]; function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2064,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,6 +2331,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2404,7 +2682,7 @@ index 8fcf04b..6897fdb 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2137,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2404,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2425,7 +2703,7 @@ index 8fcf04b..6897fdb 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2161,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2428,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2450,7 +2728,7 @@ index 8fcf04b..6897fdb 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2194,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2461,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2471,7 +2749,7 @@ index 8fcf04b..6897fdb 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2264,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,44 +2531,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -2616,7 +2894,7 @@ index 8fcf04b..6897fdb 100644 } } return out; -@@ -677,6 +2389,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -677,6 +2656,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { ? false : true; // RN ecosystem default @@ -2637,7 +2915,7 @@ index 8fcf04b..6897fdb 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,23 +2419,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,23 +2686,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -2722,7 +3000,7 @@ index 8fcf04b..6897fdb 100644 // --------------------------------------------------------------------------- // Top-level entry // --------------------------------------------------------------------------- -@@ -722,15 +2507,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -722,15 +2774,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { * Throws when the file doesn't exist. Otherwise always returns a * PodspecModel — warnings on the model surface partial parses to the * caller, who can decide whether to proceed or abort scaffolding for that @@ -2745,7 +3023,7 @@ index 8fcf04b..6897fdb 100644 // Record whether the podspec calls `install_modules_dependencies(s)`. We // strip that helper before `pod ipc` and the regex parser can't expand it, // so the React-Core family it injects never lands in `model.dependencies`. -@@ -746,21 +2534,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { +@@ -746,21 +2801,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { return model; } @@ -2796,7 +3074,7 @@ index 8fcf04b..6897fdb 100644 podspecModels.set(key, model); return model; } -@@ -794,12 +2607,13 @@ function readPodspecNames( +@@ -794,12 +2874,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -2811,8 +3089,19 @@ index 8fcf04b..6897fdb 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -840,4 +2654,5 @@ module.exports = { +@@ -834,10 +2915,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { + + module.exports = { + findPodspecs, ++ installationRootFor, ++ isPodspecReadError, ++ PodspecReadError, ++ podspecReader, + readPodspec, + readPodspecCached, + readPodspecNames, runPodIpcSpec, ++ runPodspecShim, regexPodspec, flattenSubspecs, + unresolvedSourcesReason, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 5cc80df..a37347e 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -516,10 +516,18 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..6897fdb 100644 +index 8fcf04b..7ef3500 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js -@@ -102,13 +102,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { +@@ -29,6 +29,7 @@ + + const {spawnSync} = require('node:child_process'); + const fs = require('node:fs'); ++const os = require('node:os'); + const path = require('node:path'); + + /*:: +@@ -102,13 +103,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { maxBuffer: 8 * 1024 * 1024, // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` // (e.g. safe-area-context wraps its Fabric `common` + `fabric` @@ -539,7 +547,277 @@ index 8fcf04b..6897fdb 100644 }); } catch { cleanupPatchedPodspec(patchedPath); -@@ -170,58 +169,1412 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +@@ -166,62 +166,1682 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { + } + } + ++// --------------------------------------------------------------------------- ++// The podspec reader: Ruby or the reduced reader ++// --------------------------------------------------------------------------- ++ ++// The podspec reader runs each podspec with the system Ruby, against a shim of ++// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' ++// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, ++// the reduced reader (the evaluator below) reads it instead, and the choice ++// says why. ++ ++/*:: ++type PodspecReaderChoice = ++ | {reader: 'ruby', ruby: string, forced: false, warning: ?string} ++ | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; ++type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; ++*/ ++ ++const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); ++const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; ++const RUBY_PROBE_TIMEOUT_MS = 10000; ++const PODSPEC_TIMEOUT_MS = 30000; ++// What a read that stopped on a gap of the shim, or a podspec that did not ++// finish, says to do next. A podspec's own `raise` keeps the shim's message. ++const PODSPEC_READ_REMEDY = ++ 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + ++ 'for one run, and report it with rn-xtool doctor --report.'; ++const SHIM_GAP_KINDS = [ ++ 'method', ++ 'constant', ++ 'attribute', ++ 'require', ++ 'not-a-spec', ++]; ++ ++// One probe per `PATH` (and shim): the Ruby it finds does not change during a ++// run. ++const rubyProbes /*: Map */ = new Map(); ++ ++class PodspecReadError extends Error { ++ /*:: code: string; kind: string; */ ++ constructor(message /*: string */, kind /*: string */) { ++ super(message); ++ this.name = 'PodspecReadError'; ++ this.code = 'RN_SPM_PODSPEC_READ'; ++ this.kind = kind; ++ } ++} ++ ++// By `code` as well, so an error of another copy of this file (the vendored ++// scaffolder and the patched one) counts too. ++function isPodspecReadError(e /*: mixed */) /*: boolean */ { ++ return ( ++ e instanceof PodspecReadError || ++ (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') ++ ); ++} ++ ++// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's ++// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home ++// nor a `0` in the shell changes how a podspec reads. ++function podspecChildEnv( ++ env /*: {+[string]: ?string} */, ++) /*: {[string]: string} */ { ++ const child /*: {[string]: string} */ = {}; ++ for (const name of ['PATH', 'HOME', 'LANG']) { ++ const value = env[name]; ++ if (value != null) child[name] = value; ++ } ++ return {...child, ...RN_POD_ENV}; ++} ++ ++function nonEmptyLines(text /*: ?string */) /*: Array */ { ++ return String(text ?? '') ++ .split('\n') ++ .map(line => line.trim()) ++ .filter(line => line !== ''); ++} ++ ++// `` or `` of an ended child. ++function howRubyEnded( ++ result /*: {status: ?number, signal: ?string, ...} */, ++) /*: string */ { ++ return result.status != null ? String(result.status) : String(result.signal); ++} ++ ++function probeRuby( ++ shim /*: string */, ++ env /*: {+[string]: ?string} */, ++) /*: RubyProbe */ { ++ const result = spawnSync('ruby', [shim, '--probe'], { ++ encoding: 'utf8', ++ env: podspecChildEnv(env), ++ stdio: ['ignore', 'pipe', 'pipe'], ++ timeout: RUBY_PROBE_TIMEOUT_MS, ++ killSignal: 'SIGKILL', ++ }); ++ if (result.error != null && result.error.code === 'ENOENT') { ++ return {usable: false, why: 'Ruby was not found'}; ++ } ++ if (result.status === 0) { ++ let answer; ++ try { ++ answer = JSON.parse(result.stdout); ++ } catch { ++ answer = null; ++ } ++ if (answer?.usable === true && typeof answer.ruby === 'string') { ++ return {usable: true, ruby: answer.ruby}; ++ } ++ if (answer?.usable === false && typeof answer.why === 'string') { ++ return {usable: false, why: answer.why}; ++ } ++ } ++ const stderr = nonEmptyLines(result.stderr); ++ if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { ++ return {usable: false, why: 'ruby cannot load json'}; ++ } ++ let detail; ++ if (stderr.length > 0) { ++ detail = stderr[0]; ++ } else if (result.error != null && result.error.code === 'ETIMEDOUT') { ++ detail = `did not finish in ${RUBY_PROBE_TIMEOUT_MS / 1000} s`; ++ } else if (result.error != null) { ++ detail = result.error.message; ++ } else if (result.status === 0) { ++ detail = 'its probe printed no answer'; ++ } else { ++ detail = `exited with ${howRubyEnded(result)}`; ++ } ++ return { ++ usable: false, ++ why: `ruby could not run the podspec reader (${detail})`, ++ }; ++} ++ ++// Which reader reads the podspecs, and why when it is not Ruby. ++// RN_XTOOL_PODSPEC_READER is read on every call; the Ruby probe is memoised. ++function podspecReader( ++ opts /*: {env?: {+[string]: ?string}, shim?: string} */ = {}, ++) /*: PodspecReaderChoice */ { ++ const env = opts.env ?? process.env; ++ const shim = opts.shim ?? PODSPEC_SHIM; ++ const value = env[PODSPEC_READER_VAR]; ++ if (value === 'reduced') { ++ return { ++ reader: 'reduced', ++ why: `${PODSPEC_READER_VAR}=reduced is set`, ++ forced: true, ++ warning: null, ++ }; ++ } ++ // An empty value counts as unset. ++ const warning = ++ value != null && value !== '' ++ ? `${PODSPEC_READER_VAR}=${value} is not a reader rn-xtool knows ` + ++ '(only reduced); reading podspecs with Ruby' ++ : null; ++ if (!fs.existsSync(shim)) { ++ return { ++ reader: 'reduced', ++ why: `the podspec reader's Ruby shim is missing from ${shim}`, ++ forced: false, ++ warning, ++ }; ++ } ++ const key = `${shim}\0${env.PATH ?? ''}`; ++ let probe = rubyProbes.get(key); ++ if (probe == null) { ++ probe = probeRuby(shim, env); ++ rubyProbes.set(key, probe); ++ } ++ return probe.usable ++ ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} ++ : {reader: 'reduced', why: probe.why, forced: false, warning}; ++} ++ ++// The app's `ios/` folder, CocoaPods' installation root for the podspec: ++// RN_SPM_APP_IOS_DIR when set, else the folder that holds the first ++// `node_modules` of the podspec's path (as given, not through its links) plus ++// `ios`, else the podspec's own folder. ++function installationRootFor(podspecPath /*: string */) /*: string */ { ++ const appIosDir = process.env.RN_SPM_APP_IOS_DIR; ++ if (appIosDir != null && appIosDir !== '') return appIosDir; ++ const full = path.resolve(podspecPath); ++ const nodeModules = full.indexOf('/node_modules/'); ++ if (nodeModules >= 0) return path.join(full.slice(0, nodeModules), 'ios'); ++ return path.dirname(full); ++} ++ ++// Runs the podspec with Ruby through the shim, in the podspec's folder, with ++// an empty stdin and `podspecChildEnv`: its model, and what it printed. ++function runPodspecShim( ++ podspecPath /*: string */, ++ opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, ++) /*: {raw: RawSpec, output: string} */ { ++ const podspec = path.resolve(podspecPath); ++ const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; ++ const root = opts.installationRoot ?? installationRootFor(podspec); ++ const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); ++ const out = path.join(outDir, 'spec.json'); ++ let result; ++ let written = null; ++ try { ++ result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { ++ cwd: path.dirname(podspec), ++ encoding: 'utf8', ++ env: podspecChildEnv(process.env), ++ stdio: ['ignore', 'pipe', 'pipe'], ++ timeout: timeoutMs, ++ killSignal: 'SIGKILL', ++ maxBuffer: 8 * 1024 * 1024, ++ }); ++ if (fs.existsSync(out)) written = fs.readFileSync(out, 'utf8'); ++ } finally { ++ fs.rmSync(outDir, {recursive: true, force: true}); ++ } ++ if (result.error != null && result.error.code === 'ETIMEDOUT') { ++ throw new PodspecReadError( ++ `${podspec} did not finish in ${timeoutMs / 1000} s. ` + ++ PODSPEC_READ_REMEDY, ++ 'timeout', ++ ); ++ } ++ const stderr = nonEmptyLines(result.stderr); ++ const lastStderr = stderr.length > 0 ? `: ${stderr[stderr.length - 1]}` : ''; ++ if (written == null) { ++ const error = result.error; ++ if (error != null && result.status == null && result.signal == null) { ++ throw new PodspecReadError( ++ `${podspec}: ruby could not run (${error.message})`, ++ 'exit', ++ ); ++ } ++ throw new PodspecReadError( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ 'exit', ++ ); ++ } ++ let model; ++ try { ++ model = JSON.parse(written); ++ } catch (e) { ++ throw new PodspecReadError( ++ `${podspec}: the podspec reader wrote no JSON (${e.message})`, ++ 'exit', ++ ); ++ } ++ if (model != null && typeof model.error === 'object' && model.error != null) { ++ const kind = String(model.error.kind); ++ const message = String(model.error.message); ++ throw new PodspecReadError( ++ SHIM_GAP_KINDS.includes(kind) ++ ? `${message} ${PODSPEC_READ_REMEDY}` ++ : message, ++ kind, ++ ); ++ } ++ if (result.status !== 0) { ++ throw new PodspecReadError( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ 'exit', ++ ); ++ } ++ return {raw: model, output: result.stdout}; ++} ++ + // --------------------------------------------------------------------------- // Regex fallback // --------------------------------------------------------------------------- @@ -1980,7 +2258,7 @@ index 8fcf04b..6897fdb 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1588,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1855,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2011,7 +2289,7 @@ index 8fcf04b..6897fdb 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1620,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1887,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2054,7 +2332,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1661,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1928,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2085,7 +2363,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1694,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1961,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2102,7 +2380,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1719,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1986,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2111,7 +2389,7 @@ index 8fcf04b..6897fdb 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,15 +1730,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,15 +1997,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2167,7 +2445,7 @@ index 8fcf04b..6897fdb 100644 ); } if (/install_modules_dependencies/.test(content)) { -@@ -354,26 +1790,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -354,26 +2057,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { ); } @@ -2284,7 +2562,7 @@ index 8fcf04b..6897fdb 100644 }; } -@@ -423,6 +1936,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,6 +2203,58 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2343,7 +2621,7 @@ index 8fcf04b..6897fdb 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2003,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2270,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2361,7 +2639,7 @@ index 8fcf04b..6897fdb 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -456,7 +2029,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -456,7 +2296,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // - `default_subspecs`: array of names (or undefined → use all subspecs) const subspecs = Array.isArray(rawSpec.subspecs) ? rawSpec.subspecs : []; let selected = subspecs; @@ -2375,7 +2653,7 @@ index 8fcf04b..6897fdb 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2042,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,6 +2309,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2386,7 +2664,7 @@ index 8fcf04b..6897fdb 100644 const layers = [rawSpec, ...selected]; function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2064,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,6 +2331,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2404,7 +2682,7 @@ index 8fcf04b..6897fdb 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2137,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2404,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2425,7 +2703,7 @@ index 8fcf04b..6897fdb 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2161,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2428,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2450,7 +2728,7 @@ index 8fcf04b..6897fdb 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2194,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2461,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2471,7 +2749,7 @@ index 8fcf04b..6897fdb 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2264,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,44 +2531,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -2616,7 +2894,7 @@ index 8fcf04b..6897fdb 100644 } } return out; -@@ -677,6 +2389,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -677,6 +2656,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { ? false : true; // RN ecosystem default @@ -2637,7 +2915,7 @@ index 8fcf04b..6897fdb 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,23 +2419,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,23 +2686,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -2722,7 +3000,7 @@ index 8fcf04b..6897fdb 100644 // --------------------------------------------------------------------------- // Top-level entry // --------------------------------------------------------------------------- -@@ -722,15 +2507,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -722,15 +2774,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { * Throws when the file doesn't exist. Otherwise always returns a * PodspecModel — warnings on the model surface partial parses to the * caller, who can decide whether to proceed or abort scaffolding for that @@ -2745,7 +3023,7 @@ index 8fcf04b..6897fdb 100644 // Record whether the podspec calls `install_modules_dependencies(s)`. We // strip that helper before `pod ipc` and the regex parser can't expand it, // so the React-Core family it injects never lands in `model.dependencies`. -@@ -746,21 +2534,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { +@@ -746,21 +2801,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { return model; } @@ -2796,7 +3074,7 @@ index 8fcf04b..6897fdb 100644 podspecModels.set(key, model); return model; } -@@ -794,12 +2607,13 @@ function readPodspecNames( +@@ -794,12 +2874,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -2811,8 +3089,19 @@ index 8fcf04b..6897fdb 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -840,4 +2654,5 @@ module.exports = { +@@ -834,10 +2915,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { + + module.exports = { + findPodspecs, ++ installationRootFor, ++ isPodspecReadError, ++ PodspecReadError, ++ podspecReader, + readPodspec, + readPodspecCached, + readPodspecNames, runPodIpcSpec, ++ runPodspecShim, regexPodspec, flattenSubspecs, + unresolvedSourcesReason, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts new file mode 100644 index 0000000..6012de5 --- /dev/null +++ b/tests/podspecReader.test.ts @@ -0,0 +1,257 @@ +import { chmodSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import path from "node:path"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { VENDORED_RN_SPM } from "./support/rnScaffold.js"; +import { SHIM, needsRuby, tempDir } from "./support/ruby.js"; +import { tool } from "./support/tools.js"; + +// How the vendored scaffolder (vendor/rn-spm/spm/read-podspec.js) picks its podspec reader and runs the Ruby shim. +// The reader's choice runs fake `ruby` scripts (a temp `bin` alone on `PATH`) and needs no Ruby; the shim's runs need +// the real one. +const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); +const { podspecReader, runPodspecShim, isPodspecReadError, installationRootFor } = req("./read-podspec.js"); +const REMEDY = + "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report."; + +afterEach(() => { + vi.unstubAllEnvs(); +}); + +/** A temp `bin` folder holding a `ruby` that runs `body` with sh: a `PATH` of its own. */ +function fakeRuby(body: string): string { + const bin = path.join(tempDir(), "bin"); + mkdirSync(bin); + writeFileSync(path.join(bin, "ruby"), `#!/bin/sh\n${body}\n`); + chmodSync(path.join(bin, "ruby"), 0o755); + return bin; +} +const usableRuby = () => fakeRuby(`echo '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); + +/** `files` (paths relative to it) written into a temp library folder, and the path of its `Foo.podspec`. */ +function library(podspec: string, files: Record = {}): string { + const lib = path.join(tempDir(), "lib"); + mkdirSync(lib); + for (const [file, text] of Object.entries({ "Foo.podspec": podspec, ...files })) { + mkdirSync(path.dirname(path.join(lib, file)), { recursive: true }); + writeFileSync(path.join(lib, file), text); + } + return path.join(lib, "Foo.podspec"); +} +const spec = (...lines: string[]) => ["Pod::Spec.new do |s|", ' s.name = "Foo"', ...lines, "end"].join("\n"); + +/** The error `fn` throws. */ +function thrown(fn: () => unknown): any { + try { + fn(); + } catch (e) { + return e; + } + throw new Error("expected a throw"); +} + +/** The error message the shim itself writes for `podspec`, run as rn-xtool runs it. */ +function shimMessage(podspec: string): string { + const out = path.join(tempDir(), "out.json"); + tool("ruby", [SHIM, podspec, out, path.dirname(podspec)], { + cwd: path.dirname(podspec), + env: { PATH: process.env.PATH, RCT_NEW_ARCH_ENABLED: "1", RCT_HERMES_V1_ENABLED: "1" }, + }); + return JSON.parse(readFileSync(out, "utf8")).error.message; +} + +describe("the podspec reader's choice", () => { + it("reads with the reduced reader when Ruby is not found", () => { + const emptyBin = path.join(tempDir(), "bin"); + mkdirSync(emptyBin); + expect(podspecReader({ env: { PATH: emptyBin } })).toEqual({ reader: "reduced", why: "Ruby was not found", forced: false, warning: null }); + }); + + it("says why a Ruby is unusable", () => { + const old = fakeRuby(`echo '{"ruby":"2.5.1","floor":"2.7.0","usable":false,"why":"ruby 2.5.1 is older than 2.7.0"}'`); + expect(podspecReader({ env: { PATH: old } })).toEqual({ reader: "reduced", why: "ruby 2.5.1 is older than 2.7.0", forced: false, warning: null }); + const noJson = fakeRuby(`echo "cannot load such file -- json" >&2; exit 1`); + expect(podspecReader({ env: { PATH: noJson } })).toEqual({ reader: "reduced", why: "ruby cannot load json", forced: false, warning: null }); + const broken = fakeRuby(`echo "syntax error, unexpected" >&2; exit 1`); + expect(podspecReader({ env: { PATH: broken } })).toEqual({ + reader: "reduced", + why: "ruby could not run the podspec reader (syntax error, unexpected)", + forced: false, + warning: null, + }); + }); + + it("reads with Ruby when the probe says it is usable", () => { + expect(podspecReader({ env: { PATH: usableRuby() } })).toEqual({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }); + }); + + it("is forced to the reduced reader by RN_XTOOL_PODSPEC_READER=reduced", () => { + expect(podspecReader({ env: { PATH: usableRuby(), RN_XTOOL_PODSPEC_READER: "reduced" } })).toEqual({ + reader: "reduced", + why: "RN_XTOOL_PODSPEC_READER=reduced is set", + forced: true, + warning: null, + }); + }); + + it("names an unknown RN_XTOOL_PODSPEC_READER value", () => { + expect(podspecReader({ env: { PATH: usableRuby(), RN_XTOOL_PODSPEC_READER: "REDUCED" } })).toEqual({ + reader: "ruby", + ruby: "3.3.8", + forced: false, + warning: "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby", + }); + }); + + it("reads the variable on every call", () => { + const bin = usableRuby(); + expect(podspecReader({ env: { PATH: bin } }).reader).toBe("ruby"); + expect(podspecReader({ env: { PATH: bin, RN_XTOOL_PODSPEC_READER: "reduced" } }).reader).toBe("reduced"); + vi.stubEnv("PATH", bin); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced"); + expect(podspecReader().forced).toBe(true); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + expect(podspecReader().reader).toBe("ruby"); + }); + + it("says when the shim is missing", () => { + const none = path.join(tempDir(), "none.rb"); + expect(podspecReader({ env: { PATH: usableRuby() }, shim: none })).toEqual({ + reader: "reduced", + why: `the podspec reader's Ruby shim is missing from ${none}`, + forced: false, + warning: null, + }); + }); + + it("probes Ruby once per PATH", () => { + const counter = path.join(tempDir(), "probes"); + const bin = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); + for (let i = 0; i < 3; i++) expect(podspecReader({ env: { PATH: bin } }).reader).toBe("ruby"); + expect(readFileSync(counter, "utf8")).toBe("probe\n"); + const other = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); + podspecReader({ env: { PATH: other } }); + expect(readFileSync(counter, "utf8")).toBe("probe\nprobe\n"); + }); +}); + +describe("the podspec's installation root", () => { + it("finds the installation root", () => { + vi.stubEnv("RN_SPM_APP_IOS_DIR", "/a/ios"); + expect(installationRootFor("/p/node_modules/@s/x/X.podspec")).toBe("/a/ios"); + vi.stubEnv("RN_SPM_APP_IOS_DIR", undefined); + expect(installationRootFor("/p/node_modules/@s/x/X.podspec")).toBe("/p/ios"); + expect(installationRootFor("/p/node_modules/expo/node_modules/y/ios/Y.podspec")).toBe("/p/ios"); + expect(installationRootFor("/q/X.podspec")).toBe("/q"); + }); +}); + +describe("running the podspec shim without Ruby", () => { + it("says that ruby could not run", () => { + const podspec = library(spec()); + const emptyBin = path.join(tempDir(), "bin"); + mkdirSync(emptyBin); + vi.stubEnv("PATH", emptyBin); + const e = thrown(() => runPodspecShim(podspec)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("exit"); + expect(e.message).toBe(`${podspec}: ruby could not run (spawnSync ruby ENOENT)`); + }); +}); + +describe.skipIf(needsRuby !== "")(`running the podspec shim${needsRuby}`, () => { + it("reads a podspec with Ruby", () => { + const podspec = library(spec(' puts "hello from the podspec"', ' s.version = "1.2.3"')); + const { raw, output } = runPodspecShim(podspec); + expect(raw).toMatchObject({ name: "Foo", version: "1.2.3" }); + expect(output).toBe("hello from the podspec\n"); + }); + + it("runs the podspec with a fixed environment", () => { + vi.stubEnv("RUBYOPT", "-rnonexistent"); + vi.stubEnv("BUNDLE_GEMFILE", "/x"); + vi.stubEnv("GEM_HOME", "/y"); + vi.stubEnv("RCT_NEW_ARCH_ENABLED", "0"); + const podspec = library(spec(" s.summary = [ENV['RUBYOPT'], ENV['GEM_HOME'], ENV['RCT_NEW_ARCH_ENABLED']].inspect")); + expect(runPodspecShim(podspec).raw.summary).toBe('[nil, nil, "1"]'); + }); + + it("runs the podspec in its folder", () => { + const podspec = library(spec(' s.summary = File.read("./flags.json").strip'), { "flags.json": '{"fabric":true}\n' }); + expect(runPodspecShim(podspec).raw.summary).toBe('{"fabric":true}'); + }); + + it("gives the podspec an empty stdin", () => { + const podspec = library(spec(" s.summary = $stdin.read.to_s.length.to_s")); + const start = Date.now(); + expect(runPodspecShim(podspec).raw.summary).toBe("0"); + expect(Date.now() - start).toBeLessThan(5000); + }); + + it("stops a podspec that does not finish", () => { + const podspec = library(spec(" sleep 5")); + const e = thrown(() => runPodspecShim(podspec, { timeoutMs: 1000 })); + expect(isPodspecReadError(e)).toBe(true); + expect(e.code).toBe("RN_SPM_PODSPEC_READ"); + expect(e.kind).toBe("timeout"); + expect(e.message).toBe(`${podspec} did not finish in 1 s. ${REMEDY}`); + }); + + it("ends a shim gap with how to go on", () => { + const gap = library(spec(' s.source_files = sources_for("ios")')); + const e = thrown(() => runPodspecShim(gap)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("method"); + expect(e.message).toBe(`${shimMessage(gap)} ${REMEDY}`); + const raised = library(spec(' raise "the podspec stops here"')); + const r = thrown(() => runPodspecShim(raised)); + expect(r.kind).toBe("raised"); + expect(r.message).toBe(shimMessage(raised)); + }); + + it("says how ruby ended when the shim wrote nothing", () => { + const podspec = library(spec(" exit! 3")); + const e = thrown(() => runPodspecShim(podspec)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.message).toBe(`${podspec}: ruby exited with 3`); + }); + + it("removes its temp out folder", () => { + const [ok, raised, slow] = [library(spec()), library(spec(' raise "no"')), library(spec(" sleep 5"))]; + const tmp = tempDir(); + vi.stubEnv("TMPDIR", tmp); + runPodspecShim(ok); + thrown(() => runPodspecShim(raised)); + thrown(() => runPodspecShim(slow, { timeoutMs: 500 })); + expect(tool("ls", ["-A", tmp]).stdout).toBe(""); + }); + + it("reads a library reached through a symlink", () => { + const proj = tempDir(); + const elsewhere = path.join(tempDir(), "lib"); + mkdirSync(path.join(elsewhere, "scripts"), { recursive: true }); + writeFileSync(path.join(elsewhere, "scripts", "v.rb"), 'LIB_FROM_SCRIPTS = "from scripts/v.rb"\n'); + writeFileSync(path.join(elsewhere, "package.json"), '{"version":"4.5.6"}\n'); + writeFileSync( + path.join(elsewhere, "Lib.podspec"), + [ + 'require_relative "scripts/v"', + 'package = JSON.parse(File.read(File.join(__dir__, "package.json")))', + "Pod::Spec.new do |s|", + ' s.name = "Lib"', + ' s.version = package["version"]', + " s.summary = LIB_FROM_SCRIPTS", + " s.description = Pod::Config.instance.installation_root.to_s", + "end", + ].join("\n"), + ); + mkdirSync(path.join(proj, "node_modules")); + symlinkSync(elsewhere, path.join(proj, "node_modules", "lib")); + vi.stubEnv("RN_SPM_APP_IOS_DIR", undefined); + const podspec = path.join(proj, "node_modules", "lib", "Lib.podspec"); + expect(installationRootFor(podspec)).toBe(path.join(proj, "ios")); + const { raw } = runPodspecShim(podspec); + expect(raw).toMatchObject({ name: "Lib", version: "4.5.6", summary: "from scripts/v.rb", description: path.join(proj, "ios") }); + expect(existsSync(path.join(proj, "ios"))).toBe(false); + }); +}); diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index ba885c1..04abd97 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -161,7 +161,7 @@ resolveLocalHermesCompilerVersion, --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2536,9 +2536,15 @@ +@@ -2803,9 +2803,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 5b93d34..ab0a59c 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -29,6 +29,7 @@ const {spawnSync} = require('node:child_process'); const fs = require('node:fs'); +const os = require('node:os'); const path = require('node:path'); /*:: @@ -165,6 +166,272 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { } } +// --------------------------------------------------------------------------- +// The podspec reader: Ruby or the reduced reader +// --------------------------------------------------------------------------- + +// The podspec reader runs each podspec with the system Ruby, against a shim of +// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' +// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, +// the reduced reader (the evaluator below) reads it instead, and the choice +// says why. + +/*:: +type PodspecReaderChoice = + | {reader: 'ruby', ruby: string, forced: false, warning: ?string} + | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; +type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; +*/ + +const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); +const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; +const RUBY_PROBE_TIMEOUT_MS = 10000; +const PODSPEC_TIMEOUT_MS = 30000; +// What a read that stopped on a gap of the shim, or a podspec that did not +// finish, says to do next. A podspec's own `raise` keeps the shim's message. +const PODSPEC_READ_REMEDY = + 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + + 'for one run, and report it with rn-xtool doctor --report.'; +const SHIM_GAP_KINDS = [ + 'method', + 'constant', + 'attribute', + 'require', + 'not-a-spec', +]; + +// One probe per `PATH` (and shim): the Ruby it finds does not change during a +// run. +const rubyProbes /*: Map */ = new Map(); + +class PodspecReadError extends Error { + /*:: code: string; kind: string; */ + constructor(message /*: string */, kind /*: string */) { + super(message); + this.name = 'PodspecReadError'; + this.code = 'RN_SPM_PODSPEC_READ'; + this.kind = kind; + } +} + +// By `code` as well, so an error of another copy of this file (the vendored +// scaffolder and the patched one) counts too. +function isPodspecReadError(e /*: mixed */) /*: boolean */ { + return ( + e instanceof PodspecReadError || + (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') + ); +} + +// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's +// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home +// nor a `0` in the shell changes how a podspec reads. +function podspecChildEnv( + env /*: {+[string]: ?string} */, +) /*: {[string]: string} */ { + const child /*: {[string]: string} */ = {}; + for (const name of ['PATH', 'HOME', 'LANG']) { + const value = env[name]; + if (value != null) child[name] = value; + } + return {...child, ...RN_POD_ENV}; +} + +function nonEmptyLines(text /*: ?string */) /*: Array */ { + return String(text ?? '') + .split('\n') + .map(line => line.trim()) + .filter(line => line !== ''); +} + +// `` or `` of an ended child. +function howRubyEnded( + result /*: {status: ?number, signal: ?string, ...} */, +) /*: string */ { + return result.status != null ? String(result.status) : String(result.signal); +} + +function probeRuby( + shim /*: string */, + env /*: {+[string]: ?string} */, +) /*: RubyProbe */ { + const result = spawnSync('ruby', [shim, '--probe'], { + encoding: 'utf8', + env: podspecChildEnv(env), + stdio: ['ignore', 'pipe', 'pipe'], + timeout: RUBY_PROBE_TIMEOUT_MS, + killSignal: 'SIGKILL', + }); + if (result.error != null && result.error.code === 'ENOENT') { + return {usable: false, why: 'Ruby was not found'}; + } + if (result.status === 0) { + let answer; + try { + answer = JSON.parse(result.stdout); + } catch { + answer = null; + } + if (answer?.usable === true && typeof answer.ruby === 'string') { + return {usable: true, ruby: answer.ruby}; + } + if (answer?.usable === false && typeof answer.why === 'string') { + return {usable: false, why: answer.why}; + } + } + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; + } + let detail; + if (stderr.length > 0) { + detail = stderr[0]; + } else if (result.error != null && result.error.code === 'ETIMEDOUT') { + detail = `did not finish in ${RUBY_PROBE_TIMEOUT_MS / 1000} s`; + } else if (result.error != null) { + detail = result.error.message; + } else if (result.status === 0) { + detail = 'its probe printed no answer'; + } else { + detail = `exited with ${howRubyEnded(result)}`; + } + return { + usable: false, + why: `ruby could not run the podspec reader (${detail})`, + }; +} + +// Which reader reads the podspecs, and why when it is not Ruby. +// RN_XTOOL_PODSPEC_READER is read on every call; the Ruby probe is memoised. +function podspecReader( + opts /*: {env?: {+[string]: ?string}, shim?: string} */ = {}, +) /*: PodspecReaderChoice */ { + const env = opts.env ?? process.env; + const shim = opts.shim ?? PODSPEC_SHIM; + const value = env[PODSPEC_READER_VAR]; + if (value === 'reduced') { + return { + reader: 'reduced', + why: `${PODSPEC_READER_VAR}=reduced is set`, + forced: true, + warning: null, + }; + } + // An empty value counts as unset. + const warning = + value != null && value !== '' + ? `${PODSPEC_READER_VAR}=${value} is not a reader rn-xtool knows ` + + '(only reduced); reading podspecs with Ruby' + : null; + if (!fs.existsSync(shim)) { + return { + reader: 'reduced', + why: `the podspec reader's Ruby shim is missing from ${shim}`, + forced: false, + warning, + }; + } + const key = `${shim}\0${env.PATH ?? ''}`; + let probe = rubyProbes.get(key); + if (probe == null) { + probe = probeRuby(shim, env); + rubyProbes.set(key, probe); + } + return probe.usable + ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} + : {reader: 'reduced', why: probe.why, forced: false, warning}; +} + +// The app's `ios/` folder, CocoaPods' installation root for the podspec: +// RN_SPM_APP_IOS_DIR when set, else the folder that holds the first +// `node_modules` of the podspec's path (as given, not through its links) plus +// `ios`, else the podspec's own folder. +function installationRootFor(podspecPath /*: string */) /*: string */ { + const appIosDir = process.env.RN_SPM_APP_IOS_DIR; + if (appIosDir != null && appIosDir !== '') return appIosDir; + const full = path.resolve(podspecPath); + const nodeModules = full.indexOf('/node_modules/'); + if (nodeModules >= 0) return path.join(full.slice(0, nodeModules), 'ios'); + return path.dirname(full); +} + +// Runs the podspec with Ruby through the shim, in the podspec's folder, with +// an empty stdin and `podspecChildEnv`: its model, and what it printed. +function runPodspecShim( + podspecPath /*: string */, + opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, +) /*: {raw: RawSpec, output: string} */ { + const podspec = path.resolve(podspecPath); + const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; + const root = opts.installationRoot ?? installationRootFor(podspec); + const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); + const out = path.join(outDir, 'spec.json'); + let result; + let written = null; + try { + result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { + cwd: path.dirname(podspec), + encoding: 'utf8', + env: podspecChildEnv(process.env), + stdio: ['ignore', 'pipe', 'pipe'], + timeout: timeoutMs, + killSignal: 'SIGKILL', + maxBuffer: 8 * 1024 * 1024, + }); + if (fs.existsSync(out)) written = fs.readFileSync(out, 'utf8'); + } finally { + fs.rmSync(outDir, {recursive: true, force: true}); + } + if (result.error != null && result.error.code === 'ETIMEDOUT') { + throw new PodspecReadError( + `${podspec} did not finish in ${timeoutMs / 1000} s. ` + + PODSPEC_READ_REMEDY, + 'timeout', + ); + } + const stderr = nonEmptyLines(result.stderr); + const lastStderr = stderr.length > 0 ? `: ${stderr[stderr.length - 1]}` : ''; + if (written == null) { + const error = result.error; + if (error != null && result.status == null && result.signal == null) { + throw new PodspecReadError( + `${podspec}: ruby could not run (${error.message})`, + 'exit', + ); + } + throw new PodspecReadError( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + 'exit', + ); + } + let model; + try { + model = JSON.parse(written); + } catch (e) { + throw new PodspecReadError( + `${podspec}: the podspec reader wrote no JSON (${e.message})`, + 'exit', + ); + } + if (model != null && typeof model.error === 'object' && model.error != null) { + const kind = String(model.error.kind); + const message = String(model.error.message); + throw new PodspecReadError( + SHIM_GAP_KINDS.includes(kind) + ? `${message} ${PODSPEC_READ_REMEDY}` + : message, + kind, + ); + } + if (result.status !== 0) { + throw new PodspecReadError( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + 'exit', + ); + } + return {raw: model, output: result.stdout}; +} + // --------------------------------------------------------------------------- // Regex fallback // --------------------------------------------------------------------------- @@ -2654,10 +2921,15 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, + installationRootFor, + isPodspecReadError, + PodspecReadError, + podspecReader, readPodspec, readPodspecCached, readPodspecNames, runPodIpcSpec, + runPodspecShim, regexPodspec, flattenSubspecs, unresolvedSourcesReason, From 1b84aea9b8a2ff074f87aafa216b6e1b682650ca Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 14:52:35 -0600 Subject: [PATCH 10/53] feat: read podspecs with Ruby, drop pod ipc spec --- patches/react-native+0.88.0.patch | 540 ++++++++++++++++++++++------- patches/react-native+0.88.1.patch | 540 ++++++++++++++++++++++------- tests/podspecReader.test.ts | 130 ++++++- tests/rn-scaffolder.test.ts | 60 ++-- tests/vendor-rn-spm.test.ts | 4 +- vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 293 +++++++--------- vendor/rn-spm/spm/spm-types.js | 38 +- 8 files changed, 1160 insertions(+), 447 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index a37347e..fe7d4df 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -516,10 +516,28 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..7ef3500 100644 +index 8fcf04b..7f1df66 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js -@@ -29,6 +29,7 @@ +@@ -16,11 +16,12 @@ + * read-podspec.js — produces a flattened, SPM-friendly view of an iOS + * podspec for the scaffolder. + * +- * Strategy: prefer `pod ipc spec ` (CocoaPods evaluates the Ruby DSL, +- * including `install_modules_dependencies(s)` and `$config[:...]` +- * interpolation, so the JSON output reflects the real spec). Fall back to a +- * best-effort regex parser when CocoaPods isn't available — handles simple +- * RN libs but skips subspec blocks and Ruby helpers with a warning. ++ * Strategy: run the podspec with the system Ruby against a shim of ++ * CocoaPods' DSL and React Native's helpers (read-podspec-shim.rb), which ++ * writes the spec in CocoaPods' JSON form, so the model reflects the real ++ * spec. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, the ++ * reduced reader (a JavaScript evaluator and regex parser) reads it instead ++ * and says so. A podspec Ruby cannot read is an error, never a fallback. + * + * The output `PodspecModel` collapses the spec's default subspecs into a + * single logical target view, since that's how RN consumers compile these +@@ -29,6 +30,7 @@ const {spawnSync} = require('node:child_process'); const fs = require('node:fs'); @@ -527,34 +545,53 @@ index 8fcf04b..7ef3500 100644 const path = require('node:path'); /*:: -@@ -102,13 +103,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { - maxBuffer: 8 * 1024 * 1024, - // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` - // (e.g. safe-area-context wraps its Fabric `common` + `fabric` -- // subspecs in `if fabric_enabled`). RN 0.76+ defaults to the new -- // architecture, so unless the caller has explicitly opted out, set -- // the env var here so `pod ipc spec` evaluates the full podspec. -- env: { -- ...process.env, -- RCT_NEW_ARCH_ENABLED: process.env.RCT_NEW_ARCH_ENABLED ?? '1', -- }, -+ // subspecs in `if fabric_enabled`), and react-native-worklets gates its -+ // `-DHERMES_V1_ENABLED` flag on `RCT_HERMES_V1_ENABLED`. Give both the -+ // value React Native's CocoaPods setup gives them (`RN_POD_ENV`, which -+ // the regex fallback evaluates with too), whatever the environment -+ // says, so `pod ipc spec` reads the podspec as that setup would. -+ env: {...process.env, ...RN_POD_ENV}, - }); - } catch { - cleanupPatchedPodspec(patchedPath); -@@ -166,62 +166,1682 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { - } - } +@@ -36,192 +38,1681 @@ type RawSpec = {[string]: unknown}; + */ -+// --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- +-// Pod-IPC primary path +// The podspec reader: Ruby or the reduced reader -+// --------------------------------------------------------------------------- -+ + // --------------------------------------------------------------------------- + +-/** +- * Runs `pod ipc spec ` and parses the JSON it prints. Returns null +- * on any failure: CocoaPods missing, command threw, output not JSON, etc. +- * Callers should treat null as a signal to fall back to the regex parser. +- */ +-/** +- * Strips RN-specific Ruby helpers from a podspec source so `pod ipc spec` +- * can evaluate it without RN's Podfile-side helpers loaded. The stripped +- * helpers (`install_modules_dependencies(s)`) typically inject the React-Core +- * / React-Fabric family — all of which the scaffolder collapses into the +- * single `ReactNative` product anyway, so dropping them is safe as long as +- * the podspec also has an explicit `s.dependency "React-Core"` (almost all +- * RN libs do). Writes the patched content to a temp file and returns its +- * path; caller deletes when done. +- */ +-function patchPodspecForPodIpc(podspecPath /*: string */) /*: string */ { +- const content = fs.readFileSync(podspecPath, 'utf8'); +- // Comment out RN-Podfile-only helpers. We do NOT remove the lines so +- // line numbers in any pod ipc errors still match the original file. +- const patched = content +- .replace( +- /^(\s*)install_modules_dependencies\(([^)]*)\)/gm, +- '$1# install_modules_dependencies($2) # stripped for pod ipc', +- ) +- .replace( +- /^(\s*)use_react_native!\(([^)]*)\)/gm, +- '$1# use_react_native!($2) # stripped for pod ipc', +- ); +- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. +- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or +- // similar, expecting the package.json sibling. Keeping the patched file +- // in the same directory makes those reads continue to work. +- const depDir = path.dirname(podspecPath); +- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. +- // Use a dotfile prefix so the patched copy is invisible to normal listing +- // but the suffix CocoaPods requires is preserved. +- const tmpFile = path.join( +- depDir, +- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, +// The podspec reader runs each podspec with the system Ruby, against a shim of +// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' +// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, @@ -605,9 +642,21 @@ index 8fcf04b..7ef3500 100644 + return ( + e instanceof PodspecReadError || + (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') -+ ); -+} -+ + ); +- fs.writeFileSync(tmpFile, patched, 'utf8'); +- return tmpFile; + } + +-function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { +- // RN podspecs often call `install_modules_dependencies(s)`, a helper +- // defined by RN's Podfile-side scripts. `pod ipc spec` doesn't load +- // those, so the helper is undefined and the whole spec fails to parse. +- // Pre-process to strip those calls before invoking pod ipc. +- let patchedPath /*: ?string */ = null; +- try { +- patchedPath = patchPodspecForPodIpc(podspecPath); +- } catch { +- return null; +// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's +// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home +// nor a `0` in the shell changes how a podspec reads. @@ -701,7 +750,7 @@ index 8fcf04b..7ef3500 100644 + forced: true, + warning: null, + }; -+ } + } + // An empty value counts as unset. + const warning = + value != null && value !== '' @@ -751,29 +800,70 @@ index 8fcf04b..7ef3500 100644 + const root = opts.installationRoot ?? installationRootFor(podspec); + const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); + const out = path.join(outDir, 'spec.json'); -+ let result; + let result; + let written = null; -+ try { + try { +- result = spawnSync('pod', ['ipc', 'spec', patchedPath], { + result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { + cwd: path.dirname(podspec), -+ encoding: 'utf8', + encoding: 'utf8', +- timeout: 30000, + env: podspecChildEnv(process.env), + stdio: ['ignore', 'pipe', 'pipe'], + timeout: timeoutMs, + killSignal: 'SIGKILL', -+ maxBuffer: 8 * 1024 * 1024, -+ }); + maxBuffer: 8 * 1024 * 1024, +- // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` +- // (e.g. safe-area-context wraps its Fabric `common` + `fabric` +- // subspecs in `if fabric_enabled`). RN 0.76+ defaults to the new +- // architecture, so unless the caller has explicitly opted out, set +- // the env var here so `pod ipc spec` evaluates the full podspec. +- env: { +- ...process.env, +- RCT_NEW_ARCH_ENABLED: process.env.RCT_NEW_ARCH_ENABLED ?? '1', +- }, + }); +- } catch { +- cleanupPatchedPodspec(patchedPath); +- return null; +- } +- cleanupPatchedPodspec(patchedPath); +- if (result == null || result.error != null) { +- return null; +- } +- if (typeof result.status !== 'number' || result.status !== 0) { +- return null; + if (fs.existsSync(out)) written = fs.readFileSync(out, 'utf8'); + } finally { + fs.rmSync(outDir, {recursive: true, force: true}); -+ } + } +- if (typeof result.stdout !== 'string' || result.stdout.length === 0) { +- return null; + if (result.error != null && result.error.code === 'ETIMEDOUT') { + throw new PodspecReadError( + `${podspec} did not finish in ${timeoutMs / 1000} s. ` + + PODSPEC_READ_REMEDY, + 'timeout', + ); -+ } + } +- // Some podspecs print diagnostics to stdout during evaluation (e.g. skia: +- // `-- SK_GRAPHITE: OFF ...`) before `pod ipc` emits the JSON, and a +- // diagnostic can itself contain braces (`Building {module}`). `pod ipc` +- // pretty-prints the spec as a JSON object whose outermost braces sit at +- // column 0, so ANCHOR on a line-boundary `{`…`}` rather than the first/last +- // brace anywhere — otherwise a brace inside a diagnostic shifts the slice and +- // JSON.parse throws. When the authoritative parse is abandoned we log (not +- // silently drop to the much weaker, subspec-blind regex parser). +- const stdout = result.stdout; +- const startMatch = stdout.match(/^\{/m); +- const start = startMatch != null ? startMatch.index : -1; +- const lastLineBrace = stdout.lastIndexOf('\n}'); +- const end = +- lastLineBrace >= 0 ? lastLineBrace + 2 : stdout.lastIndexOf('}') + 1; +- if (start < 0 || end <= start) { +- console.warn( +- '[read-podspec] pod ipc spec produced no line-anchored JSON object; ' + +- 'falling back to the regex parser (subspecs/helpers may be missed).', + const stderr = nonEmptyLines(result.stderr); + const lastStderr = stderr.length > 0 ? `: ${stderr[stderr.length - 1]}` : ''; + if (written == null) { @@ -787,16 +877,21 @@ index 8fcf04b..7ef3500 100644 + throw new PodspecReadError( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + 'exit', -+ ); -+ } + ); +- return null; + } + let model; -+ try { + try { +- return JSON.parse(stdout.slice(start, end)); + model = JSON.parse(written); -+ } catch (e) { + } catch (e) { +- console.warn( +- `[read-podspec] pod ipc spec JSON parse failed (${e.message}); ` + +- 'falling back to the regex parser (subspecs/helpers may be missed).', + throw new PodspecReadError( + `${podspec}: the podspec reader wrote no JSON (${e.message})`, + 'exit', -+ ); + ); + } + if (model != null && typeof model.error === 'object' && model.error != null) { + const kind = String(model.error.kind); @@ -817,10 +912,10 @@ index 8fcf04b..7ef3500 100644 + return {raw: model, output: result.stdout}; +} + - // --------------------------------------------------------------------------- - // Regex fallback - // --------------------------------------------------------------------------- - ++// --------------------------------------------------------------------------- ++// Regex fallback ++// --------------------------------------------------------------------------- ++ +// Ruby locals and conditions. Podspecs hoist globs, extension lists and flags +// into locals and set them under conditions; react-native-screens 4.24.0: +// @@ -918,8 +1013,8 @@ index 8fcf04b..7ef3500 100644 + static keyOf(k /*: mixed */) /*: ?string */ { + if (typeof k === 'string') return `s:${k}`; + if (k instanceof RubySymbol) return `y:${k.name}`; -+ return null; -+ } + return null; + } + get(k /*: mixed */) /*: mixed */ { + const key = RubyHash.keyOf(k); + return key != null ? (this.entries.get(key)?.value ?? null) : null; @@ -940,8 +1035,10 @@ index 8fcf04b..7ef3500 100644 + return h; + } + return v; -+} -+ + } + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1161,13 +1258,19 @@ index 8fcf04b..7ef3500 100644 + if (full !== dir && !full.startsWith(dir + path.sep)) { + return new RubyUnresolved(`\`File.read\` outside the podspec's directory (${file})`); + } -+ try { + try { +- fs.unlinkSync(patchedPath); + return fs.readFileSync(full, 'utf8'); -+ } catch { + } catch { +- // best-effort cleanup; the file is named with `.spm-scaffold-...tmp` +- // so a leftover is identifiable. + return new RubyUnresolved(`\`File.read\` of a file that cannot be read (${path.relative(dir, full)})`); -+ } -+} -+ + } + } + +-// --------------------------------------------------------------------------- +-// Regex fallback +-// --------------------------------------------------------------------------- +/** + * Evaluates one Ruby expression with the locals in `env`. Returns the value, + * or a RubyUnresolved saying why it cannot. `list` reads a bare comma list @@ -2020,7 +2123,7 @@ index 8fcf04b..7ef3500 100644 + lit => (lit[0] === '"' ? lit.replace(ref, () => v) : lit), + ); +} -+ + // Comment-only lines are dropped so a commented-out `# s.header_dir` cannot win // over the live one. A trailing `#` and a `#` inside a string survive: only the // first non-whitespace character counts. @@ -2197,7 +2300,7 @@ index 8fcf04b..7ef3500 100644 + // The main spec's own statements, and each subspec block apart. The readers + // below default to the main text and receiver; a subspec is read with the + // same readers anchored on its block variable, then merged like -+ // flattenSubspecs does for `pod ipc spec` output. ++ // flattenSubspecs does for the shim's model. + const {main, subspecs: allSubspecs} = splitSubspecs(content, mainName); - // Matches: s. = "value" or s. = 'value' — at ANY scope, @@ -2258,7 +2361,7 @@ index 8fcf04b..7ef3500 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1855,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1726,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2289,7 +2392,7 @@ index 8fcf04b..7ef3500 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1887,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1758,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2332,7 +2435,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1928,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1799,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2363,7 +2466,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1961,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1832,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2380,7 +2483,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1986,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1857,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2389,14 +2492,14 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,15 +1997,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1868,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } + // Literal `'OTHER_CFLAGS' => '-DFOO=1'` and `'GCC_PREPROCESSOR_DEFINITIONS' => + // '$(inherited) BAR=1'` entries (also `[config=*Debug*]` keys), from any + // xcconfig hash. Returned as {rawKey: space-joined values} so -+ // flattenSubspecs lifts them like the `pod ipc` JSON. Only string literals ++ // flattenSubspecs lifts them like the shim's JSON. Only string literals + // are read: an array, `.join` or interpolated value is not understood (an + // interpolated token is dropped later, with the other unresolved ones). + function getDefineXcconfig( @@ -2434,18 +2537,27 @@ index 8fcf04b..7ef3500 100644 // Surface known unparseable constructs so the caller can warn the user. if (shadowedIdentity) { warnings.push( - "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.", +- "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.", ++ "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", ); } - if (/(?:s|spec)\.subspec\s+["']/.test(content)) { + if (new RegExp(`(?:${mainName})\\.subspec\\b`).test(content)) { warnings.push( - 'Subspecs detected — regex parser only extracts top-level fields. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.', -+ 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.', ++ 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.', ); } if (/install_modules_dependencies/.test(content)) { -@@ -354,26 +2057,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { + warnings.push( +- '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without CocoaPods.', ++ '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.', + ); + } + if (/\bENV\[/.test(content) || /\$config\[/.test(content)) { + warnings.push( +- 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without CocoaPods.', ++ 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.', ); } @@ -2562,7 +2674,7 @@ index 8fcf04b..7ef3500 100644 }; } -@@ -423,6 +2203,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,6 +2074,58 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2621,7 +2733,7 @@ index 8fcf04b..7ef3500 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2270,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2141,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2639,7 +2751,13 @@ index 8fcf04b..7ef3500 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -456,7 +2296,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2162,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + } + } + +- // Determine which subspecs to merge. pod ipc returns: ++ // Determine which subspecs to merge. CocoaPods' JSON form has: + // - `subspecs`: array of nested specs (or undefined) // - `default_subspecs`: array of names (or undefined → use all subspecs) const subspecs = Array.isArray(rawSpec.subspecs) ? rawSpec.subspecs : []; let selected = subspecs; @@ -2653,7 +2771,7 @@ index 8fcf04b..7ef3500 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2309,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,6 +2180,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2664,7 +2782,7 @@ index 8fcf04b..7ef3500 100644 const layers = [rawSpec, ...selected]; function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2331,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,6 +2202,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2682,7 +2800,7 @@ index 8fcf04b..7ef3500 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2404,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2275,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2703,7 +2821,7 @@ index 8fcf04b..7ef3500 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2428,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2299,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2728,7 +2846,7 @@ index 8fcf04b..7ef3500 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2461,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2332,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2749,11 +2867,11 @@ index 8fcf04b..7ef3500 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2531,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,44 +2402,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } -+ // A layer's dependency names. pod ipc returns deps as ++ // A layer's dependency names. CocoaPods' JSON form has deps as + // {name: [versionConstraint, ...], ...}, the regex reader as [name, ...]. + // A reference to a dropped subspec (`/`) is left out. + const ownName = specStringField('name'); @@ -2894,7 +3012,7 @@ index 8fcf04b..7ef3500 100644 } } return out; -@@ -677,6 +2656,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -677,6 +2527,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { ? false : true; // RN ecosystem default @@ -2915,7 +3033,7 @@ index 8fcf04b..7ef3500 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,23 +2686,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2557,239 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -2959,8 +3077,10 @@ index 8fcf04b..7ef3500 100644 + ).filter(v => !v.includes('#{')), requiresArc, warnings, ++ reader: partial ? 'reduced' : 'ruby', partial, - // Default: overridden in readPodspec, which can see the podspec source. +- // Default: overridden in readPodspec, which can see the podspec source. ++ // Default: overridden in readPodspec, which knows what the podspec called. usesInstallModulesDependencies: false, + // $FlowFixMe[incompatible-type] runtime-validated dynamic shape + unresolvedSources: Array.isArray(rawSpec.__unresolved__) @@ -2991,42 +3111,141 @@ index 8fcf04b..7ef3500 100644 + '. The podspec reader evaluates locals, string interpolation, arrays, ' + + "ENV['...'], package.json reads, comparisons, ternaries and if/unless " + + 'blocks; building from the part it could read would leave some of the ' + -+ "library's files or settings out of its target. Install CocoaPods (`gem " + -+ 'install cocoapods`) so `pod ipc spec` reads the podspec, or give the ' + -+ 'library a Package.swift of its own.' ++ "library's files or settings out of its target. Install Ruby (sudo apt " + ++ 'install ruby) so rn-xtool reads the podspec as CocoaPods does, or give ' + ++ 'the library a Package.swift of its own.' + ); +} + // --------------------------------------------------------------------------- // Top-level entry // --------------------------------------------------------------------------- -@@ -722,15 +2774,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { - * Throws when the file doesn't exist. Otherwise always returns a - * PodspecModel — warnings on the model surface partial parses to the - * caller, who can decide whether to proceed or abort scaffolding for that + + /** +- * Reads and flattens a podspec at `podspecPath`. Tries `pod ipc spec` first +- * (full Ruby DSL evaluation); falls back to a regex parser when CocoaPods +- * isn't available. ++ * Reads and flattens a podspec at `podspecPath` with the reader ++ * `podspecReader()` picks: Ruby through the shim, or the reduced reader. A ++ * podspec Ruby cannot read throws a PodspecReadError; nothing falls back. ++ * `name`, `module_name` and `version` are the reduced reader's literal ++ * readings under both readers (IDENTITY_FIELDS): evaluating `s.name = ++ * package['name']` would rename the scaffolded target. + * +- * Throws when the file doesn't exist. Otherwise always returns a +- * PodspecModel — warnings on the model surface partial parses to the +- * caller, who can decide whether to proceed or abort scaffolding for that - * dep. -+ * dep. The subspecs named in `opts.dropSubspecs` are left out. ++ * Throws when the file doesn't exist. Warnings on the model surface partial ++ * reads to the caller, who can decide whether to proceed or abort scaffolding ++ * for that dep. The subspecs named in `opts.dropSubspecs` are left out. Each ++ * read is appended to RN_SPM_PODSPEC_READS when it is set. */ -function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { +function readPodspec( + podspecPath /*: string */, + opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, ++) /*: PodspecModel */ { ++ return readPodspecWith(podspecReader(), podspecPath, opts); ++} ++ ++function readPodspecWith( ++ choice /*: PodspecReaderChoice */, ++ podspecPath /*: string */, ++ opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, +) /*: PodspecModel */ { if (!fs.existsSync(podspecPath)) { throw new Error(`readPodspec: file does not exist: ${podspecPath}`); } - const podIpc = runPodIpcSpec(podspecPath); +- const podIpc = runPodIpcSpec(podspecPath); - const raw = podIpc != null ? podIpc : regexPodspec(podspecPath); - const model = flattenSubspecs(raw); -+ const raw = podIpc != null ? podIpc : regexPodspec(podspecPath, opts); -+ const model = flattenSubspecs(raw, opts); - // Record whether the podspec calls `install_modules_dependencies(s)`. We - // strip that helper before `pod ipc` and the regex parser can't expand it, - // so the React-Core family it injects never lands in `model.dependencies`. -@@ -746,21 +2801,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { - return model; - } - +- // Record whether the podspec calls `install_modules_dependencies(s)`. We +- // strip that helper before `pod ipc` and the regex parser can't expand it, +- // so the React-Core family it injects never lands in `model.dependencies`. +- // The scaffolder uses this as an implicit React-core marker (plain ObjC +- // modules using the helper have no `codegenConfig` to detect instead). ++ let used /*: {env: Array, helpers: Array} */ = { ++ env: [], ++ helpers: [], ++ }; + try { +- const src = fs.readFileSync(podspecPath, 'utf8'); ++ let shimRaw = null; ++ if (choice.reader === 'ruby') { ++ shimRaw = runPodspecShim(podspecPath).raw; ++ // $FlowFixMe[prop-missing] the shim's dynamic shape ++ const rnXtool = shimRaw.__rn_xtool__; ++ used = { ++ env: Array.isArray(rnXtool?.env) ? rnXtool.env : [], ++ helpers: Array.isArray(rnXtool?.helpers) ? rnXtool.helpers : [], ++ }; ++ } ++ const literal = regexPodspec(podspecPath, opts); ++ const model = flattenSubspecs(shimRaw ?? literal, opts); ++ // Whether the podspec calls `install_modules_dependencies(s)`, which ++ // injects the React-Core family under CocoaPods: the scaffolder uses this ++ // as an implicit React-core marker (plain ObjC modules using the helper ++ // have no `codegenConfig` to detect instead). Ruby knows whether the run ++ // called it; the reduced reader marks every podspec whose source names it. + model.usesInstallModulesDependencies = +- /\binstall_modules_dependencies\b/.test(src); ++ shimRaw != null ++ ? used.helpers.includes('install_modules_dependencies') ++ : /\binstall_modules_dependencies\b/.test( ++ fs.readFileSync(podspecPath, 'utf8'), ++ ); ++ // IDENTITY_FIELDS: the literal readings, under both readers. ++ const identity = (key /*: string */) /*: ?string */ => { ++ // $FlowFixMe[prop-missing] RawSpec is dynamically shaped ++ const value = literal[key]; ++ return typeof value === 'string' && value.length > 0 ? value : null; ++ }; ++ model.name = identity('name') ?? ''; ++ model.moduleName = identity('module_name'); ++ model.version = identity('version') ?? ''; ++ recordPodspecRead(podspecPath, choice, used, null); ++ return model; ++ } catch (e) { ++ recordPodspecRead(podspecPath, choice, used, e); ++ throw e; ++ } ++} ++ ++// One JSON line per read in RN_SPM_PODSPEC_READS, when it is set: the ++// podspec, its reader and why, what the podspec used of its environment, and ++// whether it read. A line that cannot be written does not stop the read. ++function recordPodspecRead( ++ podspecPath /*: string */, ++ choice /*: PodspecReaderChoice */, ++ used /*: {env: Array, helpers: Array} */, ++ error /*: mixed */, ++) /*: void */ { ++ const file = process.env.RN_SPM_PODSPEC_READS; ++ if (file == null || file === '') return; ++ const line /*: {[string]: mixed} */ = { ++ podspec: path.resolve(podspecPath), ++ reader: choice.reader, ++ }; ++ if (choice.reader === 'reduced') line.why = choice.why; ++ line.forced = choice.forced; ++ if (choice.reader === 'ruby') line.ruby = choice.ruby; ++ if (choice.warning != null) line.warning = choice.warning; ++ line.env = used.env; ++ line.helpers = used.helpers; ++ line.ok = error == null; ++ if (error != null) { ++ line.error = error instanceof Error ? error.message : String(error); ++ } ++ try { ++ fs.appendFileSync(file, `${JSON.stringify(line)}\n`); + } catch { +- // best-effort; leave the flattenSubspecs default (false) ++ // the read itself stands + } +- return model; ++} ++ +// The installed React Native's version as the macros libraries derive from it. +function readRnVersionMacros() /*: {[string]: number} */ { + try { @@ -3045,17 +3264,18 @@ index 8fcf04b..7ef3500 100644 + // unreadable: the defines stay dropped + } + return {}; -+} -+ + } + const podspecModels /*: Map */ = new Map(); /** - * readPodspec memoized on the resolved path. `pod ipc spec` costs a process +- * readPodspec memoized on the resolved path. `pod ipc spec` costs a process ++ * readPodspec memoized on the resolved path. A Ruby read costs a process * spawn, and one autolinking run reads the same podspec from several sites * (name resolution, header search paths, scaffolding). The model is shared, so - * callers must treat it as read-only. -+ * callers must treat it as read-only. The key is the resolved path plus the -+ * sorted `opts.dropSubspecs`. ++ * callers must treat it as read-only. The key is the resolved path, the ++ * sorted `opts.dropSubspecs` and the reader. */ -function readPodspecCached(podspecPath /*: string */) /*: PodspecModel */ { - const key = path.resolve(podspecPath); @@ -3064,17 +3284,25 @@ index 8fcf04b..7ef3500 100644 + opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, +) /*: PodspecModel */ { + const drop = [...(opts?.dropSubspecs ?? [])].sort(); -+ const key = [path.resolve(podspecPath), ...drop].join('\0'); ++ const choice = podspecReader(); ++ const key = [path.resolve(podspecPath), choice.reader, ...drop].join('\0'); const cached = podspecModels.get(key); if (cached != null) { return cached; } - const model = readPodspec(podspecPath); -+ const model = readPodspec(podspecPath, {dropSubspecs: drop}); ++ const model = readPodspecWith(choice, podspecPath, {dropSubspecs: drop}); podspecModels.set(key, model); return model; } -@@ -794,12 +2874,13 @@ function readPodspecNames( + + /** +- * The three fields that name a library, read WITHOUT `pod ipc spec`'s process ++ * The three fields that name a library, read WITHOUT Ruby's process + * spawn — name resolution runs for every dep, including self-managed ones that + * need nothing else from the podspec. + * +@@ -794,12 +2817,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3089,7 +3317,19 @@ index 8fcf04b..7ef3500 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -834,10 +2915,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -817,8 +2841,9 @@ function readPodspecNames( + + /** + * Every podspec in `dir`, sorted so two of them name a target the same way on +- * every machine (readdir order is unspecified). Skips a crashed run's leftover +- * `.spm-scaffold--.podspec` copy. ++ * every machine (readdir order is unspecified). Skips the ++ * `.spm-scaffold--.podspec` copy a crashed run of an older rn-xtool ++ * (which read podspecs with `pod ipc spec`) left. + */ + function findPodspecs(dir /*: string */) /*: Array */ { + try { +@@ -834,10 +2859,15 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, @@ -3100,7 +3340,7 @@ index 8fcf04b..7ef3500 100644 readPodspec, readPodspecCached, readPodspecNames, - runPodIpcSpec, +- runPodIpcSpec, + runPodspecShim, regexPodspec, flattenSubspecs, @@ -5007,12 +5247,71 @@ index cf7e587..f105e49 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..6ce647d 100644 +index a89142f..b9ed2bc 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js -@@ -471,6 +471,10 @@ export type PodspecModel = { - // flag as an implicit React-core dependency (a plain ObjC module using the - // helper has no `codegenConfig` to key off). +@@ -411,8 +411,8 @@ export type PreprocessorDefine = { + // Scaffold types — for the `npx react-native spm scaffold` command that + // generates a `Package.swift` into `node_modules//` for community RN + // libraries that don't ship SPM support. Inputs come from the dep's podspec +-// (read via `pod ipc spec --format=json` when CocoaPods is available, or a +-// regex fallback). The output Package.swift is treated as "self-managed" by ++// (read with Ruby through read-podspec-shim.rb when it is usable, or the ++// reduced reader). The output Package.swift is treated as "self-managed" by + // the autolinker — see isSelfManagedPackage in generate-spm-autolinking.js. + // --------------------------------------------------------------------------- + +@@ -440,9 +440,11 @@ export type PodspecModel = { + frameworks: Array, + weakFrameworks: Array, + libraries: Array, +- // Merged dependency name list. With pod-ipc, includes the deps materialized +- // by `install_modules_dependencies(s)` (React-Core, React-Fabric, ...). +- // Version constraints stripped — we only need the name to bucket. ++ // Merged dependency name list. Never includes the React-Core family that ++ // `install_modules_dependencies(s)` injects under CocoaPods: the shim only ++ // records the call (see usesInstallModulesDependencies), and the reduced ++ // reader cannot expand it. Version constraints stripped — we only need the ++ // name to bucket. + dependencies: Array, + compilerFlags: Array, + // Raw header-search-path entries from `pod_target_xcconfig['HEADER_SEARCH_PATHS']`. +@@ -450,7 +452,7 @@ export type PodspecModel = { + headerSearchPaths: Array, + // Preprocessor defines lifted from pod_target_xcconfig OTHER_CFLAGS (`-D` + // tokens) + GCC_PREPROCESSOR_DEFINITIONS (incl. per-config variants). Already +- // resolved by `pod ipc` (e.g. `-DWORKLETS_VERSION=#{package['version']}` → ++ // resolved by the reader (e.g. `-DWORKLETS_VERSION=#{package['version']}` → + // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. + preprocessorDefines: Array, + // File paths or glob patterns the dep declares as bundled resources. +@@ -460,17 +462,25 @@ export type PodspecModel = { + // a user can spot fields that didn't translate cleanly (unknown env vars, + // unrecognized $(...) tokens, etc.). Never throws on parse errors. + warnings: Array, +- // True when produced by the regex fallback rather than pod-ipc. Used to +- // emit a louder banner in the scaffold summary explaining that dependency +- // wiring may be incomplete. ++ // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the ++ // reduced reader (podspecReader in read-podspec.js says why). ++ reader: 'ruby' | 'reduced', ++ // True when produced by the reduced reader rather than Ruby. Used to emit a ++ // louder banner in the scaffold summary explaining that dependency wiring ++ // may be incomplete. + partial: boolean, +- // True when the podspec source calls `install_modules_dependencies(s)` — +- // RN's Podfile-side helper that injects the React-Core family. We strip that +- // helper before evaluating the spec (and the regex parser can't expand it), +- // so React-Core never surfaces in `dependencies`. The scaffolder treats this +- // flag as an implicit React-core dependency (a plain ObjC module using the +- // helper has no `codegenConfig` to key off). ++ // True when the podspec calls `install_modules_dependencies(s)` — RN's ++ // Podfile-side helper that injects the React-Core family. With Ruby, when ++ // the run called it (the shim records the call and adds nothing); with the ++ // reduced reader, when the source names it. React-Core never surfaces in ++ // `dependencies`, so the scaffolder treats this flag as an implicit ++ // React-core dependency (a plain ObjC module using the helper has no ++ // `codegenConfig` to key off). usesInstallModulesDependencies: boolean, + // The `source_files`/`exclude_files` values the regex fallback could not + // evaluate (a method call, an unknown local): the scaffolder refuses the @@ -5021,7 +5320,16 @@ index a89142f..6ce647d 100644 }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -502,6 +506,9 @@ export type SpmScaffoldSpec = { +@@ -485,7 +495,7 @@ export type SpmScaffoldSpec = { + // Header search paths resolved to dep-root-relative form. Each entry + // becomes `.headerSearchPath("")` in cSettings + cxxSettings. + headerSearchPaths: Array, +- // Preprocessor defines (resolved by pod ipc) — emitted as `.define(...)` in ++ // Preprocessor defines (resolved by the reader) — emitted as `.define(...)` in + // cSettings + cxxSettings, honoring any per-config scope. + preprocessorDefines: Array, + // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + +@@ -502,6 +512,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5031,7 +5339,7 @@ index a89142f..6ce647d 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +546,9 @@ export type ScaffoldResult = +@@ -539,6 +552,9 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index a37347e..fe7d4df 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -516,10 +516,28 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..7ef3500 100644 +index 8fcf04b..7f1df66 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js -@@ -29,6 +29,7 @@ +@@ -16,11 +16,12 @@ + * read-podspec.js — produces a flattened, SPM-friendly view of an iOS + * podspec for the scaffolder. + * +- * Strategy: prefer `pod ipc spec ` (CocoaPods evaluates the Ruby DSL, +- * including `install_modules_dependencies(s)` and `$config[:...]` +- * interpolation, so the JSON output reflects the real spec). Fall back to a +- * best-effort regex parser when CocoaPods isn't available — handles simple +- * RN libs but skips subspec blocks and Ruby helpers with a warning. ++ * Strategy: run the podspec with the system Ruby against a shim of ++ * CocoaPods' DSL and React Native's helpers (read-podspec-shim.rb), which ++ * writes the spec in CocoaPods' JSON form, so the model reflects the real ++ * spec. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, the ++ * reduced reader (a JavaScript evaluator and regex parser) reads it instead ++ * and says so. A podspec Ruby cannot read is an error, never a fallback. + * + * The output `PodspecModel` collapses the spec's default subspecs into a + * single logical target view, since that's how RN consumers compile these +@@ -29,6 +30,7 @@ const {spawnSync} = require('node:child_process'); const fs = require('node:fs'); @@ -527,34 +545,53 @@ index 8fcf04b..7ef3500 100644 const path = require('node:path'); /*:: -@@ -102,13 +103,12 @@ function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { - maxBuffer: 8 * 1024 * 1024, - // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` - // (e.g. safe-area-context wraps its Fabric `common` + `fabric` -- // subspecs in `if fabric_enabled`). RN 0.76+ defaults to the new -- // architecture, so unless the caller has explicitly opted out, set -- // the env var here so `pod ipc spec` evaluates the full podspec. -- env: { -- ...process.env, -- RCT_NEW_ARCH_ENABLED: process.env.RCT_NEW_ARCH_ENABLED ?? '1', -- }, -+ // subspecs in `if fabric_enabled`), and react-native-worklets gates its -+ // `-DHERMES_V1_ENABLED` flag on `RCT_HERMES_V1_ENABLED`. Give both the -+ // value React Native's CocoaPods setup gives them (`RN_POD_ENV`, which -+ // the regex fallback evaluates with too), whatever the environment -+ // says, so `pod ipc spec` reads the podspec as that setup would. -+ env: {...process.env, ...RN_POD_ENV}, - }); - } catch { - cleanupPatchedPodspec(patchedPath); -@@ -166,62 +166,1682 @@ function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { - } - } +@@ -36,192 +38,1681 @@ type RawSpec = {[string]: unknown}; + */ -+// --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- +-// Pod-IPC primary path +// The podspec reader: Ruby or the reduced reader -+// --------------------------------------------------------------------------- -+ + // --------------------------------------------------------------------------- + +-/** +- * Runs `pod ipc spec ` and parses the JSON it prints. Returns null +- * on any failure: CocoaPods missing, command threw, output not JSON, etc. +- * Callers should treat null as a signal to fall back to the regex parser. +- */ +-/** +- * Strips RN-specific Ruby helpers from a podspec source so `pod ipc spec` +- * can evaluate it without RN's Podfile-side helpers loaded. The stripped +- * helpers (`install_modules_dependencies(s)`) typically inject the React-Core +- * / React-Fabric family — all of which the scaffolder collapses into the +- * single `ReactNative` product anyway, so dropping them is safe as long as +- * the podspec also has an explicit `s.dependency "React-Core"` (almost all +- * RN libs do). Writes the patched content to a temp file and returns its +- * path; caller deletes when done. +- */ +-function patchPodspecForPodIpc(podspecPath /*: string */) /*: string */ { +- const content = fs.readFileSync(podspecPath, 'utf8'); +- // Comment out RN-Podfile-only helpers. We do NOT remove the lines so +- // line numbers in any pod ipc errors still match the original file. +- const patched = content +- .replace( +- /^(\s*)install_modules_dependencies\(([^)]*)\)/gm, +- '$1# install_modules_dependencies($2) # stripped for pod ipc', +- ) +- .replace( +- /^(\s*)use_react_native!\(([^)]*)\)/gm, +- '$1# use_react_native!($2) # stripped for pod ipc', +- ); +- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. +- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or +- // similar, expecting the package.json sibling. Keeping the patched file +- // in the same directory makes those reads continue to work. +- const depDir = path.dirname(podspecPath); +- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. +- // Use a dotfile prefix so the patched copy is invisible to normal listing +- // but the suffix CocoaPods requires is preserved. +- const tmpFile = path.join( +- depDir, +- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, +// The podspec reader runs each podspec with the system Ruby, against a shim of +// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' +// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, @@ -605,9 +642,21 @@ index 8fcf04b..7ef3500 100644 + return ( + e instanceof PodspecReadError || + (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') -+ ); -+} -+ + ); +- fs.writeFileSync(tmpFile, patched, 'utf8'); +- return tmpFile; + } + +-function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { +- // RN podspecs often call `install_modules_dependencies(s)`, a helper +- // defined by RN's Podfile-side scripts. `pod ipc spec` doesn't load +- // those, so the helper is undefined and the whole spec fails to parse. +- // Pre-process to strip those calls before invoking pod ipc. +- let patchedPath /*: ?string */ = null; +- try { +- patchedPath = patchPodspecForPodIpc(podspecPath); +- } catch { +- return null; +// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's +// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home +// nor a `0` in the shell changes how a podspec reads. @@ -701,7 +750,7 @@ index 8fcf04b..7ef3500 100644 + forced: true, + warning: null, + }; -+ } + } + // An empty value counts as unset. + const warning = + value != null && value !== '' @@ -751,29 +800,70 @@ index 8fcf04b..7ef3500 100644 + const root = opts.installationRoot ?? installationRootFor(podspec); + const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); + const out = path.join(outDir, 'spec.json'); -+ let result; + let result; + let written = null; -+ try { + try { +- result = spawnSync('pod', ['ipc', 'spec', patchedPath], { + result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { + cwd: path.dirname(podspec), -+ encoding: 'utf8', + encoding: 'utf8', +- timeout: 30000, + env: podspecChildEnv(process.env), + stdio: ['ignore', 'pipe', 'pipe'], + timeout: timeoutMs, + killSignal: 'SIGKILL', -+ maxBuffer: 8 * 1024 * 1024, -+ }); + maxBuffer: 8 * 1024 * 1024, +- // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` +- // (e.g. safe-area-context wraps its Fabric `common` + `fabric` +- // subspecs in `if fabric_enabled`). RN 0.76+ defaults to the new +- // architecture, so unless the caller has explicitly opted out, set +- // the env var here so `pod ipc spec` evaluates the full podspec. +- env: { +- ...process.env, +- RCT_NEW_ARCH_ENABLED: process.env.RCT_NEW_ARCH_ENABLED ?? '1', +- }, + }); +- } catch { +- cleanupPatchedPodspec(patchedPath); +- return null; +- } +- cleanupPatchedPodspec(patchedPath); +- if (result == null || result.error != null) { +- return null; +- } +- if (typeof result.status !== 'number' || result.status !== 0) { +- return null; + if (fs.existsSync(out)) written = fs.readFileSync(out, 'utf8'); + } finally { + fs.rmSync(outDir, {recursive: true, force: true}); -+ } + } +- if (typeof result.stdout !== 'string' || result.stdout.length === 0) { +- return null; + if (result.error != null && result.error.code === 'ETIMEDOUT') { + throw new PodspecReadError( + `${podspec} did not finish in ${timeoutMs / 1000} s. ` + + PODSPEC_READ_REMEDY, + 'timeout', + ); -+ } + } +- // Some podspecs print diagnostics to stdout during evaluation (e.g. skia: +- // `-- SK_GRAPHITE: OFF ...`) before `pod ipc` emits the JSON, and a +- // diagnostic can itself contain braces (`Building {module}`). `pod ipc` +- // pretty-prints the spec as a JSON object whose outermost braces sit at +- // column 0, so ANCHOR on a line-boundary `{`…`}` rather than the first/last +- // brace anywhere — otherwise a brace inside a diagnostic shifts the slice and +- // JSON.parse throws. When the authoritative parse is abandoned we log (not +- // silently drop to the much weaker, subspec-blind regex parser). +- const stdout = result.stdout; +- const startMatch = stdout.match(/^\{/m); +- const start = startMatch != null ? startMatch.index : -1; +- const lastLineBrace = stdout.lastIndexOf('\n}'); +- const end = +- lastLineBrace >= 0 ? lastLineBrace + 2 : stdout.lastIndexOf('}') + 1; +- if (start < 0 || end <= start) { +- console.warn( +- '[read-podspec] pod ipc spec produced no line-anchored JSON object; ' + +- 'falling back to the regex parser (subspecs/helpers may be missed).', + const stderr = nonEmptyLines(result.stderr); + const lastStderr = stderr.length > 0 ? `: ${stderr[stderr.length - 1]}` : ''; + if (written == null) { @@ -787,16 +877,21 @@ index 8fcf04b..7ef3500 100644 + throw new PodspecReadError( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + 'exit', -+ ); -+ } + ); +- return null; + } + let model; -+ try { + try { +- return JSON.parse(stdout.slice(start, end)); + model = JSON.parse(written); -+ } catch (e) { + } catch (e) { +- console.warn( +- `[read-podspec] pod ipc spec JSON parse failed (${e.message}); ` + +- 'falling back to the regex parser (subspecs/helpers may be missed).', + throw new PodspecReadError( + `${podspec}: the podspec reader wrote no JSON (${e.message})`, + 'exit', -+ ); + ); + } + if (model != null && typeof model.error === 'object' && model.error != null) { + const kind = String(model.error.kind); @@ -817,10 +912,10 @@ index 8fcf04b..7ef3500 100644 + return {raw: model, output: result.stdout}; +} + - // --------------------------------------------------------------------------- - // Regex fallback - // --------------------------------------------------------------------------- - ++// --------------------------------------------------------------------------- ++// Regex fallback ++// --------------------------------------------------------------------------- ++ +// Ruby locals and conditions. Podspecs hoist globs, extension lists and flags +// into locals and set them under conditions; react-native-screens 4.24.0: +// @@ -918,8 +1013,8 @@ index 8fcf04b..7ef3500 100644 + static keyOf(k /*: mixed */) /*: ?string */ { + if (typeof k === 'string') return `s:${k}`; + if (k instanceof RubySymbol) return `y:${k.name}`; -+ return null; -+ } + return null; + } + get(k /*: mixed */) /*: mixed */ { + const key = RubyHash.keyOf(k); + return key != null ? (this.entries.get(key)?.value ?? null) : null; @@ -940,8 +1035,10 @@ index 8fcf04b..7ef3500 100644 + return h; + } + return v; -+} -+ + } + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1161,13 +1258,19 @@ index 8fcf04b..7ef3500 100644 + if (full !== dir && !full.startsWith(dir + path.sep)) { + return new RubyUnresolved(`\`File.read\` outside the podspec's directory (${file})`); + } -+ try { + try { +- fs.unlinkSync(patchedPath); + return fs.readFileSync(full, 'utf8'); -+ } catch { + } catch { +- // best-effort cleanup; the file is named with `.spm-scaffold-...tmp` +- // so a leftover is identifiable. + return new RubyUnresolved(`\`File.read\` of a file that cannot be read (${path.relative(dir, full)})`); -+ } -+} -+ + } + } + +-// --------------------------------------------------------------------------- +-// Regex fallback +-// --------------------------------------------------------------------------- +/** + * Evaluates one Ruby expression with the locals in `env`. Returns the value, + * or a RubyUnresolved saying why it cannot. `list` reads a bare comma list @@ -2020,7 +2123,7 @@ index 8fcf04b..7ef3500 100644 + lit => (lit[0] === '"' ? lit.replace(ref, () => v) : lit), + ); +} -+ + // Comment-only lines are dropped so a commented-out `# s.header_dir` cannot win // over the live one. A trailing `#` and a `#` inside a string survive: only the // first non-whitespace character counts. @@ -2197,7 +2300,7 @@ index 8fcf04b..7ef3500 100644 + // The main spec's own statements, and each subspec block apart. The readers + // below default to the main text and receiver; a subspec is read with the + // same readers anchored on its block variable, then merged like -+ // flattenSubspecs does for `pod ipc spec` output. ++ // flattenSubspecs does for the shim's model. + const {main, subspecs: allSubspecs} = splitSubspecs(content, mainName); - // Matches: s. = "value" or s. = 'value' — at ANY scope, @@ -2258,7 +2361,7 @@ index 8fcf04b..7ef3500 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1855,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1726,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2289,7 +2392,7 @@ index 8fcf04b..7ef3500 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1887,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1758,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2332,7 +2435,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1928,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1799,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2363,7 +2466,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1961,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1832,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2380,7 +2483,7 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1986,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1857,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2389,14 +2492,14 @@ index 8fcf04b..7ef3500 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,15 +1997,53 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1868,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } + // Literal `'OTHER_CFLAGS' => '-DFOO=1'` and `'GCC_PREPROCESSOR_DEFINITIONS' => + // '$(inherited) BAR=1'` entries (also `[config=*Debug*]` keys), from any + // xcconfig hash. Returned as {rawKey: space-joined values} so -+ // flattenSubspecs lifts them like the `pod ipc` JSON. Only string literals ++ // flattenSubspecs lifts them like the shim's JSON. Only string literals + // are read: an array, `.join` or interpolated value is not understood (an + // interpolated token is dropped later, with the other unresolved ones). + function getDefineXcconfig( @@ -2434,18 +2537,27 @@ index 8fcf04b..7ef3500 100644 // Surface known unparseable constructs so the caller can warn the user. if (shadowedIdentity) { warnings.push( - "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.", +- "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.", ++ "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", ); } - if (/(?:s|spec)\.subspec\s+["']/.test(content)) { + if (new RegExp(`(?:${mainName})\\.subspec\\b`).test(content)) { warnings.push( - 'Subspecs detected — regex parser only extracts top-level fields. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.', -+ 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.', ++ 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.', ); } if (/install_modules_dependencies/.test(content)) { -@@ -354,26 +2057,103 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { + warnings.push( +- '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without CocoaPods.', ++ '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.', + ); + } + if (/\bENV\[/.test(content) || /\$config\[/.test(content)) { + warnings.push( +- 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without CocoaPods.', ++ 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.', ); } @@ -2562,7 +2674,7 @@ index 8fcf04b..7ef3500 100644 }; } -@@ -423,6 +2203,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,6 +2074,58 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2621,7 +2733,7 @@ index 8fcf04b..7ef3500 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2270,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2141,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2639,7 +2751,13 @@ index 8fcf04b..7ef3500 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -456,7 +2296,12 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2162,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + } + } + +- // Determine which subspecs to merge. pod ipc returns: ++ // Determine which subspecs to merge. CocoaPods' JSON form has: + // - `subspecs`: array of nested specs (or undefined) // - `default_subspecs`: array of names (or undefined → use all subspecs) const subspecs = Array.isArray(rawSpec.subspecs) ? rawSpec.subspecs : []; let selected = subspecs; @@ -2653,7 +2771,7 @@ index 8fcf04b..7ef3500 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2309,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,6 +2180,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2664,7 +2782,7 @@ index 8fcf04b..7ef3500 100644 const layers = [rawSpec, ...selected]; function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2331,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,6 +2202,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2682,7 +2800,7 @@ index 8fcf04b..7ef3500 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2404,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2275,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2703,7 +2821,7 @@ index 8fcf04b..7ef3500 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2428,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2299,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2728,7 +2846,7 @@ index 8fcf04b..7ef3500 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2461,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2332,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2749,11 +2867,11 @@ index 8fcf04b..7ef3500 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2531,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,44 +2402,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } -+ // A layer's dependency names. pod ipc returns deps as ++ // A layer's dependency names. CocoaPods' JSON form has deps as + // {name: [versionConstraint, ...], ...}, the regex reader as [name, ...]. + // A reference to a dropped subspec (`/`) is left out. + const ownName = specStringField('name'); @@ -2894,7 +3012,7 @@ index 8fcf04b..7ef3500 100644 } } return out; -@@ -677,6 +2656,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -677,6 +2527,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { ? false : true; // RN ecosystem default @@ -2915,7 +3033,7 @@ index 8fcf04b..7ef3500 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,23 +2686,82 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2557,239 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -2959,8 +3077,10 @@ index 8fcf04b..7ef3500 100644 + ).filter(v => !v.includes('#{')), requiresArc, warnings, ++ reader: partial ? 'reduced' : 'ruby', partial, - // Default: overridden in readPodspec, which can see the podspec source. +- // Default: overridden in readPodspec, which can see the podspec source. ++ // Default: overridden in readPodspec, which knows what the podspec called. usesInstallModulesDependencies: false, + // $FlowFixMe[incompatible-type] runtime-validated dynamic shape + unresolvedSources: Array.isArray(rawSpec.__unresolved__) @@ -2991,42 +3111,141 @@ index 8fcf04b..7ef3500 100644 + '. The podspec reader evaluates locals, string interpolation, arrays, ' + + "ENV['...'], package.json reads, comparisons, ternaries and if/unless " + + 'blocks; building from the part it could read would leave some of the ' + -+ "library's files or settings out of its target. Install CocoaPods (`gem " + -+ 'install cocoapods`) so `pod ipc spec` reads the podspec, or give the ' + -+ 'library a Package.swift of its own.' ++ "library's files or settings out of its target. Install Ruby (sudo apt " + ++ 'install ruby) so rn-xtool reads the podspec as CocoaPods does, or give ' + ++ 'the library a Package.swift of its own.' + ); +} + // --------------------------------------------------------------------------- // Top-level entry // --------------------------------------------------------------------------- -@@ -722,15 +2774,18 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { - * Throws when the file doesn't exist. Otherwise always returns a - * PodspecModel — warnings on the model surface partial parses to the - * caller, who can decide whether to proceed or abort scaffolding for that + + /** +- * Reads and flattens a podspec at `podspecPath`. Tries `pod ipc spec` first +- * (full Ruby DSL evaluation); falls back to a regex parser when CocoaPods +- * isn't available. ++ * Reads and flattens a podspec at `podspecPath` with the reader ++ * `podspecReader()` picks: Ruby through the shim, or the reduced reader. A ++ * podspec Ruby cannot read throws a PodspecReadError; nothing falls back. ++ * `name`, `module_name` and `version` are the reduced reader's literal ++ * readings under both readers (IDENTITY_FIELDS): evaluating `s.name = ++ * package['name']` would rename the scaffolded target. + * +- * Throws when the file doesn't exist. Otherwise always returns a +- * PodspecModel — warnings on the model surface partial parses to the +- * caller, who can decide whether to proceed or abort scaffolding for that - * dep. -+ * dep. The subspecs named in `opts.dropSubspecs` are left out. ++ * Throws when the file doesn't exist. Warnings on the model surface partial ++ * reads to the caller, who can decide whether to proceed or abort scaffolding ++ * for that dep. The subspecs named in `opts.dropSubspecs` are left out. Each ++ * read is appended to RN_SPM_PODSPEC_READS when it is set. */ -function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { +function readPodspec( + podspecPath /*: string */, + opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, ++) /*: PodspecModel */ { ++ return readPodspecWith(podspecReader(), podspecPath, opts); ++} ++ ++function readPodspecWith( ++ choice /*: PodspecReaderChoice */, ++ podspecPath /*: string */, ++ opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, +) /*: PodspecModel */ { if (!fs.existsSync(podspecPath)) { throw new Error(`readPodspec: file does not exist: ${podspecPath}`); } - const podIpc = runPodIpcSpec(podspecPath); +- const podIpc = runPodIpcSpec(podspecPath); - const raw = podIpc != null ? podIpc : regexPodspec(podspecPath); - const model = flattenSubspecs(raw); -+ const raw = podIpc != null ? podIpc : regexPodspec(podspecPath, opts); -+ const model = flattenSubspecs(raw, opts); - // Record whether the podspec calls `install_modules_dependencies(s)`. We - // strip that helper before `pod ipc` and the regex parser can't expand it, - // so the React-Core family it injects never lands in `model.dependencies`. -@@ -746,21 +2801,46 @@ function readPodspec(podspecPath /*: string */) /*: PodspecModel */ { - return model; - } - +- // Record whether the podspec calls `install_modules_dependencies(s)`. We +- // strip that helper before `pod ipc` and the regex parser can't expand it, +- // so the React-Core family it injects never lands in `model.dependencies`. +- // The scaffolder uses this as an implicit React-core marker (plain ObjC +- // modules using the helper have no `codegenConfig` to detect instead). ++ let used /*: {env: Array, helpers: Array} */ = { ++ env: [], ++ helpers: [], ++ }; + try { +- const src = fs.readFileSync(podspecPath, 'utf8'); ++ let shimRaw = null; ++ if (choice.reader === 'ruby') { ++ shimRaw = runPodspecShim(podspecPath).raw; ++ // $FlowFixMe[prop-missing] the shim's dynamic shape ++ const rnXtool = shimRaw.__rn_xtool__; ++ used = { ++ env: Array.isArray(rnXtool?.env) ? rnXtool.env : [], ++ helpers: Array.isArray(rnXtool?.helpers) ? rnXtool.helpers : [], ++ }; ++ } ++ const literal = regexPodspec(podspecPath, opts); ++ const model = flattenSubspecs(shimRaw ?? literal, opts); ++ // Whether the podspec calls `install_modules_dependencies(s)`, which ++ // injects the React-Core family under CocoaPods: the scaffolder uses this ++ // as an implicit React-core marker (plain ObjC modules using the helper ++ // have no `codegenConfig` to detect instead). Ruby knows whether the run ++ // called it; the reduced reader marks every podspec whose source names it. + model.usesInstallModulesDependencies = +- /\binstall_modules_dependencies\b/.test(src); ++ shimRaw != null ++ ? used.helpers.includes('install_modules_dependencies') ++ : /\binstall_modules_dependencies\b/.test( ++ fs.readFileSync(podspecPath, 'utf8'), ++ ); ++ // IDENTITY_FIELDS: the literal readings, under both readers. ++ const identity = (key /*: string */) /*: ?string */ => { ++ // $FlowFixMe[prop-missing] RawSpec is dynamically shaped ++ const value = literal[key]; ++ return typeof value === 'string' && value.length > 0 ? value : null; ++ }; ++ model.name = identity('name') ?? ''; ++ model.moduleName = identity('module_name'); ++ model.version = identity('version') ?? ''; ++ recordPodspecRead(podspecPath, choice, used, null); ++ return model; ++ } catch (e) { ++ recordPodspecRead(podspecPath, choice, used, e); ++ throw e; ++ } ++} ++ ++// One JSON line per read in RN_SPM_PODSPEC_READS, when it is set: the ++// podspec, its reader and why, what the podspec used of its environment, and ++// whether it read. A line that cannot be written does not stop the read. ++function recordPodspecRead( ++ podspecPath /*: string */, ++ choice /*: PodspecReaderChoice */, ++ used /*: {env: Array, helpers: Array} */, ++ error /*: mixed */, ++) /*: void */ { ++ const file = process.env.RN_SPM_PODSPEC_READS; ++ if (file == null || file === '') return; ++ const line /*: {[string]: mixed} */ = { ++ podspec: path.resolve(podspecPath), ++ reader: choice.reader, ++ }; ++ if (choice.reader === 'reduced') line.why = choice.why; ++ line.forced = choice.forced; ++ if (choice.reader === 'ruby') line.ruby = choice.ruby; ++ if (choice.warning != null) line.warning = choice.warning; ++ line.env = used.env; ++ line.helpers = used.helpers; ++ line.ok = error == null; ++ if (error != null) { ++ line.error = error instanceof Error ? error.message : String(error); ++ } ++ try { ++ fs.appendFileSync(file, `${JSON.stringify(line)}\n`); + } catch { +- // best-effort; leave the flattenSubspecs default (false) ++ // the read itself stands + } +- return model; ++} ++ +// The installed React Native's version as the macros libraries derive from it. +function readRnVersionMacros() /*: {[string]: number} */ { + try { @@ -3045,17 +3264,18 @@ index 8fcf04b..7ef3500 100644 + // unreadable: the defines stay dropped + } + return {}; -+} -+ + } + const podspecModels /*: Map */ = new Map(); /** - * readPodspec memoized on the resolved path. `pod ipc spec` costs a process +- * readPodspec memoized on the resolved path. `pod ipc spec` costs a process ++ * readPodspec memoized on the resolved path. A Ruby read costs a process * spawn, and one autolinking run reads the same podspec from several sites * (name resolution, header search paths, scaffolding). The model is shared, so - * callers must treat it as read-only. -+ * callers must treat it as read-only. The key is the resolved path plus the -+ * sorted `opts.dropSubspecs`. ++ * callers must treat it as read-only. The key is the resolved path, the ++ * sorted `opts.dropSubspecs` and the reader. */ -function readPodspecCached(podspecPath /*: string */) /*: PodspecModel */ { - const key = path.resolve(podspecPath); @@ -3064,17 +3284,25 @@ index 8fcf04b..7ef3500 100644 + opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, +) /*: PodspecModel */ { + const drop = [...(opts?.dropSubspecs ?? [])].sort(); -+ const key = [path.resolve(podspecPath), ...drop].join('\0'); ++ const choice = podspecReader(); ++ const key = [path.resolve(podspecPath), choice.reader, ...drop].join('\0'); const cached = podspecModels.get(key); if (cached != null) { return cached; } - const model = readPodspec(podspecPath); -+ const model = readPodspec(podspecPath, {dropSubspecs: drop}); ++ const model = readPodspecWith(choice, podspecPath, {dropSubspecs: drop}); podspecModels.set(key, model); return model; } -@@ -794,12 +2874,13 @@ function readPodspecNames( + + /** +- * The three fields that name a library, read WITHOUT `pod ipc spec`'s process ++ * The three fields that name a library, read WITHOUT Ruby's process + * spawn — name resolution runs for every dep, including self-managed ones that + * need nothing else from the podspec. + * +@@ -794,12 +2817,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3089,7 +3317,19 @@ index 8fcf04b..7ef3500 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -834,10 +2915,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -817,8 +2841,9 @@ function readPodspecNames( + + /** + * Every podspec in `dir`, sorted so two of them name a target the same way on +- * every machine (readdir order is unspecified). Skips a crashed run's leftover +- * `.spm-scaffold--.podspec` copy. ++ * every machine (readdir order is unspecified). Skips the ++ * `.spm-scaffold--.podspec` copy a crashed run of an older rn-xtool ++ * (which read podspecs with `pod ipc spec`) left. + */ + function findPodspecs(dir /*: string */) /*: Array */ { + try { +@@ -834,10 +2859,15 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, @@ -3100,7 +3340,7 @@ index 8fcf04b..7ef3500 100644 readPodspec, readPodspecCached, readPodspecNames, - runPodIpcSpec, +- runPodIpcSpec, + runPodspecShim, regexPodspec, flattenSubspecs, @@ -5007,12 +5247,71 @@ index cf7e587..f105e49 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..6ce647d 100644 +index a89142f..b9ed2bc 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js -@@ -471,6 +471,10 @@ export type PodspecModel = { - // flag as an implicit React-core dependency (a plain ObjC module using the - // helper has no `codegenConfig` to key off). +@@ -411,8 +411,8 @@ export type PreprocessorDefine = { + // Scaffold types — for the `npx react-native spm scaffold` command that + // generates a `Package.swift` into `node_modules//` for community RN + // libraries that don't ship SPM support. Inputs come from the dep's podspec +-// (read via `pod ipc spec --format=json` when CocoaPods is available, or a +-// regex fallback). The output Package.swift is treated as "self-managed" by ++// (read with Ruby through read-podspec-shim.rb when it is usable, or the ++// reduced reader). The output Package.swift is treated as "self-managed" by + // the autolinker — see isSelfManagedPackage in generate-spm-autolinking.js. + // --------------------------------------------------------------------------- + +@@ -440,9 +440,11 @@ export type PodspecModel = { + frameworks: Array, + weakFrameworks: Array, + libraries: Array, +- // Merged dependency name list. With pod-ipc, includes the deps materialized +- // by `install_modules_dependencies(s)` (React-Core, React-Fabric, ...). +- // Version constraints stripped — we only need the name to bucket. ++ // Merged dependency name list. Never includes the React-Core family that ++ // `install_modules_dependencies(s)` injects under CocoaPods: the shim only ++ // records the call (see usesInstallModulesDependencies), and the reduced ++ // reader cannot expand it. Version constraints stripped — we only need the ++ // name to bucket. + dependencies: Array, + compilerFlags: Array, + // Raw header-search-path entries from `pod_target_xcconfig['HEADER_SEARCH_PATHS']`. +@@ -450,7 +452,7 @@ export type PodspecModel = { + headerSearchPaths: Array, + // Preprocessor defines lifted from pod_target_xcconfig OTHER_CFLAGS (`-D` + // tokens) + GCC_PREPROCESSOR_DEFINITIONS (incl. per-config variants). Already +- // resolved by `pod ipc` (e.g. `-DWORKLETS_VERSION=#{package['version']}` → ++ // resolved by the reader (e.g. `-DWORKLETS_VERSION=#{package['version']}` → + // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. + preprocessorDefines: Array, + // File paths or glob patterns the dep declares as bundled resources. +@@ -460,17 +462,25 @@ export type PodspecModel = { + // a user can spot fields that didn't translate cleanly (unknown env vars, + // unrecognized $(...) tokens, etc.). Never throws on parse errors. + warnings: Array, +- // True when produced by the regex fallback rather than pod-ipc. Used to +- // emit a louder banner in the scaffold summary explaining that dependency +- // wiring may be incomplete. ++ // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the ++ // reduced reader (podspecReader in read-podspec.js says why). ++ reader: 'ruby' | 'reduced', ++ // True when produced by the reduced reader rather than Ruby. Used to emit a ++ // louder banner in the scaffold summary explaining that dependency wiring ++ // may be incomplete. + partial: boolean, +- // True when the podspec source calls `install_modules_dependencies(s)` — +- // RN's Podfile-side helper that injects the React-Core family. We strip that +- // helper before evaluating the spec (and the regex parser can't expand it), +- // so React-Core never surfaces in `dependencies`. The scaffolder treats this +- // flag as an implicit React-core dependency (a plain ObjC module using the +- // helper has no `codegenConfig` to key off). ++ // True when the podspec calls `install_modules_dependencies(s)` — RN's ++ // Podfile-side helper that injects the React-Core family. With Ruby, when ++ // the run called it (the shim records the call and adds nothing); with the ++ // reduced reader, when the source names it. React-Core never surfaces in ++ // `dependencies`, so the scaffolder treats this flag as an implicit ++ // React-core dependency (a plain ObjC module using the helper has no ++ // `codegenConfig` to key off). usesInstallModulesDependencies: boolean, + // The `source_files`/`exclude_files` values the regex fallback could not + // evaluate (a method call, an unknown local): the scaffolder refuses the @@ -5021,7 +5320,16 @@ index a89142f..6ce647d 100644 }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -502,6 +506,9 @@ export type SpmScaffoldSpec = { +@@ -485,7 +495,7 @@ export type SpmScaffoldSpec = { + // Header search paths resolved to dep-root-relative form. Each entry + // becomes `.headerSearchPath("")` in cSettings + cxxSettings. + headerSearchPaths: Array, +- // Preprocessor defines (resolved by pod ipc) — emitted as `.define(...)` in ++ // Preprocessor defines (resolved by the reader) — emitted as `.define(...)` in + // cSettings + cxxSettings, honoring any per-config scope. + preprocessorDefines: Array, + // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + +@@ -502,6 +512,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5031,7 +5339,7 @@ index a89142f..6ce647d 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +546,9 @@ export type ScaffoldResult = +@@ -539,6 +552,9 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 6012de5..dbff1f9 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -1,7 +1,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import path from "node:path"; -import { afterEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { VENDORED_RN_SPM } from "./support/rnScaffold.js"; import { SHIM, needsRuby, tempDir } from "./support/ruby.js"; import { tool } from "./support/tools.js"; @@ -10,7 +10,9 @@ import { tool } from "./support/tools.js"; // The reader's choice runs fake `ruby` scripts (a temp `bin` alone on `PATH`) and needs no Ruby; the shim's runs need // the real one. const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); -const { podspecReader, runPodspecShim, isPodspecReadError, installationRootFor } = req("./read-podspec.js"); +const readPodspecJs = req("./read-podspec.js"); +const { podspecReader, runPodspecShim, isPodspecReadError, installationRootFor } = readPodspecJs; +const { readPodspec, readPodspecCached, unresolvedSourcesReason } = readPodspecJs; const REMEDY = "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report."; @@ -255,3 +257,127 @@ describe.skipIf(needsRuby !== "")(`running the podspec shim${needsRuby}`, () => expect(existsSync(path.join(proj, "ios"))).toBe(false); }); }); + +describe.skipIf(needsRuby !== "")(`readPodspec${needsRuby}`, () => { + const INSTALL_RUBY = + "Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own."; + beforeEach(() => { + const rn = tempDir(); + writeFileSync(path.join(rn, "package.json"), JSON.stringify({ name: "react-native", version: "0.86.3" })); + vi.stubEnv("RN_SPM_RN_ROOT", rn); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + vi.stubEnv("RN_SPM_PODSPEC_READS", undefined); + }); + const forceReduced = () => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced"); + + it("reads with Ruby and says so", () => { + const podspec = library(spec(' s.version = "1.0.0"', ' s.source_files = "ios/**/*.{h,m}"')); + expect(readPodspec(podspec)).toMatchObject({ + reader: "ruby", + partial: false, + name: "Foo", + version: "1.0.0", + sourceFiles: ["ios/**/*.{h,m}"], + }); + }); + + it("never falls back after a shim failure", () => { + const podspec = library(spec(' s.source_files = sources_for("ios")')); + const e = thrown(() => readPodspec(podspec)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("method"); + }); + + it("reads with the reduced reader when forced", () => { + forceReduced(); + expect(readPodspec(library(spec()))).toMatchObject({ reader: "reduced", partial: true, name: "Foo" }); + }); + + it("keeps the literal identity fields", () => { + const podspec = library( + [ + "package = JSON.parse(File.read(File.join(__dir__, 'package.json')))", + "Pod::Spec.new do |s|", + " s.name = package['name']", + " s.version = package['version']", + ' s.module_name = "Foo"', + "end", + ].join("\n"), + { "package.json": JSON.stringify({ name: "react-native-foo", version: "1.2.3" }) }, + ); + expect(readPodspec(podspec)).toMatchObject({ reader: "ruby", name: "", version: "", moduleName: "Foo" }); + forceReduced(); + expect(readPodspec(podspec)).toMatchObject({ reader: "reduced", name: "", version: "", moduleName: "Foo" }); + }); + + it("marks React core from the helper actually called", () => { + expect(readPodspec(library(spec(" install_modules_dependencies(s)"))).usesInstallModulesDependencies).toBe(true); + const notCalled = library(spec(" install_modules_dependencies(s) if false")); + expect(readPodspec(notCalled).usesInstallModulesDependencies).toBe(false); + forceReduced(); + expect(readPodspec(notCalled).usesInstallModulesDependencies).toBe(true); + }); + + it("caches per reader", () => { + const podspec = library(spec()); + const ruby = readPodspecCached(podspec); + expect(readPodspecCached(podspec)).toBe(ruby); + forceReduced(); + const reduced = readPodspecCached(podspec); + expect(reduced).not.toBe(ruby); + expect([ruby.reader, reduced.reader]).toEqual(["ruby", "reduced"]); + }); + + it("never runs pod", () => { + const marker = path.join(tempDir(), "pod-ran"); + const bin = path.join(tempDir(), "bin"); + mkdirSync(bin); + writeFileSync(path.join(bin, "pod"), `#!/bin/sh\ntouch '${marker}'\nexit 1\n`); + chmodSync(path.join(bin, "pod"), 0o755); + vi.stubEnv("PATH", `${bin}${path.delimiter}${process.env.PATH ?? ""}`); + const podspec = library(spec()); + expect(readPodspec(podspec).reader).toBe("ruby"); + readPodspecCached(podspec); + forceReduced(); + readPodspec(podspec); + expect(existsSync(marker)).toBe(false); + expect(readPodspecJs).not.toHaveProperty("runPodIpcSpec"); + }); + + it("appends each read to RN_SPM_PODSPEC_READS", () => { + const reads = path.join(tempDir(), "reads.jsonl"); + vi.stubEnv("RN_SPM_PODSPEC_READS", reads); + const lines = () => { + const text = readFileSync(reads, "utf8"); + expect(text.endsWith("\n")).toBe(true); + return text.slice(0, -1).split("\n").map((line) => JSON.parse(line)); + }; + const ruby = podspecReader().ruby; + const ok = library(spec(" s.summary = ENV['RCT_NEW_ARCH_ENABLED']", " install_modules_dependencies(s)")); + readPodspecCached(ok); + const okLine = { + podspec: ok, + reader: "ruby", + forced: false, + ruby, + env: ["RCT_NEW_ARCH_ENABLED"], + helpers: ["install_modules_dependencies"], + ok: true, + }; + expect(lines()).toEqual([okLine]); + const bad = library(spec(' s.source_files = sources_for("ios")')); + const e = thrown(() => readPodspecCached(bad)); + readPodspecCached(ok); + expect(lines()).toEqual([ + okLine, + { podspec: bad, reader: "ruby", forced: false, ruby, env: [], helpers: [], ok: false, error: e.message }, + ]); + }); + + it("tells a refused glob to install Ruby", () => { + forceReduced(); + const podspec = library(spec(' s.source_files = sources_for("ios")')); + const reason: string = unresolvedSourcesReason(podspec, readPodspec(podspec)); + expect(reason.slice(-INSTALL_RUBY.length - 1)).toBe(` ${INSTALL_RUBY}`); + }); +}); diff --git a/tests/rn-scaffolder.test.ts b/tests/rn-scaffolder.test.ts index 6187408..d82f39f 100644 --- a/tests/rn-scaffolder.test.ts +++ b/tests/rn-scaffolder.test.ts @@ -3,7 +3,7 @@ import { createRequire } from "node:module"; import { homedir, tmpdir } from "node:os"; import path from "node:path"; import { execa } from "execa"; -import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { GOLDEN_LIBS, PODSPEC_FIXTURES, @@ -12,6 +12,7 @@ import { scaffoldLibraries, withRnRoot, } from "./support/rnScaffold.js"; +import { needsRuby } from "./support/ruby.js"; import { needsTarball, packageFromTarball, patchedSpm, tarballPath } from "./support/tarballs.js"; import { SWIFT_TEST_TIMEOUT_MS, SWIFT_TIMEOUT_MS, hasTool, tool } from "./support/tools.js"; @@ -70,8 +71,8 @@ afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); }); /** - * A copy of a library podspec, with what it reads (package.json, svg's scripts/): reading a podspec - * writes a temporary `.spm-scaffold-*.podspec` next to it, which must not land in the shared pristine tree. + * A copy of a library podspec, with what it reads (package.json, svg's scripts/): reading a podspec runs it, and + * nothing it may write must land in the shared pristine tree. */ function podspecCopy(file: string): string { const dir = tempDir(); @@ -153,9 +154,9 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); it("the scaffolder has the fixes 14–19 hunks", () => { expect(src("read-podspec.js")).toContain("function resolvePackageVersion"); - // Fix 19's RN_POD_ENV ternary, which fix 28 grew into ENV lookups in the evaluator. + // Fix 19's RN_POD_ENV ternary, which fix 28 grew into ENV lookups in the evaluator, and the shim's environment. expect(src("read-podspec.js")).toContain("const RN_POD_ENV"); - expect(src("read-podspec.js")).toContain("env: {...process.env, ...RN_POD_ENV}"); + expect(src("read-podspec.js")).toContain("...RN_POD_ENV"); const f = src("scaffold-package-swift.js"); expect(f).toContain("RN_XTOOL_SCAFFOLD_REVISION = 7"); expect(f).toContain("rn-xtool-swift-importer-paths"); @@ -257,6 +258,8 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("read-podspec Ruby constants", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const read = (body: string) => load("read-podspec.js").readPodspecCached(podspec(body)).sourceFiles; @@ -286,6 +289,8 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("read-podspec subspecs", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const readModel = (body: string) => load("read-podspec.js").readPodspecCached(podspec(body)) as Model & { excludeFiles: string[]; @@ -325,6 +330,8 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("read-podspec hardening", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); type M = Model & { excludeFiles: string[]; frameworks: string[] }; function readRaw(src: string): M { const file = path.join(tempDir(), "Foo.podspec"); @@ -387,6 +394,9 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("read-podspec platform-scoped fields", () => { + // Pinned until Task 5 adds the `ios` merge to the Ruby path and gives the svg copy a react-native beside it; Task 5 removes this pin. + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const readModel = (body: string) => load("read-podspec.js").readPodspecCached(podspec(body)) as Model & { excludeFiles: string[]; @@ -442,6 +452,8 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("preprocessor defines", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); type Def = { name: string; value: string | null; config: string | null }; const model = (body: string) => load("read-podspec.js").readPodspecCached(podspec(body)) as Model & { @@ -1162,6 +1174,8 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () // gesture-handler 2.32.0, plus screens 4.30.1, which has no Swift (a clang-only target), and // worklets 0.8.3 (fix 19's `RCT_HERMES_V1_ENABLED` ternary). describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const req = createRequire(import.meta.url); const load = (f: string) => req(path.join(VENDORED_RN_SPM, f)) as T; const IMPORTER = /^\/\/ rn-xtool-swift-importer-paths: (.*)$/m; @@ -1516,23 +1530,19 @@ describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { } }); - it("19: runs `pod ipc spec` with React Native's value 1 for both variables, whatever the environment says", () => { - // With the CocoaPods gem on PATH, `pod ipc spec` evaluates the podspec itself: it must see the same values as the - // regex path, or worklets loses HERMES_V1_ENABLED there. A stub `pod` prints the values it was given as the spec. - const bin = tempDir(); - writeFileSync( - path.join(bin, "pod"), - '#!/bin/sh\nprintf \'{"name":"Foo","args":"%s %s","arch":"%s","hermes":"%s"}\\n\' "$1" "$2" "$RCT_NEW_ARCH_ENABLED" "$RCT_HERMES_V1_ENABLED"\n', - { mode: 0o755 }, + it.skipIf(needsRuby !== "")(`19: the shim reads both variables as 1, whatever the environment says${needsRuby}`, () => { + // Ruby runs the podspec itself: it must see the same values as the reduced reader, or worklets loses + // HERMES_V1_ENABLED there. + const podspecFile = path.join( + lib({}, " s.summary = ENV['RCT_NEW_ARCH_ENABLED'] + ENV['RCT_HERMES_V1_ENABLED']"), + "Foo.podspec", ); - const podspecFile = path.join(lib({}, ""), "Foo.podspec"); - const { runPodIpcSpec } = load<{ runPodIpcSpec(f: string): Record | null }>("read-podspec.js"); + const { runPodspecShim } = load<{ runPodspecShim(f: string): { raw: Record } }>("read-podspec.js"); try { - vi.stubEnv("PATH", `${bin}${path.delimiter}${process.env["PATH"] ?? ""}`); - for (const value of [undefined, "0", "", "true"]) { + for (const value of ["0", "", "true"]) { vi.stubEnv("RCT_NEW_ARCH_ENABLED", value); vi.stubEnv("RCT_HERMES_V1_ENABLED", value); - expect(runPodIpcSpec(podspecFile), String(value)).toEqual({ name: "Foo", args: "ipc spec", arch: "1", hermes: "1" }); + expect(runPodspecShim(podspecFile).raw.summary, value).toBe("11"); } } finally { vi.unstubAllEnvs(); @@ -1594,6 +1604,8 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { `Dependency "${dep}" is not installed (or not linked for iOS); left out with the subspec "${subspec}" that declares it (its sources, headers, settings and dependencies), as CocoaPods leaves it out.`; describe("20: a dependency on a package that is not installed", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); // react-native-vision-camera 4.7.3's shape: the FrameProcessors subspec exists only `if enableFrameProcessors`, // which the podspec turns off when react-native-worklets-core does not resolve. The regex reader sees it anyway. const VISION_CAMERA = [ @@ -1749,6 +1761,8 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { }); describe("21: Swift 5 language mode unless the podspec asks for 6", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const MODE = " swiftLanguageModes: [.v5],\n cxxLanguageStandard: .cxx20\n"; const scaffold = (files: Record, podBody: string) => { const run = scaffoldLibraries(VENDORED_RN_SPM, { foo: lib(files, podBody) }); @@ -1804,7 +1818,7 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { expect(files["foo/Package.swift"]).not.toContain("swiftLanguageModes"); }); - it("reads swift_version and swift_versions from pod ipc spec's JSON", () => { + it("reads swift_version and swift_versions from CocoaPods' JSON form", () => { const { flattenSubspecs } = load<{ flattenSubspecs(raw: object): { swiftVersions: string[] } }>("read-podspec.js"); const model = withRnRoot("0.86.3", () => flattenSubspecs({ name: "Foo", swift_versions: ["5.0"], subspecs: [{ name: "core", swift_version: "6.0" }] }), @@ -1934,6 +1948,8 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { }); describe("24: Swift compilation conditions", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const swiftSettingsOf = (pkg: string) => pkg.split("\n").find((l) => l.trim().startsWith("swiftSettings:"))?.trim(); const scaffold = (files: Record, podBody: string) => { const run = scaffoldLibraries(VENDORED_RN_SPM, { foo: lib(files, podBody) }); @@ -1977,7 +1993,7 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { expect(pkg).not.toContain('.define("FOO")'); }); - it("reads them from pod ipc spec's JSON", () => { + it("reads them from CocoaPods' JSON form", () => { const { flattenSubspecs } = load<{ flattenSubspecs(raw: object): { swiftConditions: string[] } }>("read-podspec.js"); const model = withRnRoot("0.86.3", () => flattenSubspecs({ @@ -2032,6 +2048,8 @@ describe("scaffolder fixes 20–26 (vendor/rn-spm)", () => { }); describe("26: parenthesised dependencies", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); type Deps = { dependencies: string[]; subspecDependencies?: Record }; it("26: reads `s.dependency('Pod', …)` as CocoaPods does", () => { const root = lib( @@ -2405,6 +2423,8 @@ describe("scaffolder fix 27: binary pods (vendor/rn-spm)", () => { // conditional `.push`, `if !gamma … else … end` around `exclude_files`): the reader left `#{exts}` unresolved, the // target got only the `common` subspec's C++ and no Objective-C class, and the app crashed at start. describe("scaffolder fix 28: podspec locals and conditions (vendor/rn-spm)", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); const fixture = (dir: string) => path.join(PODSPEC_FIXTURES, dir); /** The `sources:` entries of a manifest's first target. */ const sourcesOf = (pkg: string) => [...pkg.match(/sources: \[([^\]]*)\]/)![1]!.matchAll(/"([^"]+)"/g)].map((m) => m[1]!); diff --git a/tests/vendor-rn-spm.test.ts b/tests/vendor-rn-spm.test.ts index 6ca4afc..ab8da54 100644 --- a/tests/vendor-rn-spm.test.ts +++ b/tests/vendor-rn-spm.test.ts @@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, import { createRequire } from "node:module"; import { tmpdir } from "node:os"; import path from "node:path"; -import { afterAll, describe, expect, it } from "vitest"; +import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { packageRoot } from "../src/tools/exec.js"; import { RN_INTEGRITY as INTEGRITY, RN_TARBALL as TARBALL } from "./support/rnScaffold.js"; import { FETCH_HINT } from "./support/tarballs.js"; @@ -78,6 +78,8 @@ describe("vendor/rn-spm provenance", () => { }); describe("vendor/rn-spm dependencies and edits", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); + afterEach(() => vi.unstubAllEnvs()); it("the vendored scripts resolve yargs and micromatch from rn-xtool", () => { const nm = path.join(packageRoot(), "node_modules"); expect(req.resolve("yargs").startsWith(nm)).toBe(true); diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index 04abd97..b4d195d 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -161,7 +161,7 @@ resolveLocalHermesCompilerVersion, --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2803,9 +2803,15 @@ +@@ -2745,9 +2745,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index ab0a59c..7aa2b2c 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -16,11 +16,12 @@ * read-podspec.js — produces a flattened, SPM-friendly view of an iOS * podspec for the scaffolder. * - * Strategy: prefer `pod ipc spec ` (CocoaPods evaluates the Ruby DSL, - * including `install_modules_dependencies(s)` and `$config[:...]` - * interpolation, so the JSON output reflects the real spec). Fall back to a - * best-effort regex parser when CocoaPods isn't available — handles simple - * RN libs but skips subspec blocks and Ruby helpers with a warning. + * Strategy: run the podspec with the system Ruby against a shim of + * CocoaPods' DSL and React Native's helpers (read-podspec-shim.rb), which + * writes the spec in CocoaPods' JSON form, so the model reflects the real + * spec. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, the + * reduced reader (a JavaScript evaluator and regex parser) reads it instead + * and says so. A podspec Ruby cannot read is an error, never a fallback. * * The output `PodspecModel` collapses the spec's default subspecs into a * single logical target view, since that's how RN consumers compile these @@ -36,136 +37,6 @@ const path = require('node:path'); type RawSpec = {[string]: unknown}; */ -// --------------------------------------------------------------------------- -// Pod-IPC primary path -// --------------------------------------------------------------------------- - -/** - * Runs `pod ipc spec ` and parses the JSON it prints. Returns null - * on any failure: CocoaPods missing, command threw, output not JSON, etc. - * Callers should treat null as a signal to fall back to the regex parser. - */ -/** - * Strips RN-specific Ruby helpers from a podspec source so `pod ipc spec` - * can evaluate it without RN's Podfile-side helpers loaded. The stripped - * helpers (`install_modules_dependencies(s)`) typically inject the React-Core - * / React-Fabric family — all of which the scaffolder collapses into the - * single `ReactNative` product anyway, so dropping them is safe as long as - * the podspec also has an explicit `s.dependency "React-Core"` (almost all - * RN libs do). Writes the patched content to a temp file and returns its - * path; caller deletes when done. - */ -function patchPodspecForPodIpc(podspecPath /*: string */) /*: string */ { - const content = fs.readFileSync(podspecPath, 'utf8'); - // Comment out RN-Podfile-only helpers. We do NOT remove the lines so - // line numbers in any pod ipc errors still match the original file. - const patched = content - .replace( - /^(\s*)install_modules_dependencies\(([^)]*)\)/gm, - '$1# install_modules_dependencies($2) # stripped for pod ipc', - ) - .replace( - /^(\s*)use_react_native!\(([^)]*)\)/gm, - '$1# use_react_native!($2) # stripped for pod ipc', - ); - // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. - // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or - // similar, expecting the package.json sibling. Keeping the patched file - // in the same directory makes those reads continue to work. - const depDir = path.dirname(podspecPath); - // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. - // Use a dotfile prefix so the patched copy is invisible to normal listing - // but the suffix CocoaPods requires is preserved. - const tmpFile = path.join( - depDir, - `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, - ); - fs.writeFileSync(tmpFile, patched, 'utf8'); - return tmpFile; -} - -function runPodIpcSpec(podspecPath /*: string */) /*: RawSpec | null */ { - // RN podspecs often call `install_modules_dependencies(s)`, a helper - // defined by RN's Podfile-side scripts. `pod ipc spec` doesn't load - // those, so the helper is undefined and the whole spec fails to parse. - // Pre-process to strip those calls before invoking pod ipc. - let patchedPath /*: ?string */ = null; - try { - patchedPath = patchPodspecForPodIpc(podspecPath); - } catch { - return null; - } - let result; - try { - result = spawnSync('pod', ['ipc', 'spec', patchedPath], { - encoding: 'utf8', - timeout: 30000, - maxBuffer: 8 * 1024 * 1024, - // Many RN podspecs gate subspec definitions on `RCT_NEW_ARCH_ENABLED` - // (e.g. safe-area-context wraps its Fabric `common` + `fabric` - // subspecs in `if fabric_enabled`), and react-native-worklets gates its - // `-DHERMES_V1_ENABLED` flag on `RCT_HERMES_V1_ENABLED`. Give both the - // value React Native's CocoaPods setup gives them (`RN_POD_ENV`, which - // the regex fallback evaluates with too), whatever the environment - // says, so `pod ipc spec` reads the podspec as that setup would. - env: {...process.env, ...RN_POD_ENV}, - }); - } catch { - cleanupPatchedPodspec(patchedPath); - return null; - } - cleanupPatchedPodspec(patchedPath); - if (result == null || result.error != null) { - return null; - } - if (typeof result.status !== 'number' || result.status !== 0) { - return null; - } - if (typeof result.stdout !== 'string' || result.stdout.length === 0) { - return null; - } - // Some podspecs print diagnostics to stdout during evaluation (e.g. skia: - // `-- SK_GRAPHITE: OFF ...`) before `pod ipc` emits the JSON, and a - // diagnostic can itself contain braces (`Building {module}`). `pod ipc` - // pretty-prints the spec as a JSON object whose outermost braces sit at - // column 0, so ANCHOR on a line-boundary `{`…`}` rather than the first/last - // brace anywhere — otherwise a brace inside a diagnostic shifts the slice and - // JSON.parse throws. When the authoritative parse is abandoned we log (not - // silently drop to the much weaker, subspec-blind regex parser). - const stdout = result.stdout; - const startMatch = stdout.match(/^\{/m); - const start = startMatch != null ? startMatch.index : -1; - const lastLineBrace = stdout.lastIndexOf('\n}'); - const end = - lastLineBrace >= 0 ? lastLineBrace + 2 : stdout.lastIndexOf('}') + 1; - if (start < 0 || end <= start) { - console.warn( - '[read-podspec] pod ipc spec produced no line-anchored JSON object; ' + - 'falling back to the regex parser (subspecs/helpers may be missed).', - ); - return null; - } - try { - return JSON.parse(stdout.slice(start, end)); - } catch (e) { - console.warn( - `[read-podspec] pod ipc spec JSON parse failed (${e.message}); ` + - 'falling back to the regex parser (subspecs/helpers may be missed).', - ); - return null; - } -} - -function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { - if (patchedPath == null) return; - try { - fs.unlinkSync(patchedPath); - } catch { - // best-effort cleanup; the file is named with `.spm-scaffold-...tmp` - // so a leftover is identifiable. - } -} - // --------------------------------------------------------------------------- // The podspec reader: Ruby or the reduced reader // --------------------------------------------------------------------------- @@ -1797,7 +1668,7 @@ function regexPodspec( // The main spec's own statements, and each subspec block apart. The readers // below default to the main text and receiver; a subspec is read with the // same readers anchored on its block variable, then merged like - // flattenSubspecs does for `pod ipc spec` output. + // flattenSubspecs does for the shim's model. const {main, subspecs: allSubspecs} = splitSubspecs(content, mainName); // Matches: s. = "value" or s. = 'value' — on `recv` @@ -2000,7 +1871,7 @@ function regexPodspec( // Literal `'OTHER_CFLAGS' => '-DFOO=1'` and `'GCC_PREPROCESSOR_DEFINITIONS' => // '$(inherited) BAR=1'` entries (also `[config=*Debug*]` keys), from any // xcconfig hash. Returned as {rawKey: space-joined values} so - // flattenSubspecs lifts them like the `pod ipc` JSON. Only string literals + // flattenSubspecs lifts them like the shim's JSON. Only string literals // are read: an array, `.join` or interpolated value is not understood (an // interpolated token is dropped later, with the other unresolved ones). function getDefineXcconfig( @@ -2038,22 +1909,22 @@ function regexPodspec( // Surface known unparseable constructs so the caller can warn the user. if (shadowedIdentity) { warnings.push( - "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.", + "A subspec rebinds the spec variable (`do |s|`), so its `name`, `module_name` and `header_dir` cannot be told from the library's own — those are left unread. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", ); } if (new RegExp(`(?:${mainName})\\.subspec\\b`).test(content)) { warnings.push( - 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install CocoaPods (`gem install cocoapods`) to enable full `pod ipc spec` parsing.', + 'Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.', ); } if (/install_modules_dependencies/.test(content)) { warnings.push( - '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without CocoaPods.', + '`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.', ); } if (/\bENV\[/.test(content) || /\$config\[/.test(content)) { warnings.push( - 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without CocoaPods.', + 'Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.', ); } @@ -2291,7 +2162,7 @@ function flattenSubspecs( } } - // Determine which subspecs to merge. pod ipc returns: + // Determine which subspecs to merge. CocoaPods' JSON form has: // - `subspecs`: array of nested specs (or undefined) // - `default_subspecs`: array of names (or undefined → use all subspecs) const subspecs = Array.isArray(rawSpec.subspecs) ? rawSpec.subspecs : []; @@ -2531,7 +2402,7 @@ function flattenSubspecs( return out; } - // A layer's dependency names. pod ipc returns deps as + // A layer's dependency names. CocoaPods' JSON form has deps as // {name: [versionConstraint, ...], ...}, the regex reader as [name, ...]. // A reference to a dropped subspec (`/`) is left out. const ownName = specStringField('name'); @@ -2724,8 +2595,9 @@ function flattenSubspecs( ).filter(v => !v.includes('#{')), requiresArc, warnings, + reader: partial ? 'reduced' : 'ruby', partial, - // Default: overridden in readPodspec, which can see the podspec source. + // Default: overridden in readPodspec, which knows what the podspec called. usesInstallModulesDependencies: false, // $FlowFixMe[incompatible-type] runtime-validated dynamic shape unresolvedSources: Array.isArray(rawSpec.__unresolved__) @@ -2756,9 +2628,9 @@ function unresolvedSourcesReason( '. The podspec reader evaluates locals, string interpolation, arrays, ' + "ENV['...'], package.json reads, comparisons, ternaries and if/unless " + 'blocks; building from the part it could read would leave some of the ' + - "library's files or settings out of its target. Install CocoaPods (`gem " + - 'install cocoapods`) so `pod ipc spec` reads the podspec, or give the ' + - 'library a Package.swift of its own.' + "library's files or settings out of its target. Install Ruby (sudo apt " + + 'install ruby) so rn-xtool reads the podspec as CocoaPods does, or give ' + + 'the library a Package.swift of its own.' ); } @@ -2767,38 +2639,108 @@ function unresolvedSourcesReason( // --------------------------------------------------------------------------- /** - * Reads and flattens a podspec at `podspecPath`. Tries `pod ipc spec` first - * (full Ruby DSL evaluation); falls back to a regex parser when CocoaPods - * isn't available. + * Reads and flattens a podspec at `podspecPath` with the reader + * `podspecReader()` picks: Ruby through the shim, or the reduced reader. A + * podspec Ruby cannot read throws a PodspecReadError; nothing falls back. + * `name`, `module_name` and `version` are the reduced reader's literal + * readings under both readers (IDENTITY_FIELDS): evaluating `s.name = + * package['name']` would rename the scaffolded target. * - * Throws when the file doesn't exist. Otherwise always returns a - * PodspecModel — warnings on the model surface partial parses to the - * caller, who can decide whether to proceed or abort scaffolding for that - * dep. The subspecs named in `opts.dropSubspecs` are left out. + * Throws when the file doesn't exist. Warnings on the model surface partial + * reads to the caller, who can decide whether to proceed or abort scaffolding + * for that dep. The subspecs named in `opts.dropSubspecs` are left out. Each + * read is appended to RN_SPM_PODSPEC_READS when it is set. */ function readPodspec( podspecPath /*: string */, opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, +) /*: PodspecModel */ { + return readPodspecWith(podspecReader(), podspecPath, opts); +} + +function readPodspecWith( + choice /*: PodspecReaderChoice */, + podspecPath /*: string */, + opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, ) /*: PodspecModel */ { if (!fs.existsSync(podspecPath)) { throw new Error(`readPodspec: file does not exist: ${podspecPath}`); } - const podIpc = runPodIpcSpec(podspecPath); - const raw = podIpc != null ? podIpc : regexPodspec(podspecPath, opts); - const model = flattenSubspecs(raw, opts); - // Record whether the podspec calls `install_modules_dependencies(s)`. We - // strip that helper before `pod ipc` and the regex parser can't expand it, - // so the React-Core family it injects never lands in `model.dependencies`. - // The scaffolder uses this as an implicit React-core marker (plain ObjC - // modules using the helper have no `codegenConfig` to detect instead). + let used /*: {env: Array, helpers: Array} */ = { + env: [], + helpers: [], + }; try { - const src = fs.readFileSync(podspecPath, 'utf8'); + let shimRaw = null; + if (choice.reader === 'ruby') { + shimRaw = runPodspecShim(podspecPath).raw; + // $FlowFixMe[prop-missing] the shim's dynamic shape + const rnXtool = shimRaw.__rn_xtool__; + used = { + env: Array.isArray(rnXtool?.env) ? rnXtool.env : [], + helpers: Array.isArray(rnXtool?.helpers) ? rnXtool.helpers : [], + }; + } + const literal = regexPodspec(podspecPath, opts); + const model = flattenSubspecs(shimRaw ?? literal, opts); + // Whether the podspec calls `install_modules_dependencies(s)`, which + // injects the React-Core family under CocoaPods: the scaffolder uses this + // as an implicit React-core marker (plain ObjC modules using the helper + // have no `codegenConfig` to detect instead). Ruby knows whether the run + // called it; the reduced reader marks every podspec whose source names it. model.usesInstallModulesDependencies = - /\binstall_modules_dependencies\b/.test(src); + shimRaw != null + ? used.helpers.includes('install_modules_dependencies') + : /\binstall_modules_dependencies\b/.test( + fs.readFileSync(podspecPath, 'utf8'), + ); + // IDENTITY_FIELDS: the literal readings, under both readers. + const identity = (key /*: string */) /*: ?string */ => { + // $FlowFixMe[prop-missing] RawSpec is dynamically shaped + const value = literal[key]; + return typeof value === 'string' && value.length > 0 ? value : null; + }; + model.name = identity('name') ?? ''; + model.moduleName = identity('module_name'); + model.version = identity('version') ?? ''; + recordPodspecRead(podspecPath, choice, used, null); + return model; + } catch (e) { + recordPodspecRead(podspecPath, choice, used, e); + throw e; + } +} + +// One JSON line per read in RN_SPM_PODSPEC_READS, when it is set: the +// podspec, its reader and why, what the podspec used of its environment, and +// whether it read. A line that cannot be written does not stop the read. +function recordPodspecRead( + podspecPath /*: string */, + choice /*: PodspecReaderChoice */, + used /*: {env: Array, helpers: Array} */, + error /*: mixed */, +) /*: void */ { + const file = process.env.RN_SPM_PODSPEC_READS; + if (file == null || file === '') return; + const line /*: {[string]: mixed} */ = { + podspec: path.resolve(podspecPath), + reader: choice.reader, + }; + if (choice.reader === 'reduced') line.why = choice.why; + line.forced = choice.forced; + if (choice.reader === 'ruby') line.ruby = choice.ruby; + if (choice.warning != null) line.warning = choice.warning; + line.env = used.env; + line.helpers = used.helpers; + line.ok = error == null; + if (error != null) { + line.error = error instanceof Error ? error.message : String(error); + } + try { + fs.appendFileSync(file, `${JSON.stringify(line)}\n`); } catch { - // best-effort; leave the flattenSubspecs default (false) + // the read itself stands } - return model; } // The installed React Native's version as the macros libraries derive from it. @@ -2830,29 +2772,30 @@ function readRnVersionMacros() /*: {[string]: number} */ { const podspecModels /*: Map */ = new Map(); /** - * readPodspec memoized on the resolved path. `pod ipc spec` costs a process + * readPodspec memoized on the resolved path. A Ruby read costs a process * spawn, and one autolinking run reads the same podspec from several sites * (name resolution, header search paths, scaffolding). The model is shared, so - * callers must treat it as read-only. The key is the resolved path plus the - * sorted `opts.dropSubspecs`. + * callers must treat it as read-only. The key is the resolved path, the + * sorted `opts.dropSubspecs` and the reader. */ function readPodspecCached( podspecPath /*: string */, opts /*:: ?: {dropSubspecs?: ReadonlyArray} */, ) /*: PodspecModel */ { const drop = [...(opts?.dropSubspecs ?? [])].sort(); - const key = [path.resolve(podspecPath), ...drop].join('\0'); + const choice = podspecReader(); + const key = [path.resolve(podspecPath), choice.reader, ...drop].join('\0'); const cached = podspecModels.get(key); if (cached != null) { return cached; } - const model = readPodspec(podspecPath, {dropSubspecs: drop}); + const model = readPodspecWith(choice, podspecPath, {dropSubspecs: drop}); podspecModels.set(key, model); return model; } /** - * The three fields that name a library, read WITHOUT `pod ipc spec`'s process + * The three fields that name a library, read WITHOUT Ruby's process * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * @@ -2904,8 +2847,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on - * every machine (readdir order is unspecified). Skips a crashed run's leftover - * `.spm-scaffold--.podspec` copy. + * every machine (readdir order is unspecified). Skips the + * `.spm-scaffold--.podspec` copy a crashed run of an older rn-xtool + * (which read podspecs with `pod ipc spec`) left. */ function findPodspecs(dir /*: string */) /*: Array */ { try { @@ -2928,7 +2872,6 @@ module.exports = { readPodspec, readPodspecCached, readPodspecNames, - runPodIpcSpec, runPodspecShim, regexPodspec, flattenSubspecs, diff --git a/vendor/rn-spm/spm/spm-types.js b/vendor/rn-spm/spm/spm-types.js index 6ce647d..b9ed2bc 100644 --- a/vendor/rn-spm/spm/spm-types.js +++ b/vendor/rn-spm/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { // Scaffold types — for the `npx react-native spm scaffold` command that // generates a `Package.swift` into `node_modules//` for community RN // libraries that don't ship SPM support. Inputs come from the dep's podspec -// (read via `pod ipc spec --format=json` when CocoaPods is available, or a -// regex fallback). The output Package.swift is treated as "self-managed" by +// (read with Ruby through read-podspec-shim.rb when it is usable, or the +// reduced reader). The output Package.swift is treated as "self-managed" by // the autolinker — see isSelfManagedPackage in generate-spm-autolinking.js. // --------------------------------------------------------------------------- @@ -440,9 +440,11 @@ export type PodspecModel = { frameworks: Array, weakFrameworks: Array, libraries: Array, - // Merged dependency name list. With pod-ipc, includes the deps materialized - // by `install_modules_dependencies(s)` (React-Core, React-Fabric, ...). - // Version constraints stripped — we only need the name to bucket. + // Merged dependency name list. Never includes the React-Core family that + // `install_modules_dependencies(s)` injects under CocoaPods: the shim only + // records the call (see usesInstallModulesDependencies), and the reduced + // reader cannot expand it. Version constraints stripped — we only need the + // name to bucket. dependencies: Array, compilerFlags: Array, // Raw header-search-path entries from `pod_target_xcconfig['HEADER_SEARCH_PATHS']`. @@ -450,7 +452,7 @@ export type PodspecModel = { headerSearchPaths: Array, // Preprocessor defines lifted from pod_target_xcconfig OTHER_CFLAGS (`-D` // tokens) + GCC_PREPROCESSOR_DEFINITIONS (incl. per-config variants). Already - // resolved by `pod ipc` (e.g. `-DWORKLETS_VERSION=#{package['version']}` → + // resolved by the reader (e.g. `-DWORKLETS_VERSION=#{package['version']}` → // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. preprocessorDefines: Array, // File paths or glob patterns the dep declares as bundled resources. @@ -460,16 +462,20 @@ export type PodspecModel = { // a user can spot fields that didn't translate cleanly (unknown env vars, // unrecognized $(...) tokens, etc.). Never throws on parse errors. warnings: Array, - // True when produced by the regex fallback rather than pod-ipc. Used to - // emit a louder banner in the scaffold summary explaining that dependency - // wiring may be incomplete. + // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the + // reduced reader (podspecReader in read-podspec.js says why). + reader: 'ruby' | 'reduced', + // True when produced by the reduced reader rather than Ruby. Used to emit a + // louder banner in the scaffold summary explaining that dependency wiring + // may be incomplete. partial: boolean, - // True when the podspec source calls `install_modules_dependencies(s)` — - // RN's Podfile-side helper that injects the React-Core family. We strip that - // helper before evaluating the spec (and the regex parser can't expand it), - // so React-Core never surfaces in `dependencies`. The scaffolder treats this - // flag as an implicit React-core dependency (a plain ObjC module using the - // helper has no `codegenConfig` to key off). + // True when the podspec calls `install_modules_dependencies(s)` — RN's + // Podfile-side helper that injects the React-Core family. With Ruby, when + // the run called it (the shim records the call and adds nothing); with the + // reduced reader, when the source names it. React-Core never surfaces in + // `dependencies`, so the scaffolder treats this flag as an implicit + // React-core dependency (a plain ObjC module using the helper has no + // `codegenConfig` to key off). usesInstallModulesDependencies: boolean, // The `source_files`/`exclude_files` values the regex fallback could not // evaluate (a method call, an unknown local): the scaffolder refuses the @@ -489,7 +495,7 @@ export type SpmScaffoldSpec = { // Header search paths resolved to dep-root-relative form. Each entry // becomes `.headerSearchPath("")` in cSettings + cxxSettings. headerSearchPaths: Array, - // Preprocessor defines (resolved by pod ipc) — emitted as `.define(...)` in + // Preprocessor defines (resolved by the reader) — emitted as `.define(...)` in // cSettings + cxxSettings, honoring any per-config scope. preprocessorDefines: Array, // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + From 1d3f7b31b87cbb9709e8dd833230651c02a3fe7c Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 14:53:57 -0600 Subject: [PATCH 11/53] fix: punctuate the podspec reader's remedy --- patches/react-native+0.88.0.patch | 4 ++-- patches/react-native+0.88.1.patch | 4 ++-- tests/podspecReader.test.ts | 2 +- vendor/rn-spm/spm/read-podspec.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index fe7d4df..687b764 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..7f1df66 100644 +index 8fcf04b..14af29e 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -898,7 +898,7 @@ index 8fcf04b..7f1df66 100644 + const message = String(model.error.message); + throw new PodspecReadError( + SHIM_GAP_KINDS.includes(kind) -+ ? `${message} ${PODSPEC_READ_REMEDY}` ++ ? `${message}. ${PODSPEC_READ_REMEDY}` + : message, + kind, + ); diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index fe7d4df..687b764 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..7f1df66 100644 +index 8fcf04b..14af29e 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -898,7 +898,7 @@ index 8fcf04b..7f1df66 100644 + const message = String(model.error.message); + throw new PodspecReadError( + SHIM_GAP_KINDS.includes(kind) -+ ? `${message} ${PODSPEC_READ_REMEDY}` ++ ? `${message}. ${PODSPEC_READ_REMEDY}` + : message, + kind, + ); diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index dbff1f9..3b87d14 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -204,7 +204,7 @@ describe.skipIf(needsRuby !== "")(`running the podspec shim${needsRuby}`, () => const e = thrown(() => runPodspecShim(gap)); expect(isPodspecReadError(e)).toBe(true); expect(e.kind).toBe("method"); - expect(e.message).toBe(`${shimMessage(gap)} ${REMEDY}`); + expect(e.message).toBe(`${shimMessage(gap)}. ${REMEDY}`); const raised = library(spec(' raise "the podspec stops here"')); const r = thrown(() => runPodspecShim(raised)); expect(r.kind).toBe("raised"); diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 7aa2b2c..48216e7 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -289,7 +289,7 @@ function runPodspecShim( const message = String(model.error.message); throw new PodspecReadError( SHIM_GAP_KINDS.includes(kind) - ? `${message} ${PODSPEC_READ_REMEDY}` + ? `${message}. ${PODSPEC_READ_REMEDY}` : message, kind, ); From 1297fb9105bca274c5ce563630fbcf1b82af311f Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 15:12:04 -0600 Subject: [PATCH 12/53] test: complete the gesture-handler 2.32.0 fixture --- .../scripts/gesture_handler_utils.rb | 31 +++++++++++++++++++ tests/tarballs.json | 5 +++ 2 files changed, 36 insertions(+) create mode 100644 tests/fixtures/podspecs/RNGestureHandler-2.32.0/scripts/gesture_handler_utils.rb diff --git a/tests/fixtures/podspecs/RNGestureHandler-2.32.0/scripts/gesture_handler_utils.rb b/tests/fixtures/podspecs/RNGestureHandler-2.32.0/scripts/gesture_handler_utils.rb new file mode 100644 index 0000000..cfecb9f --- /dev/null +++ b/tests/fixtures/podspecs/RNGestureHandler-2.32.0/scripts/gesture_handler_utils.rb @@ -0,0 +1,31 @@ +module GestureHandlerUtils + module_function + + def try_to_parse_react_native_package_json(react_native_dir) + react_native_package_json_path = File.join(react_native_dir, 'package.json') + + if !File.exist?(react_native_package_json_path) + return nil + end + + return JSON.parse(File.read(react_native_package_json_path)) + end + + def get_react_native_minor_version() + react_native_dir = File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`) + react_native_json = try_to_parse_react_native_package_json(react_native_dir) + + if react_native_json == nil + node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"] + if node_modules_dir != nil + react_native_json = try_to_parse_react_native_package_json(File.join(node_modules_dir, 'react-native')) + end + end + + if react_native_json == nil + raise '[react-native-gesture-handler] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="" && pod install`.' + end + + return react_native_json['version'].split('.')[1].to_i + end +end diff --git a/tests/tarballs.json b/tests/tarballs.json index 419a91f..4c49fa3 100644 --- a/tests/tarballs.json +++ b/tests/tarballs.json @@ -73,5 +73,10 @@ "spec": "dnssd-advertise@1.1.6", "file": "dnssd-advertise-1.1.6.tgz", "integrity": "sha512-Ndrrf6BMPalkQPd/zubL+4YghH2J9NspapQ09uDXwYbvOPkP0oaqf5CkcwJ0b50kS2O3ul6yVu+jz+RY62Cejg==" + }, + { + "spec": "react-native-gesture-handler@2.32.0", + "file": "react-native-gesture-handler-2.32.0.tgz", + "integrity": "sha512-uYIMOKlKENORq2SABE+jIjbPU+h5I/sQKcq2v16zRq848nwEp1fWRVwML4QWqijc8UcXJC25o54S8GQd4Mf2OA==" } ] From 5eb4e81a9e1c6d2709d026402a79955089130e1e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 15:12:10 -0600 Subject: [PATCH 13/53] feat: merge ios attributes of the shim's model --- patches/react-native+0.88.0.patch | 286 +++++++++++++++----- patches/react-native+0.88.1.patch | 286 +++++++++++++++----- tests/podspecReader.test.ts | 194 ++++++++++++- tests/rn-scaffolder.test.ts | 20 +- tests/support/rnScaffold.ts | 29 ++ vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 134 ++++++++- vendor/rn-spm/spm/scaffold-package-swift.js | 7 + vendor/rn-spm/spm/spm-types.js | 3 + 9 files changed, 810 insertions(+), 151 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 687b764..2c85986 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..14af29e 100644 +index 8fcf04b..00d53dc 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -716,7 +716,7 @@ index 8fcf04b..14af29e 100644 + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; -+ } + } + let detail; + if (stderr.length > 0) { + detail = stderr[0]; @@ -750,7 +750,7 @@ index 8fcf04b..14af29e 100644 + forced: true, + warning: null, + }; - } ++ } + // An empty value counts as unset. + const warning = + value != null && value !== '' @@ -1035,10 +1035,8 @@ index 8fcf04b..14af29e 100644 + return h; + } + return v; - } - --function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { -- if (patchedPath == null) return; ++} ++ +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1117,7 +1115,7 @@ index 8fcf04b..14af29e 100644 + } + } + return null; -+} + } +const PLATFORM_SCOPES /*: Set */ = new Set([ + 'ios', + 'osx', @@ -1126,7 +1124,9 @@ index 8fcf04b..14af29e 100644 + 'visionos', + 'watchos', +]); -+ + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// Tokens of one Ruby expression. A double-quoted string keeps its parts: +// literal text and the source of each `#{...}`. +function tokenizeRubyExpr(src /*: string */) /*: Array */ { @@ -2674,7 +2674,7 @@ index 8fcf04b..14af29e 100644 }; } -@@ -423,6 +2074,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2074,140 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2733,7 +2733,89 @@ index 8fcf04b..14af29e 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2141,16 @@ function shellTokenize(value /*: string */) /*: Array */ { + ++// The attributes CocoaPods' DSL declares with an Array container: for an iOS ++// target its consumer appends the `ios` value to the spec's. ++const ARRAY_ATTRIBUTES /*: Set */ = new Set([ ++ 'compiler_flags', ++ 'exclude_files', ++ 'frameworks', ++ 'libraries', ++ 'preserve_paths', ++ 'private_header_files', ++ 'project_header_files', ++ 'public_header_files', ++ 'resources', ++ 'source_files', ++ 'vendored_frameworks', ++ 'vendored_libraries', ++ 'weak_frameworks', ++]); ++ ++// What a CocoaPods build applies and the scaffold does not: each is named in ++// a warning when the spec or a selected subspec sets it. ++const UNAPPLIED_KEYS /*: Array */ = [ ++ 'script_phases', ++ 'prepare_command', ++ 'info_plist', ++ 'module_map', ++]; ++ ++const isHash = (v /*: mixed */) /*: boolean */ => ++ v != null && typeof v === 'object' && !Array.isArray(v); ++ ++/** ++ * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for ++ * an iOS target: each value under its `ios` merged over the spec's. An ++ * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string ++ * read as a one-element array); two hashes merge key by key, two strings ++ * under one key joined by one space; anything else is the platform's value. ++ * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. ++ * The reduced reader's model has no `ios`: it is returned as it is. ++ */ ++function mergeIos(layer /*: mixed */) /*: mixed */ { ++ // $FlowFixMe[incompatible-use] layer narrowed by isHash ++ if (!isHash(layer) || !isHash(layer.ios)) return layer; ++ // $FlowFixMe[incompatible-use] layer narrowed by isHash ++ const spec /*: {[string]: mixed} */ = layer; ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const ios /*: {[string]: mixed} */ = spec.ios; ++ const out /*: {[string]: mixed} */ = {...spec}; ++ for (const key of Object.keys(ios)) { ++ const own = spec[key]; ++ const platform = ios[key]; ++ if (platform == null) continue; ++ if (own == null) { ++ out[key] = platform; ++ } else if (ARRAY_ATTRIBUTES.has(key)) { ++ out[key] = [ ++ ...(Array.isArray(own) ? own : [own]), ++ ...(Array.isArray(platform) ? platform : [platform]), ++ ]; ++ } else if (isHash(own) && isHash(platform)) { ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const ownHash /*: {[string]: mixed} */ = own; ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const platformHash /*: {[string]: mixed} */ = platform; ++ const merged /*: {[string]: mixed} */ = {...ownHash}; ++ for (const k of Object.keys(platformHash)) { ++ const a = ownHash[k]; ++ const b = platformHash[k]; ++ merged[k] = ++ typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; ++ } ++ out[key] = merged; ++ } else { ++ out[key] = platform; ++ } ++ } ++ return out; ++} ++ + /** + * Merges a podspec's default subspecs (or all subspecs when no defaults are + * declared) into a single logical view. RN libraries use subspecs for +@@ -438,8 +2219,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2751,7 +2833,7 @@ index 8fcf04b..14af29e 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2162,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2240,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2771,18 +2853,31 @@ index 8fcf04b..14af29e 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2180,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2258,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } +- const layers = [rawSpec, ...selected]; + selected = selected.filter( + // $FlowFixMe[prop-missing] dynamic shape + s => !(s != null && typeof s.name === 'string' && dropped.has(s.name)), + ); - const layers = [rawSpec, ...selected]; ++ // Each layer as CocoaPods reads it for iOS, before any reader below. ++ const layers = [rawSpec, ...selected].map(mergeIos); ++ // $FlowFixMe[incompatible-type] mergeIos keeps the spec's shape ++ const spec /*: RawSpec */ = layers[0]; ++ for (const key of UNAPPLIED_KEYS) { ++ // $FlowFixMe[incompatible-use] layer narrowed from `mixed` ++ if (layers.some(l => isHash(l) && l[key] != null)) { ++ warnings.push( ++ `The podspec sets ${key}, which a CocoaPods build applies and rn-xtool's scaffold does not.`, ++ ); ++ } ++ } function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2202,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + const out /*: Array */ = []; +@@ -482,11 +2291,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2800,7 +2895,13 @@ index 8fcf04b..14af29e 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2275,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + // $FlowFixMe[incompatible-use] dynamic shape +- const value = rawSpec[key]; ++ const value = spec[key]; + return typeof value === 'string' && value.length > 0 ? value : null; + } + +@@ -544,6 +2364,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2821,7 +2922,7 @@ index 8fcf04b..14af29e 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2299,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2388,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2846,7 +2947,7 @@ index 8fcf04b..14af29e 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2332,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2421,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2867,7 +2968,7 @@ index 8fcf04b..14af29e 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2402,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2491,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -2911,6 +3012,21 @@ index 8fcf04b..14af29e 100644 + return Array.from(new Set(out)); + } + ++ // The SwiftPM packages the podspec's run asked for with ++ // `spm_dependency(spec, url:, requirement:, products:)`, as the shim ++ // recorded them. ++ function spmDependencies() /*: Array<{url: string, products: Array}> */ { ++ // $FlowFixMe[prop-missing] the shim's dynamic shape ++ const recorded = rawSpec.__rn_xtool__?.spm_dependencies; ++ if (!Array.isArray(recorded)) return []; ++ return recorded.filter(isHash).map(d => ({ ++ url: String(d.url), ++ products: (Array.isArray(d.products) ? d.products : [d.products]).filter( ++ p => typeof p === 'string', ++ ), ++ })); ++ } ++ + // Each selected subspec's own dependencies, by subspec name. + function subspecDependencies() /*: {[string]: Array} */ { + const out /*: {[string]: Array} */ = {}; @@ -3012,7 +3128,13 @@ index 8fcf04b..14af29e 100644 } } return out; -@@ -677,6 +2527,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + } + + // $FlowFixMe[prop-missing] dynamic shape +- const reqArc /*: unknown */ = rawSpec.requires_arc; ++ const reqArc /*: unknown */ = spec.requires_arc; + const requiresArc = + reqArc === false || (Array.isArray(reqArc) && reqArc.length === 0) ? false : true; // RN ecosystem default @@ -3033,7 +3155,7 @@ index 8fcf04b..14af29e 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2557,239 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2661,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3086,6 +3208,7 @@ index 8fcf04b..14af29e 100644 + unresolvedSources: Array.isArray(rawSpec.__unresolved__) + ? rawSpec.__unresolved__ + : [], ++ spmDependencies: spmDependencies(), }; } @@ -3116,6 +3239,28 @@ index 8fcf04b..14af29e 100644 + 'the library a Package.swift of its own.' + ); +} ++ ++/** ++ * Why the library cannot be scaffolded for the SwiftPM packages its podspec ++ * declares with `spm_dependency`, or null: a CocoaPods build resolves them, ++ * and a scaffold without them would not link. ++ */ ++function spmDependencyReason( ++ podspecPath /*: string */, ++ model /*: PodspecModel */, ++) /*: ?string */ { ++ const list = model.spmDependencies ?? []; ++ if (list.length === 0) return null; ++ return ( ++ `${podspecPath}: uses ` + ++ list ++ .map( ++ d => `spm_dependency(url: ${d.url}, products: ${d.products.join(', ')})`, ++ ) ++ .join(', ') + ++ ', which rn-xtool does not map yet' ++ ); ++} + // --------------------------------------------------------------------------- // Top-level entry @@ -3302,7 +3447,7 @@ index 8fcf04b..14af29e 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2817,13 @@ function readPodspecNames( +@@ -794,12 +2944,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3317,7 +3462,7 @@ index 8fcf04b..14af29e 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2841,9 @@ function readPodspecNames( +@@ -817,8 +2968,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3329,7 +3474,7 @@ index 8fcf04b..14af29e 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2859,15 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +2986,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, @@ -3344,13 +3489,14 @@ index 8fcf04b..14af29e 100644 + runPodspecShim, regexPodspec, flattenSubspecs, ++ spmDependencyReason, + unresolvedSourcesReason, }; diff --git a/node_modules/react-native/scripts/spm/scaffold-package-swift.js b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -index cf7e587..f105e49 100644 +index cf7e587..0986d43 100644 --- a/node_modules/react-native/scripts/spm/scaffold-package-swift.js +++ b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -@@ -45,7 +45,11 @@ const { +@@ -45,7 +45,12 @@ const { } = require('./expand-spm-dependencies'); const {expandSpmSourceGlobs} = require('./generate-spm-autolinking'); const {MIN_IOS_VERSION_SUPPORTED} = require('./ios-deployment-target'); @@ -3358,12 +3504,13 @@ index cf7e587..f105e49 100644 +const { + findPodspecs, + readPodspecCached, ++ spmDependencyReason, + unresolvedSourcesReason, +} = require('./read-podspec'); const { REACT_CODEGEN_PACKAGE_NAME, REACT_CODEGEN_PRODUCTS, -@@ -54,6 +58,7 @@ const { +@@ -54,6 +59,7 @@ const { SCAFFOLDER_MARKER, makeLogger, remotePackageConfig, @@ -3371,7 +3518,7 @@ index cf7e587..f105e49 100644 } = require('./spm-utils'); const {readSwiftpmConfig, writeSwiftpmName} = require('./swiftpm-config'); const fs = require('node:fs'); -@@ -113,6 +118,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); +@@ -113,6 +119,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); const SCAFFOLDER_VERSION = 20; const SCAFFOLDER_VERSION_LINE_RE = /^\/\/ AUTO-SCAFFOLDED-VERSION: (\d+)$/m; @@ -3653,7 +3800,7 @@ index cf7e587..f105e49 100644 const AUTOGEN_MARKER = '// AUTO-GENERATED by scripts/generate-spm-autolinking.js'; -@@ -145,6 +425,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm +@@ -145,6 +426,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm #endif `; @@ -4027,7 +4174,7 @@ index cf7e587..f105e49 100644 // Names of deps the scaffolder always refuses to touch — `react-native` // itself is handled by the xcframework subpackage, never as an autolinked // target. -@@ -167,10 +814,27 @@ const REACT_CORE_DEP_PREFIXES = [ +@@ -167,10 +815,27 @@ const REACT_CORE_DEP_PREFIXES = [ 'DoubleConversion', 'Yoga', 'hermes-engine', @@ -4056,7 +4203,7 @@ index cf7e587..f105e49 100644 } // True when the dep ships a `codegenConfig` in package.json — RN's standard -@@ -248,6 +912,12 @@ function translatePodspecToSpmTarget( +@@ -248,6 +913,12 @@ function translatePodspecToSpmTarget( // npm name → resolved Swift name for every autolinked dep, so a sibling // reference honors that sibling's `spm.name` instead of re-deriving it. swiftNameByNpm /*: Map */ = new Map(), @@ -4069,7 +4216,7 @@ index cf7e587..f105e49 100644 ) /*: SpmScaffoldSpec */ { const warnings = [...model.warnings]; -@@ -322,46 +992,92 @@ function translatePodspecToSpmTarget( +@@ -322,46 +993,92 @@ function translatePodspecToSpmTarget( } } @@ -4190,7 +4337,7 @@ index cf7e587..f105e49 100644 } } -@@ -427,15 +1143,55 @@ function translatePodspecToSpmTarget( +@@ -427,15 +1144,55 @@ function translatePodspecToSpmTarget( f => f !== SCAFFOLD_PREFIX_HEADER && f !== 'Package.swift' && @@ -4248,7 +4395,7 @@ index cf7e587..f105e49 100644 try { for (const f of expandSpmSourceGlobs(dep.root, model.publicHeaderFiles)) { if (/\.(h|hh|hpp)$/i.test(f)) headerFiles.push(f); -@@ -497,6 +1253,51 @@ function translatePodspecToSpmTarget( +@@ -497,6 +1254,51 @@ function translatePodspecToSpmTarget( } } let namespacedShimHeaders /*: Array */ = []; @@ -4300,7 +4447,7 @@ index cf7e587..f105e49 100644 if (publicHeadersPath == null) { // Root-level podspecs (`s.source_files = "*.{h,m,mm}"`) keep their // headers in the package root. CocoaPods exposes them to dependents as -@@ -518,6 +1319,101 @@ function translatePodspecToSpmTarget( +@@ -518,6 +1320,101 @@ function translatePodspecToSpmTarget( ); } @@ -4402,7 +4549,7 @@ index cf7e587..f105e49 100644 const siblingSwiftNames /*: {[npmName: string]: string} */ = {}; for (const npmName of siblingNames) { const resolved = swiftNameByNpm.get(npmName); -@@ -526,21 +1422,201 @@ function translatePodspecToSpmTarget( +@@ -526,21 +1423,201 @@ function translatePodspecToSpmTarget( } } @@ -4606,7 +4753,7 @@ index cf7e587..f105e49 100644 warnings, }; } -@@ -565,6 +1641,9 @@ type EmitContext = { +@@ -565,6 +1642,9 @@ type EmitContext = { // Relative path to the app's local xcframeworks package // (/build/xcframeworks). Only referenced when remote == null. localXcfwPackageDir?: ?string, @@ -4616,7 +4763,7 @@ index cf7e587..f105e49 100644 iosDeploymentTarget?: ?string, }; */ -@@ -629,10 +1708,25 @@ function emitScaffoldedPackageSwift( +@@ -629,10 +1709,25 @@ function emitScaffoldedPackageSwift( const prefixFlag = spec.needsObjCPrefix ? `.unsafeFlags(["-include", "${SCAFFOLD_PREFIX_HEADER}"])` : ''; @@ -4643,7 +4790,7 @@ index cf7e587..f105e49 100644 ...(customFlagsCxx.length > 0 ? [`.unsafeFlags([${customFlagsCxx.join(', ')}])`] : []), -@@ -723,6 +1817,32 @@ function emitScaffoldedPackageSwift( +@@ -723,6 +1818,32 @@ function emitScaffoldedPackageSwift( `.product(name: "${swiftSibling}", package: "${swiftSibling}")`, ); } @@ -4676,7 +4823,7 @@ index cf7e587..f105e49 100644 // sources: emit only when the podspec declared them. If empty (regex-fallback // podspec), no `sources:`/`exclude:` is emitted and SPM auto-scans the target -@@ -740,6 +1860,11 @@ function emitScaffoldedPackageSwift( +@@ -740,6 +1861,11 @@ function emitScaffoldedPackageSwift( ? `\n publicHeadersPath: "${spec.publicHeadersPath}",` : ''; @@ -4688,7 +4835,7 @@ index cf7e587..f105e49 100644 const resourcesLine = spec.resources.length > 0 ? `\n resources: [${spec.resources.map(r => `.copy("${r}")`).join(', ')}],` -@@ -755,9 +1880,71 @@ function emitScaffoldedPackageSwift( +@@ -755,9 +1881,71 @@ function emitScaffoldedPackageSwift( ? `\n dependencies: [${targetDeps.join(', ')}],` : ''; @@ -4762,7 +4909,7 @@ index cf7e587..f105e49 100644 // Edit the contents below if needed and re-run \`npx patch-package \` // to persist across \`npm install\`. To regenerate from the podspec, remove // this file (or just this marker) and re-run \`npx react-native spm scaffold\`. -@@ -768,7 +1955,7 @@ ${SCAFFOLDER_MARKER} +@@ -768,7 +1956,7 @@ ${SCAFFOLDER_MARKER} // (dropping the file) anyway. import PackageDescription @@ -4771,7 +4918,7 @@ index cf7e587..f105e49 100644 let package = Package( name: "${spec.swiftName}", platforms: [.iOS("${iosDeploymentTarget}")], -@@ -778,13 +1965,13 @@ let package = Package( +@@ -778,13 +1966,13 @@ let package = Package( ${packageDepsBlock} targets: [ .target( name: "${spec.swiftName}",${targetDepsLine} @@ -4788,7 +4935,7 @@ index cf7e587..f105e49 100644 ) `; } -@@ -844,6 +2031,61 @@ function reportSwiftName( +@@ -844,6 +2032,61 @@ function reportSwiftName( } } @@ -4850,7 +4997,7 @@ index cf7e587..f105e49 100644 // --------------------------------------------------------------------------- // Per-dep orchestrator // --------------------------------------------------------------------------- -@@ -953,7 +2195,11 @@ function scaffoldPackageSwiftForDep( +@@ -953,7 +2196,11 @@ function scaffoldPackageSwiftForDep( // regenerating existing files; --force is not needed here. const vMatch = existing.match(SCAFFOLDER_VERSION_LINE_RE); const existingVersion = vMatch != null ? parseInt(vMatch[1], 10) : 1; @@ -4863,7 +5010,7 @@ index cf7e587..f105e49 100644 if (!ctx.force && !versionStale) { // Slot label change is the other auto-regen trigger — bumps SPM's // manifest hash so the cache-slot path gets re-resolved. -@@ -970,7 +2216,7 @@ function scaffoldPackageSwiftForDep( +@@ -970,7 +2217,7 @@ function scaffoldPackageSwiftForDep( } if (versionStale) { log( @@ -4872,7 +5019,7 @@ index cf7e587..f105e49 100644 ); } // Fall through: regenerate (force, slot changed, or version bumped). -@@ -998,9 +2244,44 @@ function scaffoldPackageSwiftForDep( +@@ -998,9 +2245,44 @@ function scaffoldPackageSwiftForDep( }; } @@ -4917,7 +5064,7 @@ index cf7e587..f105e49 100644 } catch (e) { return { depName, -@@ -1008,39 +2289,27 @@ function scaffoldPackageSwiftForDep( +@@ -1008,39 +2290,33 @@ function scaffoldPackageSwiftForDep( reason: `Podspec read failed: ${e.message}`, }; } @@ -4926,6 +5073,12 @@ index cf7e587..f105e49 100644 + const unresolved = unresolvedSourcesReason(podspecPath, model); + if (unresolved != null) { + return {depName, status: 'error', reason: unresolved}; ++ } ++ // A SwiftPM package the podspec asks for (`spm_dependency`): the target ++ // would not link without it. ++ const spmDependency = spmDependencyReason(podspecPath, model); ++ if (spmDependency != null) { ++ return {depName, status: 'error', reason: spmDependency}; + } const spec = translatePodspecToSpmTarget( @@ -4972,7 +5125,7 @@ index cf7e587..f105e49 100644 // Relative paths into the app, embedded in the scaffolded Package.swift. // -@@ -1072,6 +2341,7 @@ function scaffoldPackageSwiftForDep( +@@ -1072,6 +2348,7 @@ function scaffoldPackageSwiftForDep( iosDeploymentTarget: ctx.iosDeploymentTarget, codegenPackageDir: relFromManifest('build', 'generated', 'ios'), localXcfwPackageDir: relFromManifest('build', 'xcframeworks'), @@ -4980,7 +5133,7 @@ index cf7e587..f105e49 100644 }); // Distinguish "first-time scaffold" (no file at all) from "regenerate" -@@ -1081,15 +2351,36 @@ function scaffoldPackageSwiftForDep( +@@ -1081,15 +2358,36 @@ function scaffoldPackageSwiftForDep( // regens are silent because we're maintaining a file we already own. const previouslyExisted = fs.existsSync(pkgSwiftPath); @@ -5020,7 +5173,7 @@ index cf7e587..f105e49 100644 ); } // Mirror root-level headers into the generated include// shim -@@ -1099,18 +2390,96 @@ function scaffoldPackageSwiftForDep( +@@ -1099,18 +2397,96 @@ function scaffoldPackageSwiftForDep( const shimDir = path.join(dep.root, 'include', spec.swiftName); fs.mkdirSync(shimDir, {recursive: true}); for (const header of spec.namespacedShimHeaders) { @@ -5121,7 +5274,7 @@ index cf7e587..f105e49 100644 reportSwiftName(dep, spec.swiftName, model); // Migration: record a name we derived from the podspec, so the library can -@@ -1120,6 +2489,12 @@ function scaffoldPackageSwiftForDep( +@@ -1120,6 +2496,12 @@ function scaffoldPackageSwiftForDep( dep.swiftNameSource === 'podspec' ? writeSwiftpmName(dep.root, spec.swiftName, {dryRun: ctx.dryRun}) : undefined; @@ -5134,7 +5287,7 @@ index cf7e587..f105e49 100644 return { depName, -@@ -1128,6 +2503,7 @@ function scaffoldPackageSwiftForDep( +@@ -1128,6 +2510,7 @@ function scaffoldPackageSwiftForDep( warnings: spec.warnings, previouslyExisted, swiftpmName, @@ -5142,7 +5295,7 @@ index cf7e587..f105e49 100644 }; } -@@ -1141,7 +2517,7 @@ function collectAutolinkedDeps( +@@ -1141,7 +2524,7 @@ function collectAutolinkedDeps( opts /*: { autolinkingJsonPath: string, remote: ?{url: string, version: string, identity: string}, @@ -5151,7 +5304,7 @@ index cf7e587..f105e49 100644 } */, ) /*: ?Array */ { const {autolinkingJsonPath, remote, onSkipped} = opts; -@@ -1162,7 +2538,7 @@ function collectAutolinkedDeps( +@@ -1162,7 +2545,7 @@ function collectAutolinkedDeps( const root = raw.root; const ios = raw.platforms?.ios; if (typeof root !== 'string' || ios == null) { @@ -5160,7 +5313,7 @@ index cf7e587..f105e49 100644 continue; } // $FlowFixMe[incompatible-type] `ios` shape is runtime-validated above -@@ -1294,6 +2670,11 @@ type ScaffoldAllOptions = { +@@ -1294,6 +2677,11 @@ type ScaffoldAllOptions = { // confirmation prompt for first-time scaffolds. Skipped deps still // appear in the returned results array with status='skipped-opt-out'. skipDeps?: ReadonlyArray, @@ -5172,7 +5325,7 @@ index cf7e587..f105e49 100644 }; */ -@@ -1323,6 +2704,17 @@ function scaffoldAll( +@@ -1323,6 +2711,17 @@ function scaffoldAll( // scaffolded here — leaving `react-native spm scaffold` unable to clear the // autolinker's missing-manifest error. const results /*: Array */ = []; @@ -5190,7 +5343,7 @@ index cf7e587..f105e49 100644 // Outside collectAutolinkedDeps' own try: a malformed remote config // (RemoteVersionError) is a misconfiguration to surface, not an expansion // failure to degrade past. -@@ -1330,24 +2722,23 @@ function scaffoldAll( +@@ -1330,24 +2729,23 @@ function scaffoldAll( const allDeps = collectAutolinkedDeps({ autolinkingJsonPath, remote, @@ -5226,7 +5379,7 @@ index cf7e587..f105e49 100644 for (const dep of allDeps) { const podspecPath = dep.platforms?.ios?.podspecPath; if (typeof podspecPath === 'string' && podspecPath.length > 0) { -@@ -1386,6 +2777,9 @@ function scaffoldAll( +@@ -1386,6 +2784,9 @@ function scaffoldAll( const skipSet /*: Set */ = new Set(opts.skipDeps ?? []); for (const dep of allDeps) { @@ -5236,7 +5389,7 @@ index cf7e587..f105e49 100644 if (skipSet.has(dep.name)) { results.push({ depName: dep.name, -@@ -1404,6 +2798,9 @@ function scaffoldAll( +@@ -1404,6 +2805,9 @@ function scaffoldAll( } module.exports = { @@ -5247,7 +5400,7 @@ index cf7e587..f105e49 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..b9ed2bc 100644 +index a89142f..4493621 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5285,7 +5438,7 @@ index a89142f..b9ed2bc 100644 // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. preprocessorDefines: Array, // File paths or glob patterns the dep declares as bundled resources. -@@ -460,17 +462,25 @@ export type PodspecModel = { +@@ -460,17 +462,28 @@ export type PodspecModel = { // a user can spot fields that didn't translate cleanly (unknown env vars, // unrecognized $(...) tokens, etc.). Never throws on parse errors. warnings: Array, @@ -5317,10 +5470,13 @@ index a89142f..b9ed2bc 100644 + // evaluate (a method call, an unknown local): the scaffolder refuses the + // library rather than build it from a partial source list. + unresolvedSources?: Array<{field: string, expr: string, why: string}>, ++ // The SwiftPM packages the podspec's run asked for with `spm_dependency` ++ // (Ruby only): the scaffolder refuses the library (spmDependencyReason). ++ spmDependencies?: Array<{url: string, products: Array}>, }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -485,7 +495,7 @@ export type SpmScaffoldSpec = { +@@ -485,7 +498,7 @@ export type SpmScaffoldSpec = { // Header search paths resolved to dep-root-relative form. Each entry // becomes `.headerSearchPath("")` in cSettings + cxxSettings. headerSearchPaths: Array, @@ -5329,7 +5485,7 @@ index a89142f..b9ed2bc 100644 // cSettings + cxxSettings, honoring any per-config scope. preprocessorDefines: Array, // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + -@@ -502,6 +512,9 @@ export type SpmScaffoldSpec = { +@@ -502,6 +515,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5339,7 +5495,7 @@ index a89142f..b9ed2bc 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +552,9 @@ export type ScaffoldResult = +@@ -539,6 +555,9 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 687b764..2c85986 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..14af29e 100644 +index 8fcf04b..00d53dc 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -716,7 +716,7 @@ index 8fcf04b..14af29e 100644 + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; -+ } + } + let detail; + if (stderr.length > 0) { + detail = stderr[0]; @@ -750,7 +750,7 @@ index 8fcf04b..14af29e 100644 + forced: true, + warning: null, + }; - } ++ } + // An empty value counts as unset. + const warning = + value != null && value !== '' @@ -1035,10 +1035,8 @@ index 8fcf04b..14af29e 100644 + return h; + } + return v; - } - --function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { -- if (patchedPath == null) return; ++} ++ +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1117,7 +1115,7 @@ index 8fcf04b..14af29e 100644 + } + } + return null; -+} + } +const PLATFORM_SCOPES /*: Set */ = new Set([ + 'ios', + 'osx', @@ -1126,7 +1124,9 @@ index 8fcf04b..14af29e 100644 + 'visionos', + 'watchos', +]); -+ + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// Tokens of one Ruby expression. A double-quoted string keeps its parts: +// literal text and the source of each `#{...}`. +function tokenizeRubyExpr(src /*: string */) /*: Array */ { @@ -2674,7 +2674,7 @@ index 8fcf04b..14af29e 100644 }; } -@@ -423,6 +2074,58 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2074,140 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2733,7 +2733,89 @@ index 8fcf04b..14af29e 100644 // --------------------------------------------------------------------------- // Subspec flattening // --------------------------------------------------------------------------- -@@ -438,8 +2141,16 @@ function shellTokenize(value /*: string */) /*: Array */ { + ++// The attributes CocoaPods' DSL declares with an Array container: for an iOS ++// target its consumer appends the `ios` value to the spec's. ++const ARRAY_ATTRIBUTES /*: Set */ = new Set([ ++ 'compiler_flags', ++ 'exclude_files', ++ 'frameworks', ++ 'libraries', ++ 'preserve_paths', ++ 'private_header_files', ++ 'project_header_files', ++ 'public_header_files', ++ 'resources', ++ 'source_files', ++ 'vendored_frameworks', ++ 'vendored_libraries', ++ 'weak_frameworks', ++]); ++ ++// What a CocoaPods build applies and the scaffold does not: each is named in ++// a warning when the spec or a selected subspec sets it. ++const UNAPPLIED_KEYS /*: Array */ = [ ++ 'script_phases', ++ 'prepare_command', ++ 'info_plist', ++ 'module_map', ++]; ++ ++const isHash = (v /*: mixed */) /*: boolean */ => ++ v != null && typeof v === 'object' && !Array.isArray(v); ++ ++/** ++ * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for ++ * an iOS target: each value under its `ios` merged over the spec's. An ++ * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string ++ * read as a one-element array); two hashes merge key by key, two strings ++ * under one key joined by one space; anything else is the platform's value. ++ * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. ++ * The reduced reader's model has no `ios`: it is returned as it is. ++ */ ++function mergeIos(layer /*: mixed */) /*: mixed */ { ++ // $FlowFixMe[incompatible-use] layer narrowed by isHash ++ if (!isHash(layer) || !isHash(layer.ios)) return layer; ++ // $FlowFixMe[incompatible-use] layer narrowed by isHash ++ const spec /*: {[string]: mixed} */ = layer; ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const ios /*: {[string]: mixed} */ = spec.ios; ++ const out /*: {[string]: mixed} */ = {...spec}; ++ for (const key of Object.keys(ios)) { ++ const own = spec[key]; ++ const platform = ios[key]; ++ if (platform == null) continue; ++ if (own == null) { ++ out[key] = platform; ++ } else if (ARRAY_ATTRIBUTES.has(key)) { ++ out[key] = [ ++ ...(Array.isArray(own) ? own : [own]), ++ ...(Array.isArray(platform) ? platform : [platform]), ++ ]; ++ } else if (isHash(own) && isHash(platform)) { ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const ownHash /*: {[string]: mixed} */ = own; ++ // $FlowFixMe[incompatible-type] narrowed by isHash ++ const platformHash /*: {[string]: mixed} */ = platform; ++ const merged /*: {[string]: mixed} */ = {...ownHash}; ++ for (const k of Object.keys(platformHash)) { ++ const a = ownHash[k]; ++ const b = platformHash[k]; ++ merged[k] = ++ typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; ++ } ++ out[key] = merged; ++ } else { ++ out[key] = platform; ++ } ++ } ++ return out; ++} ++ + /** + * Merges a podspec's default subspecs (or all subspecs when no defaults are + * declared) into a single logical view. RN libraries use subspecs for +@@ -438,8 +2219,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2751,7 +2833,7 @@ index 8fcf04b..14af29e 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2162,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2240,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2771,18 +2853,31 @@ index 8fcf04b..14af29e 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,6 +2180,10 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2258,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } +- const layers = [rawSpec, ...selected]; + selected = selected.filter( + // $FlowFixMe[prop-missing] dynamic shape + s => !(s != null && typeof s.name === 'string' && dropped.has(s.name)), + ); - const layers = [rawSpec, ...selected]; ++ // Each layer as CocoaPods reads it for iOS, before any reader below. ++ const layers = [rawSpec, ...selected].map(mergeIos); ++ // $FlowFixMe[incompatible-type] mergeIos keeps the spec's shape ++ const spec /*: RawSpec */ = layers[0]; ++ for (const key of UNAPPLIED_KEYS) { ++ // $FlowFixMe[incompatible-use] layer narrowed from `mixed` ++ if (layers.some(l => isHash(l) && l[key] != null)) { ++ warnings.push( ++ `The podspec sets ${key}, which a CocoaPods build applies and rn-xtool's scaffold does not.`, ++ ); ++ } ++ } function mergeArrayField(key /*: string */) /*: Array */ { -@@ -482,6 +2202,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + const out /*: Array */ = []; +@@ -482,11 +2291,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2800,7 +2895,13 @@ index 8fcf04b..14af29e 100644 // Only the spec's own value: a subspec's `header_dir` names that subspec's // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { -@@ -544,6 +2275,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + // $FlowFixMe[incompatible-use] dynamic shape +- const value = rawSpec[key]; ++ const value = spec[key]; + return typeof value === 'string' && value.length > 0 ? value : null; + } + +@@ -544,6 +2364,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2821,7 +2922,7 @@ index 8fcf04b..14af29e 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2299,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2388,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2846,7 +2947,7 @@ index 8fcf04b..14af29e 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2332,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2421,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2867,7 +2968,7 @@ index 8fcf04b..14af29e 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,44 +2402,119 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2491,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -2911,6 +3012,21 @@ index 8fcf04b..14af29e 100644 + return Array.from(new Set(out)); + } + ++ // The SwiftPM packages the podspec's run asked for with ++ // `spm_dependency(spec, url:, requirement:, products:)`, as the shim ++ // recorded them. ++ function spmDependencies() /*: Array<{url: string, products: Array}> */ { ++ // $FlowFixMe[prop-missing] the shim's dynamic shape ++ const recorded = rawSpec.__rn_xtool__?.spm_dependencies; ++ if (!Array.isArray(recorded)) return []; ++ return recorded.filter(isHash).map(d => ({ ++ url: String(d.url), ++ products: (Array.isArray(d.products) ? d.products : [d.products]).filter( ++ p => typeof p === 'string', ++ ), ++ })); ++ } ++ + // Each selected subspec's own dependencies, by subspec name. + function subspecDependencies() /*: {[string]: Array} */ { + const out /*: {[string]: Array} */ = {}; @@ -3012,7 +3128,13 @@ index 8fcf04b..14af29e 100644 } } return out; -@@ -677,6 +2527,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { + } + + // $FlowFixMe[prop-missing] dynamic shape +- const reqArc /*: unknown */ = rawSpec.requires_arc; ++ const reqArc /*: unknown */ = spec.requires_arc; + const requiresArc = + reqArc === false || (Array.isArray(reqArc) && reqArc.length === 0) ? false : true; // RN ecosystem default @@ -3033,7 +3155,7 @@ index 8fcf04b..14af29e 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2557,239 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2661,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3086,6 +3208,7 @@ index 8fcf04b..14af29e 100644 + unresolvedSources: Array.isArray(rawSpec.__unresolved__) + ? rawSpec.__unresolved__ + : [], ++ spmDependencies: spmDependencies(), }; } @@ -3116,6 +3239,28 @@ index 8fcf04b..14af29e 100644 + 'the library a Package.swift of its own.' + ); +} ++ ++/** ++ * Why the library cannot be scaffolded for the SwiftPM packages its podspec ++ * declares with `spm_dependency`, or null: a CocoaPods build resolves them, ++ * and a scaffold without them would not link. ++ */ ++function spmDependencyReason( ++ podspecPath /*: string */, ++ model /*: PodspecModel */, ++) /*: ?string */ { ++ const list = model.spmDependencies ?? []; ++ if (list.length === 0) return null; ++ return ( ++ `${podspecPath}: uses ` + ++ list ++ .map( ++ d => `spm_dependency(url: ${d.url}, products: ${d.products.join(', ')})`, ++ ) ++ .join(', ') + ++ ', which rn-xtool does not map yet' ++ ); ++} + // --------------------------------------------------------------------------- // Top-level entry @@ -3302,7 +3447,7 @@ index 8fcf04b..14af29e 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2817,13 @@ function readPodspecNames( +@@ -794,12 +2944,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3317,7 +3462,7 @@ index 8fcf04b..14af29e 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2841,9 @@ function readPodspecNames( +@@ -817,8 +2968,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3329,7 +3474,7 @@ index 8fcf04b..14af29e 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2859,15 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +2986,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, @@ -3344,13 +3489,14 @@ index 8fcf04b..14af29e 100644 + runPodspecShim, regexPodspec, flattenSubspecs, ++ spmDependencyReason, + unresolvedSourcesReason, }; diff --git a/node_modules/react-native/scripts/spm/scaffold-package-swift.js b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -index cf7e587..f105e49 100644 +index cf7e587..0986d43 100644 --- a/node_modules/react-native/scripts/spm/scaffold-package-swift.js +++ b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -@@ -45,7 +45,11 @@ const { +@@ -45,7 +45,12 @@ const { } = require('./expand-spm-dependencies'); const {expandSpmSourceGlobs} = require('./generate-spm-autolinking'); const {MIN_IOS_VERSION_SUPPORTED} = require('./ios-deployment-target'); @@ -3358,12 +3504,13 @@ index cf7e587..f105e49 100644 +const { + findPodspecs, + readPodspecCached, ++ spmDependencyReason, + unresolvedSourcesReason, +} = require('./read-podspec'); const { REACT_CODEGEN_PACKAGE_NAME, REACT_CODEGEN_PRODUCTS, -@@ -54,6 +58,7 @@ const { +@@ -54,6 +59,7 @@ const { SCAFFOLDER_MARKER, makeLogger, remotePackageConfig, @@ -3371,7 +3518,7 @@ index cf7e587..f105e49 100644 } = require('./spm-utils'); const {readSwiftpmConfig, writeSwiftpmName} = require('./swiftpm-config'); const fs = require('node:fs'); -@@ -113,6 +118,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); +@@ -113,6 +119,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); const SCAFFOLDER_VERSION = 20; const SCAFFOLDER_VERSION_LINE_RE = /^\/\/ AUTO-SCAFFOLDED-VERSION: (\d+)$/m; @@ -3653,7 +3800,7 @@ index cf7e587..f105e49 100644 const AUTOGEN_MARKER = '// AUTO-GENERATED by scripts/generate-spm-autolinking.js'; -@@ -145,6 +425,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm +@@ -145,6 +426,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm #endif `; @@ -4027,7 +4174,7 @@ index cf7e587..f105e49 100644 // Names of deps the scaffolder always refuses to touch — `react-native` // itself is handled by the xcframework subpackage, never as an autolinked // target. -@@ -167,10 +814,27 @@ const REACT_CORE_DEP_PREFIXES = [ +@@ -167,10 +815,27 @@ const REACT_CORE_DEP_PREFIXES = [ 'DoubleConversion', 'Yoga', 'hermes-engine', @@ -4056,7 +4203,7 @@ index cf7e587..f105e49 100644 } // True when the dep ships a `codegenConfig` in package.json — RN's standard -@@ -248,6 +912,12 @@ function translatePodspecToSpmTarget( +@@ -248,6 +913,12 @@ function translatePodspecToSpmTarget( // npm name → resolved Swift name for every autolinked dep, so a sibling // reference honors that sibling's `spm.name` instead of re-deriving it. swiftNameByNpm /*: Map */ = new Map(), @@ -4069,7 +4216,7 @@ index cf7e587..f105e49 100644 ) /*: SpmScaffoldSpec */ { const warnings = [...model.warnings]; -@@ -322,46 +992,92 @@ function translatePodspecToSpmTarget( +@@ -322,46 +993,92 @@ function translatePodspecToSpmTarget( } } @@ -4190,7 +4337,7 @@ index cf7e587..f105e49 100644 } } -@@ -427,15 +1143,55 @@ function translatePodspecToSpmTarget( +@@ -427,15 +1144,55 @@ function translatePodspecToSpmTarget( f => f !== SCAFFOLD_PREFIX_HEADER && f !== 'Package.swift' && @@ -4248,7 +4395,7 @@ index cf7e587..f105e49 100644 try { for (const f of expandSpmSourceGlobs(dep.root, model.publicHeaderFiles)) { if (/\.(h|hh|hpp)$/i.test(f)) headerFiles.push(f); -@@ -497,6 +1253,51 @@ function translatePodspecToSpmTarget( +@@ -497,6 +1254,51 @@ function translatePodspecToSpmTarget( } } let namespacedShimHeaders /*: Array */ = []; @@ -4300,7 +4447,7 @@ index cf7e587..f105e49 100644 if (publicHeadersPath == null) { // Root-level podspecs (`s.source_files = "*.{h,m,mm}"`) keep their // headers in the package root. CocoaPods exposes them to dependents as -@@ -518,6 +1319,101 @@ function translatePodspecToSpmTarget( +@@ -518,6 +1320,101 @@ function translatePodspecToSpmTarget( ); } @@ -4402,7 +4549,7 @@ index cf7e587..f105e49 100644 const siblingSwiftNames /*: {[npmName: string]: string} */ = {}; for (const npmName of siblingNames) { const resolved = swiftNameByNpm.get(npmName); -@@ -526,21 +1422,201 @@ function translatePodspecToSpmTarget( +@@ -526,21 +1423,201 @@ function translatePodspecToSpmTarget( } } @@ -4606,7 +4753,7 @@ index cf7e587..f105e49 100644 warnings, }; } -@@ -565,6 +1641,9 @@ type EmitContext = { +@@ -565,6 +1642,9 @@ type EmitContext = { // Relative path to the app's local xcframeworks package // (/build/xcframeworks). Only referenced when remote == null. localXcfwPackageDir?: ?string, @@ -4616,7 +4763,7 @@ index cf7e587..f105e49 100644 iosDeploymentTarget?: ?string, }; */ -@@ -629,10 +1708,25 @@ function emitScaffoldedPackageSwift( +@@ -629,10 +1709,25 @@ function emitScaffoldedPackageSwift( const prefixFlag = spec.needsObjCPrefix ? `.unsafeFlags(["-include", "${SCAFFOLD_PREFIX_HEADER}"])` : ''; @@ -4643,7 +4790,7 @@ index cf7e587..f105e49 100644 ...(customFlagsCxx.length > 0 ? [`.unsafeFlags([${customFlagsCxx.join(', ')}])`] : []), -@@ -723,6 +1817,32 @@ function emitScaffoldedPackageSwift( +@@ -723,6 +1818,32 @@ function emitScaffoldedPackageSwift( `.product(name: "${swiftSibling}", package: "${swiftSibling}")`, ); } @@ -4676,7 +4823,7 @@ index cf7e587..f105e49 100644 // sources: emit only when the podspec declared them. If empty (regex-fallback // podspec), no `sources:`/`exclude:` is emitted and SPM auto-scans the target -@@ -740,6 +1860,11 @@ function emitScaffoldedPackageSwift( +@@ -740,6 +1861,11 @@ function emitScaffoldedPackageSwift( ? `\n publicHeadersPath: "${spec.publicHeadersPath}",` : ''; @@ -4688,7 +4835,7 @@ index cf7e587..f105e49 100644 const resourcesLine = spec.resources.length > 0 ? `\n resources: [${spec.resources.map(r => `.copy("${r}")`).join(', ')}],` -@@ -755,9 +1880,71 @@ function emitScaffoldedPackageSwift( +@@ -755,9 +1881,71 @@ function emitScaffoldedPackageSwift( ? `\n dependencies: [${targetDeps.join(', ')}],` : ''; @@ -4762,7 +4909,7 @@ index cf7e587..f105e49 100644 // Edit the contents below if needed and re-run \`npx patch-package \` // to persist across \`npm install\`. To regenerate from the podspec, remove // this file (or just this marker) and re-run \`npx react-native spm scaffold\`. -@@ -768,7 +1955,7 @@ ${SCAFFOLDER_MARKER} +@@ -768,7 +1956,7 @@ ${SCAFFOLDER_MARKER} // (dropping the file) anyway. import PackageDescription @@ -4771,7 +4918,7 @@ index cf7e587..f105e49 100644 let package = Package( name: "${spec.swiftName}", platforms: [.iOS("${iosDeploymentTarget}")], -@@ -778,13 +1965,13 @@ let package = Package( +@@ -778,13 +1966,13 @@ let package = Package( ${packageDepsBlock} targets: [ .target( name: "${spec.swiftName}",${targetDepsLine} @@ -4788,7 +4935,7 @@ index cf7e587..f105e49 100644 ) `; } -@@ -844,6 +2031,61 @@ function reportSwiftName( +@@ -844,6 +2032,61 @@ function reportSwiftName( } } @@ -4850,7 +4997,7 @@ index cf7e587..f105e49 100644 // --------------------------------------------------------------------------- // Per-dep orchestrator // --------------------------------------------------------------------------- -@@ -953,7 +2195,11 @@ function scaffoldPackageSwiftForDep( +@@ -953,7 +2196,11 @@ function scaffoldPackageSwiftForDep( // regenerating existing files; --force is not needed here. const vMatch = existing.match(SCAFFOLDER_VERSION_LINE_RE); const existingVersion = vMatch != null ? parseInt(vMatch[1], 10) : 1; @@ -4863,7 +5010,7 @@ index cf7e587..f105e49 100644 if (!ctx.force && !versionStale) { // Slot label change is the other auto-regen trigger — bumps SPM's // manifest hash so the cache-slot path gets re-resolved. -@@ -970,7 +2216,7 @@ function scaffoldPackageSwiftForDep( +@@ -970,7 +2217,7 @@ function scaffoldPackageSwiftForDep( } if (versionStale) { log( @@ -4872,7 +5019,7 @@ index cf7e587..f105e49 100644 ); } // Fall through: regenerate (force, slot changed, or version bumped). -@@ -998,9 +2244,44 @@ function scaffoldPackageSwiftForDep( +@@ -998,9 +2245,44 @@ function scaffoldPackageSwiftForDep( }; } @@ -4917,7 +5064,7 @@ index cf7e587..f105e49 100644 } catch (e) { return { depName, -@@ -1008,39 +2289,27 @@ function scaffoldPackageSwiftForDep( +@@ -1008,39 +2290,33 @@ function scaffoldPackageSwiftForDep( reason: `Podspec read failed: ${e.message}`, }; } @@ -4926,6 +5073,12 @@ index cf7e587..f105e49 100644 + const unresolved = unresolvedSourcesReason(podspecPath, model); + if (unresolved != null) { + return {depName, status: 'error', reason: unresolved}; ++ } ++ // A SwiftPM package the podspec asks for (`spm_dependency`): the target ++ // would not link without it. ++ const spmDependency = spmDependencyReason(podspecPath, model); ++ if (spmDependency != null) { ++ return {depName, status: 'error', reason: spmDependency}; + } const spec = translatePodspecToSpmTarget( @@ -4972,7 +5125,7 @@ index cf7e587..f105e49 100644 // Relative paths into the app, embedded in the scaffolded Package.swift. // -@@ -1072,6 +2341,7 @@ function scaffoldPackageSwiftForDep( +@@ -1072,6 +2348,7 @@ function scaffoldPackageSwiftForDep( iosDeploymentTarget: ctx.iosDeploymentTarget, codegenPackageDir: relFromManifest('build', 'generated', 'ios'), localXcfwPackageDir: relFromManifest('build', 'xcframeworks'), @@ -4980,7 +5133,7 @@ index cf7e587..f105e49 100644 }); // Distinguish "first-time scaffold" (no file at all) from "regenerate" -@@ -1081,15 +2351,36 @@ function scaffoldPackageSwiftForDep( +@@ -1081,15 +2358,36 @@ function scaffoldPackageSwiftForDep( // regens are silent because we're maintaining a file we already own. const previouslyExisted = fs.existsSync(pkgSwiftPath); @@ -5020,7 +5173,7 @@ index cf7e587..f105e49 100644 ); } // Mirror root-level headers into the generated include// shim -@@ -1099,18 +2390,96 @@ function scaffoldPackageSwiftForDep( +@@ -1099,18 +2397,96 @@ function scaffoldPackageSwiftForDep( const shimDir = path.join(dep.root, 'include', spec.swiftName); fs.mkdirSync(shimDir, {recursive: true}); for (const header of spec.namespacedShimHeaders) { @@ -5121,7 +5274,7 @@ index cf7e587..f105e49 100644 reportSwiftName(dep, spec.swiftName, model); // Migration: record a name we derived from the podspec, so the library can -@@ -1120,6 +2489,12 @@ function scaffoldPackageSwiftForDep( +@@ -1120,6 +2496,12 @@ function scaffoldPackageSwiftForDep( dep.swiftNameSource === 'podspec' ? writeSwiftpmName(dep.root, spec.swiftName, {dryRun: ctx.dryRun}) : undefined; @@ -5134,7 +5287,7 @@ index cf7e587..f105e49 100644 return { depName, -@@ -1128,6 +2503,7 @@ function scaffoldPackageSwiftForDep( +@@ -1128,6 +2510,7 @@ function scaffoldPackageSwiftForDep( warnings: spec.warnings, previouslyExisted, swiftpmName, @@ -5142,7 +5295,7 @@ index cf7e587..f105e49 100644 }; } -@@ -1141,7 +2517,7 @@ function collectAutolinkedDeps( +@@ -1141,7 +2524,7 @@ function collectAutolinkedDeps( opts /*: { autolinkingJsonPath: string, remote: ?{url: string, version: string, identity: string}, @@ -5151,7 +5304,7 @@ index cf7e587..f105e49 100644 } */, ) /*: ?Array */ { const {autolinkingJsonPath, remote, onSkipped} = opts; -@@ -1162,7 +2538,7 @@ function collectAutolinkedDeps( +@@ -1162,7 +2545,7 @@ function collectAutolinkedDeps( const root = raw.root; const ios = raw.platforms?.ios; if (typeof root !== 'string' || ios == null) { @@ -5160,7 +5313,7 @@ index cf7e587..f105e49 100644 continue; } // $FlowFixMe[incompatible-type] `ios` shape is runtime-validated above -@@ -1294,6 +2670,11 @@ type ScaffoldAllOptions = { +@@ -1294,6 +2677,11 @@ type ScaffoldAllOptions = { // confirmation prompt for first-time scaffolds. Skipped deps still // appear in the returned results array with status='skipped-opt-out'. skipDeps?: ReadonlyArray, @@ -5172,7 +5325,7 @@ index cf7e587..f105e49 100644 }; */ -@@ -1323,6 +2704,17 @@ function scaffoldAll( +@@ -1323,6 +2711,17 @@ function scaffoldAll( // scaffolded here — leaving `react-native spm scaffold` unable to clear the // autolinker's missing-manifest error. const results /*: Array */ = []; @@ -5190,7 +5343,7 @@ index cf7e587..f105e49 100644 // Outside collectAutolinkedDeps' own try: a malformed remote config // (RemoteVersionError) is a misconfiguration to surface, not an expansion // failure to degrade past. -@@ -1330,24 +2722,23 @@ function scaffoldAll( +@@ -1330,24 +2729,23 @@ function scaffoldAll( const allDeps = collectAutolinkedDeps({ autolinkingJsonPath, remote, @@ -5226,7 +5379,7 @@ index cf7e587..f105e49 100644 for (const dep of allDeps) { const podspecPath = dep.platforms?.ios?.podspecPath; if (typeof podspecPath === 'string' && podspecPath.length > 0) { -@@ -1386,6 +2777,9 @@ function scaffoldAll( +@@ -1386,6 +2784,9 @@ function scaffoldAll( const skipSet /*: Set */ = new Set(opts.skipDeps ?? []); for (const dep of allDeps) { @@ -5236,7 +5389,7 @@ index cf7e587..f105e49 100644 if (skipSet.has(dep.name)) { results.push({ depName: dep.name, -@@ -1404,6 +2798,9 @@ function scaffoldAll( +@@ -1404,6 +2805,9 @@ function scaffoldAll( } module.exports = { @@ -5247,7 +5400,7 @@ index cf7e587..f105e49 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..b9ed2bc 100644 +index a89142f..4493621 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5285,7 +5438,7 @@ index a89142f..b9ed2bc 100644 // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. preprocessorDefines: Array, // File paths or glob patterns the dep declares as bundled resources. -@@ -460,17 +462,25 @@ export type PodspecModel = { +@@ -460,17 +462,28 @@ export type PodspecModel = { // a user can spot fields that didn't translate cleanly (unknown env vars, // unrecognized $(...) tokens, etc.). Never throws on parse errors. warnings: Array, @@ -5317,10 +5470,13 @@ index a89142f..b9ed2bc 100644 + // evaluate (a method call, an unknown local): the scaffolder refuses the + // library rather than build it from a partial source list. + unresolvedSources?: Array<{field: string, expr: string, why: string}>, ++ // The SwiftPM packages the podspec's run asked for with `spm_dependency` ++ // (Ruby only): the scaffolder refuses the library (spmDependencyReason). ++ spmDependencies?: Array<{url: string, products: Array}>, }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -485,7 +495,7 @@ export type SpmScaffoldSpec = { +@@ -485,7 +498,7 @@ export type SpmScaffoldSpec = { // Header search paths resolved to dep-root-relative form. Each entry // becomes `.headerSearchPath("")` in cSettings + cxxSettings. headerSearchPaths: Array, @@ -5329,7 +5485,7 @@ index a89142f..b9ed2bc 100644 // cSettings + cxxSettings, honoring any per-config scope. preprocessorDefines: Array, // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + -@@ -502,6 +512,9 @@ export type SpmScaffoldSpec = { +@@ -502,6 +515,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5339,7 +5495,7 @@ index a89142f..b9ed2bc 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +552,9 @@ export type ScaffoldResult = +@@ -539,6 +555,9 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 3b87d14..07ed6c5 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -2,8 +2,9 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileS import { createRequire } from "node:module"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { VENDORED_RN_SPM } from "./support/rnScaffold.js"; +import { PODSPEC_FIXTURES, VENDORED_RN_SPM, installedCopy, podspecCopy } from "./support/rnScaffold.js"; import { SHIM, needsRuby, tempDir } from "./support/ruby.js"; +import { needsTarball, packageFromTarball } from "./support/tarballs.js"; import { tool } from "./support/tools.js"; // How the vendored scaffolder (vendor/rn-spm/spm/read-podspec.js) picks its podspec reader and runs the Ruby shim. @@ -13,6 +14,8 @@ const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); const readPodspecJs = req("./read-podspec.js"); const { podspecReader, runPodspecShim, isPodspecReadError, installationRootFor } = readPodspecJs; const { readPodspec, readPodspecCached, unresolvedSourcesReason } = readPodspecJs; +const { flattenSubspecs, findPodspecs, spmDependencyReason } = readPodspecJs; +const { scaffoldPackageSwiftForDep } = req("./scaffold-package-swift.js"); const REMEDY = "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report."; @@ -381,3 +384,192 @@ describe.skipIf(needsRuby !== "")(`readPodspec${needsRuby}`, () => { expect(reason.slice(-INSTALL_RUBY.length - 1)).toBe(` ${INSTALL_RUBY}`); }); }); + +describe("flattenSubspecs on the shim's model", () => { + const SVG = "react-native-svg@15.16.0"; + const unapplied = (key: string) => `The podspec sets ${key}, which a CocoaPods build applies and rn-xtool's scaffold does not.`; + beforeEach(() => { + const rn = tempDir(); + writeFileSync(path.join(rn, "package.json"), JSON.stringify({ name: "react-native", version: "0.86.3" })); + vi.stubEnv("RN_SPM_RN_ROOT", rn); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + vi.stubEnv("RN_SPM_APP_IOS_DIR", undefined); + }); + const withReader = (reader: "ruby" | "reduced", read: () => T): T => { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", reader === "reduced" ? "reduced" : undefined); + return read(); + }; + /** The library in `root` scaffolded as rn-xtool's driver does, its app's `ios/` beside its `node_modules`. */ + function scaffold(root: string): { status: string; reason?: string; packageSwift?: string } { + const base = path.resolve(root, "..", ".."); + vi.stubEnv("RN_SPM_RN_ROOT", path.join(base, "node_modules", "react-native")); + const podspec = findPodspecs(root)[0]; + const dep = { name: path.basename(root), root, swiftName: "Lib", swiftNameSource: "podspec", platforms: { ios: { podspecPath: podspec } } }; + const ctx = { + appRoot: path.join(base, "ios"), + projectRoot: base, + reactNativeRoot: path.join(base, "node_modules", "react-native"), + force: true, + dryRun: false, + cacheSlotLabel: null, + remote: null, + }; + const r = scaffoldPackageSwiftForDep(dep, ctx); + const pkg = path.join(root, "Package.swift"); + return existsSync(pkg) ? { ...r, packageSwift: readFileSync(pkg, "utf8").split(base).join("") } : r; + } + + it("merges ios attributes over each layer", () => { + const m = flattenSubspecs({ + name: "Foo", + source_files: "a/**/*.m", + exclude_files: "x", + ios: { exclude_files: "**/*.macos.m" }, + osx: { exclude_files: "**/*.ios.m" }, + pod_target_xcconfig: { OTHER_CFLAGS: "-DA" }, + subspecs: [{ name: "c", ios: { pod_target_xcconfig: { OTHER_CFLAGS: "-DB" } } }], + }); + expect(m.excludeFiles).toEqual(["x", "**/*.macos.m"]); + expect(m.preprocessorDefines.map((d: { name: string }) => d.name)).toEqual(["A", "B"]); + }); + + it("merges a hash key by key and lets ios win other values", () => { + const m = flattenSubspecs({ + name: "Foo", + header_dir: "generic", + requires_arc: false, + frameworks: "UIKit", + pod_target_xcconfig: { OTHER_CFLAGS: "-DA", GCC_PREPROCESSOR_DEFINITIONS: ["KEPT=1"] }, + ios: { + header_dir: "iosdir", + requires_arc: true, + frameworks: ["WebKit"], + pod_target_xcconfig: { OTHER_CFLAGS: "-DB", GCC_PREPROCESSOR_DEFINITIONS: "IOS=1" }, + }, + tvos: { frameworks: "TVUIKit" }, + visionos: { frameworks: "RealityKit" }, + watchos: { frameworks: "WatchKit" }, + }); + expect(m.headerDir).toBe("iosdir"); + expect(m.requiresArc).toBe(true); + expect(m.frameworks).toEqual(["UIKit", "WebKit"]); + expect(m.preprocessorDefines.map((d: { name: string }) => d.name)).toEqual(["A", "B", "IOS"]); + }); + + it("warns about keys the scaffold does not apply", () => { + const m = flattenSubspecs({ + name: "Foo", + script_phases: [{ name: "Codegen", script: "echo" }], + ios: { info_plist: { NSCameraUsageDescription: "camera" } }, + osx: { module_map: "mac.modulemap" }, + }); + expect(m.warnings).toEqual([unapplied("script_phases"), unapplied("info_plist")]); + expect(flattenSubspecs({ name: "Foo", prepare_command: "make", subspecs: [{ name: "c", module_map: "c.modulemap" }] }).warnings).toEqual([ + unapplied("prepare_command"), + unapplied("module_map"), + ]); + }); + + it.skipIf(needsRuby !== "")(`refuses a library that declares a SwiftPM dependency${needsRuby}`, () => { + const model = flattenSubspecs({ name: "Foo", __rn_xtool__: { spm_dependencies: [{ url: "https://x/y", requirement: {}, products: ["Y"] }] } }); + expect(model.spmDependencies).toEqual([{ url: "https://x/y", products: ["Y"] }]); + expect(flattenSubspecs({ name: "Foo" }).spmDependencies).toEqual([]); + const root = installedCopy( + path.dirname( + library( + spec( + ' s.source_files = "ios/*.m"', + ' spm_dependency(s, url: "https://x/y", requirement: {kind: "upToNextMajorVersion", minimumVersion: "1.0.0"}, products: ["Y"])', + ), + { "ios/Foo.m": "", "package.json": JSON.stringify({ name: "react-native-foo", version: "1.0.0" }) }, + ), + ), + ); + const podspec = path.join(root, "Foo.podspec"); + const reason = `${podspec}: uses spm_dependency(url: https://x/y, products: Y), which rn-xtool does not map yet`; + expect(spmDependencyReason(podspec, readPodspec(podspec))).toBe(reason); + expect(scaffold(root)).toEqual({ depName: "react-native-foo", status: "error", reason }); + }); + + it.skipIf(needsRuby !== "" || needsTarball(SVG) !== "")( + `reads react-native-svg 15.16.0's iOS excludes with Ruby${needsRuby}${needsTarball(SVG)}`, + () => { + const m = readPodspec(podspecCopy(path.join(packageFromTarball(SVG)!, "RNSVG.podspec"))); + expect(m.reader).toBe("ruby"); + expect(m.excludeFiles).toContain("**/*.macos.{h,m,mm}"); + expect(m.excludeFiles).not.toContain("**/*.ios.{h,m,mm}"); + expect(m.excludeFiles).not.toContain("apple/Utils/RNSVGFabricConversions.h"); + }, + ); + + it.skipIf(needsRuby !== "")(`reads react-native-screens 4.24.0's locals with Ruby${needsRuby}`, () => { + const m = readPodspec(podspecCopy(path.join(PODSPEC_FIXTURES, "RNScreens-4.24.0", "RNScreens.podspec"))); + expect(m.reader).toBe("ruby"); + expect(m.sourceFiles).toEqual(["ios/**/*.{h,m,mm,cpp,swift}", "common/cpp/**/*.{cpp,h}", "cpp/**/*.{cpp,h}"]); + expect(m.excludeFiles).toEqual(["ios/gamma/**/*.{h,m,mm,cpp,swift}"]); + }); + + // The reduced reader cannot evaluate `defined?(install_modules_dependencies())`, so it reads both branches. + it.skipIf(needsRuby !== "")(`scaffolds gesture-handler 2.32.0 the same with Ruby as with the reduced reader${needsRuby}`, () => { + const fixture = path.join(PODSPEC_FIXTURES, "RNGestureHandler-2.32.0"); + const run = (reader: "ruby" | "reduced") => + withReader(reader, () => { + const root = installedCopy(fixture); + const model = readPodspec(path.join(root, "RNGestureHandler.podspec")); + return { model, scaffolded: scaffold(root) }; + }); + const ruby = run("ruby"); + const reduced = run("reduced"); + expect([ruby.model.reader, reduced.model.reader]).toEqual(["ruby", "reduced"]); + expect(ruby.model.sourceFiles).toEqual(["apple/**/*.{h,m,mm}"]); + expect(reduced.model.sourceFiles).toEqual(ruby.model.sourceFiles); + expect(ruby.model.dependencies).toEqual([]); + expect(ruby.model.usesInstallModulesDependencies).toBe(true); + expect(reduced.model.dependencies).toEqual(["React-Core"]); + expect(ruby.scaffolded.status).toBe("written"); + expect(reduced.scaffolded.status).toBe("written"); + expect(reduced.scaffolded.packageSwift).toBe(ruby.scaffolded.packageSwift); + }); + + it.skipIf(needsRuby !== "")(`drops a subspec on Ruby's model as on the reduced one${needsRuby}`, () => { + // react-native-vision-camera 4.7.3's shape. + const podspec = library( + [ + "enableFrameProcessors = true", + "if defined?($VCEnableFrameProcessors)", + ' Pod::UI.puts "[VisionCamera] $VCEnableFrameProcessors is set to #{$VCEnableFrameProcessors}!"', + " enableFrameProcessors = $VCEnableFrameProcessors", + "end", + 'Pod::UI.puts("[VisionCamera] VisionCamera_enableFrameProcessors is set to #{enableFrameProcessors}!")', + "Pod::Spec.new do |s|", + ' s.name = "VisionCamera"', + " s.subspec 'Core' do |core|", + ' core.source_files = ["ios/Core/**/*.swift"]', + " end", + " s.subspec 'React' do |core|", + ' core.source_files = ["ios/React/**/*.{h,m,swift}"]', + ' core.dependency "React-Core"', + " if enableFrameProcessors", + ' core.dependency "VisionCamera/FrameProcessors"', + " end", + " end", + " if enableFrameProcessors", + " s.subspec 'FrameProcessors' do |fp|", + ' fp.source_files = ["ios/FrameProcessors/**/*.{h,m,mm}"]', + ' fp.dependency "react-native-worklets-core"', + " end", + " end", + "end", + ].join("\n"), + ); + for (const reader of ["ruby", "reduced"] as const) { + const all = withReader(reader, () => readPodspec(podspec)); + expect(all.reader).toBe(reader); + expect(all.sourceFiles).toContain("ios/FrameProcessors/**/*.{h,m,mm}"); + expect(all.dependencies).toContain("react-native-worklets-core"); + const m = withReader(reader, () => readPodspec(podspec, { dropSubspecs: ["FrameProcessors"] })); + expect(m.sourceFiles, reader).toEqual(["ios/Core/**/*.swift", "ios/React/**/*.{h,m,swift}"]); + expect(m.dependencies, reader).toEqual(["React-Core"]); + } + }); +}); diff --git a/tests/rn-scaffolder.test.ts b/tests/rn-scaffolder.test.ts index d82f39f..82fce45 100644 --- a/tests/rn-scaffolder.test.ts +++ b/tests/rn-scaffolder.test.ts @@ -1,4 +1,4 @@ -import { cpSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync, existsSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync, existsSync } from "node:fs"; import { createRequire } from "node:module"; import { homedir, tmpdir } from "node:os"; import path from "node:path"; @@ -8,6 +8,7 @@ import { GOLDEN_LIBS, PODSPEC_FIXTURES, VENDORED_RN_SPM, + podspecCopy, readGolden, scaffoldLibraries, withRnRoot, @@ -70,18 +71,6 @@ function tempDir(): string { afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); }); -/** - * A copy of a library podspec, with what it reads (package.json, svg's scripts/): reading a podspec runs it, and - * nothing it may write must land in the shared pristine tree. - */ -function podspecCopy(file: string): string { - const dir = tempDir(); - for (const f of [path.basename(file), "package.json", "scripts"]) { - const src = path.join(path.dirname(file), f); - if (existsSync(src)) cpSync(src, path.join(dir, f), { recursive: true, dereference: true }); - } - return path.join(dir, path.basename(file)); -} describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () => { beforeAll(() => { @@ -394,9 +383,6 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("read-podspec platform-scoped fields", () => { - // Pinned until Task 5 adds the `ios` merge to the Ruby path and gives the svg copy a react-native beside it; Task 5 removes this pin. - beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); - afterEach(() => vi.unstubAllEnvs()); const readModel = (body: string) => load("read-podspec.js").readPodspecCached(podspec(body)) as Model & { excludeFiles: string[]; @@ -452,6 +438,7 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); describe("preprocessor defines", () => { + // The reduced reader's: Ruby cannot run their `#{x}` interpolations of undefined locals. beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); afterEach(() => vi.unstubAllEnvs()); type Def = { name: string; value: string | null; config: string | null }; @@ -1174,6 +1161,7 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () // gesture-handler 2.32.0, plus screens 4.30.1, which has no Swift (a clang-only target), and // worklets 0.8.3 (fix 19's `RCT_HERMES_V1_ENABLED` ternary). describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { + // The reduced reader's: the RNReanimated-4.5.1 and RNWorklets-0.10.1 fixtures lack the scripts/*.rb they require. beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced")); afterEach(() => vi.unstubAllEnvs()); const req = createRequire(import.meta.url); diff --git a/tests/support/rnScaffold.ts b/tests/support/rnScaffold.ts index 5840f2c..0fc769a 100644 --- a/tests/support/rnScaffold.ts +++ b/tests/support/rnScaffold.ts @@ -70,6 +70,35 @@ export function withRnRoot(version: string, run: () => T): T { } } +/** + * An installed copy of the library in `src`, as an app's install lays it out: `/node_modules/` + * (by value; only `files`, relative to `src`, when given), beside a `node_modules/react-native` of `rnVersion` and the + * app's `ios/` folder. Reading a podspec runs it, and its Ruby helpers look React Native up from there. Its folder. + */ +export function installedCopy(src: string, { files, rnVersion = "0.86.3" }: { files?: string[]; rnVersion?: string } = {}): string { + const base = mkTmp("rn-scaffold-installed-"); + const pkg = path.join(src, "package.json"); + const name = existsSync(pkg) ? (JSON.parse(readFileSync(pkg, "utf8")) as { name?: string }).name : undefined; + const root = path.join(base, "node_modules", name ?? path.basename(src)); + mkdirSync(root, { recursive: true }); + for (const f of files ?? readdirSync(src)) { + if (existsSync(path.join(src, f))) cpSync(path.join(src, f), path.join(root, f), { recursive: true, dereference: true }); + } + mkdirSync(path.join(base, "node_modules", "react-native")); + writeFileSync(path.join(base, "node_modules", "react-native", "package.json"), JSON.stringify({ name: "react-native", version: rnVersion })); + mkdirSync(path.join(base, "ios")); + return root; +} + +/** + * An installed copy ({@link installedCopy}) of a library podspec, with what it reads (package.json, svg's scripts/): + * reading a podspec runs it, and nothing it may write must land in the shared pristine tree. The copy's podspec. + */ +export function podspecCopy(file: string): string { + const name = path.basename(file); + return path.join(installedCopy(path.dirname(file), { files: [name, "package.json", "scripts"] }), name); +} + /** * Copies each library (`name` → its source dir) into a temp `node_modules`, drops the scaffolder's * earlier output (a persisted scaffold patch), runs `scaffoldAll` over them with `spmDir`, and diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index b4d195d..8a7e3df 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -161,7 +161,7 @@ resolveLocalHermesCompilerVersion, --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2745,9 +2745,15 @@ +@@ -2872,9 +2872,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 48216e7..799b744 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -2130,6 +2130,84 @@ function headerDirScopes( // Subspec flattening // --------------------------------------------------------------------------- +// The attributes CocoaPods' DSL declares with an Array container: for an iOS +// target its consumer appends the `ios` value to the spec's. +const ARRAY_ATTRIBUTES /*: Set */ = new Set([ + 'compiler_flags', + 'exclude_files', + 'frameworks', + 'libraries', + 'preserve_paths', + 'private_header_files', + 'project_header_files', + 'public_header_files', + 'resources', + 'source_files', + 'vendored_frameworks', + 'vendored_libraries', + 'weak_frameworks', +]); + +// What a CocoaPods build applies and the scaffold does not: each is named in +// a warning when the spec or a selected subspec sets it. +const UNAPPLIED_KEYS /*: Array */ = [ + 'script_phases', + 'prepare_command', + 'info_plist', + 'module_map', +]; + +const isHash = (v /*: mixed */) /*: boolean */ => + v != null && typeof v === 'object' && !Array.isArray(v); + +/** + * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for + * an iOS target: each value under its `ios` merged over the spec's. An + * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string + * read as a one-element array); two hashes merge key by key, two strings + * under one key joined by one space; anything else is the platform's value. + * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. + * The reduced reader's model has no `ios`: it is returned as it is. + */ +function mergeIos(layer /*: mixed */) /*: mixed */ { + // $FlowFixMe[incompatible-use] layer narrowed by isHash + if (!isHash(layer) || !isHash(layer.ios)) return layer; + // $FlowFixMe[incompatible-use] layer narrowed by isHash + const spec /*: {[string]: mixed} */ = layer; + // $FlowFixMe[incompatible-type] narrowed by isHash + const ios /*: {[string]: mixed} */ = spec.ios; + const out /*: {[string]: mixed} */ = {...spec}; + for (const key of Object.keys(ios)) { + const own = spec[key]; + const platform = ios[key]; + if (platform == null) continue; + if (own == null) { + out[key] = platform; + } else if (ARRAY_ATTRIBUTES.has(key)) { + out[key] = [ + ...(Array.isArray(own) ? own : [own]), + ...(Array.isArray(platform) ? platform : [platform]), + ]; + } else if (isHash(own) && isHash(platform)) { + // $FlowFixMe[incompatible-type] narrowed by isHash + const ownHash /*: {[string]: mixed} */ = own; + // $FlowFixMe[incompatible-type] narrowed by isHash + const platformHash /*: {[string]: mixed} */ = platform; + const merged /*: {[string]: mixed} */ = {...ownHash}; + for (const k of Object.keys(platformHash)) { + const a = ownHash[k]; + const b = platformHash[k]; + merged[k] = + typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; + } + out[key] = merged; + } else { + out[key] = platform; + } + } + return out; +} + /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for @@ -2184,7 +2262,18 @@ function flattenSubspecs( // $FlowFixMe[prop-missing] dynamic shape s => !(s != null && typeof s.name === 'string' && dropped.has(s.name)), ); - const layers = [rawSpec, ...selected]; + // Each layer as CocoaPods reads it for iOS, before any reader below. + const layers = [rawSpec, ...selected].map(mergeIos); + // $FlowFixMe[incompatible-type] mergeIos keeps the spec's shape + const spec /*: RawSpec */ = layers[0]; + for (const key of UNAPPLIED_KEYS) { + // $FlowFixMe[incompatible-use] layer narrowed from `mixed` + if (layers.some(l => isHash(l) && l[key] != null)) { + warnings.push( + `The podspec sets ${key}, which a CocoaPods build applies and rn-xtool's scaffold does not.`, + ); + } + } function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; @@ -2217,7 +2306,7 @@ function flattenSubspecs( // headers, and several subspecs can disagree. function specStringField(key /*: string */) /*: string | null */ { // $FlowFixMe[incompatible-use] dynamic shape - const value = rawSpec[key]; + const value = spec[key]; return typeof value === 'string' && value.length > 0 ? value : null; } @@ -2431,6 +2520,21 @@ function flattenSubspecs( return Array.from(new Set(out)); } + // The SwiftPM packages the podspec's run asked for with + // `spm_dependency(spec, url:, requirement:, products:)`, as the shim + // recorded them. + function spmDependencies() /*: Array<{url: string, products: Array}> */ { + // $FlowFixMe[prop-missing] the shim's dynamic shape + const recorded = rawSpec.__rn_xtool__?.spm_dependencies; + if (!Array.isArray(recorded)) return []; + return recorded.filter(isHash).map(d => ({ + url: String(d.url), + products: (Array.isArray(d.products) ? d.products : [d.products]).filter( + p => typeof p === 'string', + ), + })); + } + // Each selected subspec's own dependencies, by subspec name. function subspecDependencies() /*: {[string]: Array} */ { const out /*: {[string]: Array} */ = {}; @@ -2521,7 +2625,7 @@ function flattenSubspecs( } // $FlowFixMe[prop-missing] dynamic shape - const reqArc /*: unknown */ = rawSpec.requires_arc; + const reqArc /*: unknown */ = spec.requires_arc; const requiresArc = reqArc === false || (Array.isArray(reqArc) && reqArc.length === 0) ? false @@ -2603,6 +2707,7 @@ function flattenSubspecs( unresolvedSources: Array.isArray(rawSpec.__unresolved__) ? rawSpec.__unresolved__ : [], + spmDependencies: spmDependencies(), }; } @@ -2634,6 +2739,28 @@ function unresolvedSourcesReason( ); } +/** + * Why the library cannot be scaffolded for the SwiftPM packages its podspec + * declares with `spm_dependency`, or null: a CocoaPods build resolves them, + * and a scaffold without them would not link. + */ +function spmDependencyReason( + podspecPath /*: string */, + model /*: PodspecModel */, +) /*: ?string */ { + const list = model.spmDependencies ?? []; + if (list.length === 0) return null; + return ( + `${podspecPath}: uses ` + + list + .map( + d => `spm_dependency(url: ${d.url}, products: ${d.products.join(', ')})`, + ) + .join(', ') + + ', which rn-xtool does not map yet' + ); +} + // --------------------------------------------------------------------------- // Top-level entry // --------------------------------------------------------------------------- @@ -2875,5 +3002,6 @@ module.exports = { runPodspecShim, regexPodspec, flattenSubspecs, + spmDependencyReason, unresolvedSourcesReason, }; diff --git a/vendor/rn-spm/spm/scaffold-package-swift.js b/vendor/rn-spm/spm/scaffold-package-swift.js index f105e49..0986d43 100644 --- a/vendor/rn-spm/spm/scaffold-package-swift.js +++ b/vendor/rn-spm/spm/scaffold-package-swift.js @@ -48,6 +48,7 @@ const {MIN_IOS_VERSION_SUPPORTED} = require('./ios-deployment-target'); const { findPodspecs, readPodspecCached, + spmDependencyReason, unresolvedSourcesReason, } = require('./read-podspec'); const { @@ -2295,6 +2296,12 @@ function scaffoldPackageSwiftForDep( if (unresolved != null) { return {depName, status: 'error', reason: unresolved}; } + // A SwiftPM package the podspec asks for (`spm_dependency`): the target + // would not link without it. + const spmDependency = spmDependencyReason(podspecPath, model); + if (spmDependency != null) { + return {depName, status: 'error', reason: spmDependency}; + } const spec = translatePodspecToSpmTarget( model, diff --git a/vendor/rn-spm/spm/spm-types.js b/vendor/rn-spm/spm/spm-types.js index b9ed2bc..4493621 100644 --- a/vendor/rn-spm/spm/spm-types.js +++ b/vendor/rn-spm/spm/spm-types.js @@ -481,6 +481,9 @@ export type PodspecModel = { // evaluate (a method call, an unknown local): the scaffolder refuses the // library rather than build it from a partial source list. unresolvedSources?: Array<{field: string, expr: string, why: string}>, + // The SwiftPM packages the podspec's run asked for with `spm_dependency` + // (Ruby only): the scaffolder refuses the library (spmDependencyReason). + spmDependencies?: Array<{url: string, products: Array}>, }; // Intermediate translation result — concrete data the Swift emitter consumes. From 5678eeb30205e0ea7a5ee8efb2515096fee96a06 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 15:22:47 -0600 Subject: [PATCH 14/53] fix: merge ios dependencies and array values --- patches/react-native+0.88.0.patch | 48 ++++++++++++++++++------------ patches/react-native+0.88.1.patch | 48 ++++++++++++++++++------------ tests/podspecReader.test.ts | 11 ++++++- vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 20 +++++++++---- 5 files changed, 84 insertions(+), 45 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 2c85986..eaac900 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..00d53dc 100644 +index 8fcf04b..032bc7c 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -2674,7 +2674,7 @@ index 8fcf04b..00d53dc 100644 }; } -@@ -423,10 +2074,140 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2074,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2768,8 +2768,10 @@ index 8fcf04b..00d53dc 100644 + * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for + * an iOS target: each value under its `ios` merged over the spec's. An + * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string -+ * read as a one-element array); two hashes merge key by key, two strings -+ * under one key joined by one space; anything else is the platform's value. ++ * read as a one-element array); two hashes merge key by key as CocoaPods' ++ * `merge_hash_value` does (two strings joined by one space, an array on ++ * either side concatenated with the other read as an array, any other pair ++ * the platform's value); anything else is the platform's value. + * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. + * The reduced reader's model has no `ios`: it is returned as it is. + */ @@ -2801,8 +2803,16 @@ index 8fcf04b..00d53dc 100644 + for (const k of Object.keys(platformHash)) { + const a = ownHash[k]; + const b = platformHash[k]; -+ merged[k] = -+ typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; ++ if (typeof a === 'string' && typeof b === 'string') { ++ merged[k] = `${a} ${b}`; ++ } else if (a != null && (Array.isArray(a) || Array.isArray(b))) { ++ merged[k] = [ ++ ...(Array.isArray(a) ? a : [a]), ++ ...(Array.isArray(b) ? b : [b]), ++ ].filter(v => v != null); ++ } else { ++ merged[k] = b; ++ } + } + out[key] = merged; + } else { @@ -2815,7 +2825,7 @@ index 8fcf04b..00d53dc 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2219,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2229,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2833,7 +2843,7 @@ index 8fcf04b..00d53dc 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2240,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2250,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2853,7 +2863,7 @@ index 8fcf04b..00d53dc 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2258,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2268,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2877,7 +2887,7 @@ index 8fcf04b..00d53dc 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2291,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2301,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2901,7 +2911,7 @@ index 8fcf04b..00d53dc 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2364,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2374,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2922,7 +2932,7 @@ index 8fcf04b..00d53dc 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2388,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2398,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2947,7 +2957,7 @@ index 8fcf04b..00d53dc 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2421,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2431,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2968,7 +2978,7 @@ index 8fcf04b..00d53dc 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2491,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2501,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3038,7 +3048,7 @@ index 8fcf04b..00d53dc 100644 + } + return out; + } -+ for (const sub of selected) { ++ for (const sub of layers.slice(1)) { + // $FlowFixMe[prop-missing] dynamic shape + if (sub == null || typeof sub.name !== 'string') continue; + // $FlowFixMe[prop-missing] dynamic shape @@ -3155,7 +3165,7 @@ index 8fcf04b..00d53dc 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2661,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2671,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3447,7 +3457,7 @@ index 8fcf04b..00d53dc 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2944,13 @@ function readPodspecNames( +@@ -794,12 +2954,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3462,7 +3472,7 @@ index 8fcf04b..00d53dc 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2968,9 @@ function readPodspecNames( +@@ -817,8 +2978,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3474,7 +3484,7 @@ index 8fcf04b..00d53dc 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2986,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +2996,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 2c85986..eaac900 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -516,7 +516,7 @@ index 0000000..1536aa7 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..00d53dc 100644 +index 8fcf04b..032bc7c 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -2674,7 +2674,7 @@ index 8fcf04b..00d53dc 100644 }; } -@@ -423,10 +2074,140 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2074,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2768,8 +2768,10 @@ index 8fcf04b..00d53dc 100644 + * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for + * an iOS target: each value under its `ios` merged over the spec's. An + * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string -+ * read as a one-element array); two hashes merge key by key, two strings -+ * under one key joined by one space; anything else is the platform's value. ++ * read as a one-element array); two hashes merge key by key as CocoaPods' ++ * `merge_hash_value` does (two strings joined by one space, an array on ++ * either side concatenated with the other read as an array, any other pair ++ * the platform's value); anything else is the platform's value. + * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. + * The reduced reader's model has no `ios`: it is returned as it is. + */ @@ -2801,8 +2803,16 @@ index 8fcf04b..00d53dc 100644 + for (const k of Object.keys(platformHash)) { + const a = ownHash[k]; + const b = platformHash[k]; -+ merged[k] = -+ typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; ++ if (typeof a === 'string' && typeof b === 'string') { ++ merged[k] = `${a} ${b}`; ++ } else if (a != null && (Array.isArray(a) || Array.isArray(b))) { ++ merged[k] = [ ++ ...(Array.isArray(a) ? a : [a]), ++ ...(Array.isArray(b) ? b : [b]), ++ ].filter(v => v != null); ++ } else { ++ merged[k] = b; ++ } + } + out[key] = merged; + } else { @@ -2815,7 +2825,7 @@ index 8fcf04b..00d53dc 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2219,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2229,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2833,7 +2843,7 @@ index 8fcf04b..00d53dc 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2240,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2250,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2853,7 +2863,7 @@ index 8fcf04b..00d53dc 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2258,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2268,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2877,7 +2887,7 @@ index 8fcf04b..00d53dc 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2291,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2301,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2901,7 +2911,7 @@ index 8fcf04b..00d53dc 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2364,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2374,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2922,7 +2932,7 @@ index 8fcf04b..00d53dc 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2388,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2398,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -2947,7 +2957,7 @@ index 8fcf04b..00d53dc 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2421,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2431,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -2968,7 +2978,7 @@ index 8fcf04b..00d53dc 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2491,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2501,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3038,7 +3048,7 @@ index 8fcf04b..00d53dc 100644 + } + return out; + } -+ for (const sub of selected) { ++ for (const sub of layers.slice(1)) { + // $FlowFixMe[prop-missing] dynamic shape + if (sub == null || typeof sub.name !== 'string') continue; + // $FlowFixMe[prop-missing] dynamic shape @@ -3155,7 +3165,7 @@ index 8fcf04b..00d53dc 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2661,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2671,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3447,7 +3457,7 @@ index 8fcf04b..00d53dc 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2944,13 @@ function readPodspecNames( +@@ -794,12 +2954,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3462,7 +3472,7 @@ index 8fcf04b..00d53dc 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2968,9 @@ function readPodspecNames( +@@ -817,8 +2978,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3474,7 +3484,7 @@ index 8fcf04b..00d53dc 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2986,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +2996,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 07ed6c5..8d01f7c 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -453,7 +453,16 @@ describe("flattenSubspecs on the shim's model", () => { expect(m.headerDir).toBe("iosdir"); expect(m.requiresArc).toBe(true); expect(m.frameworks).toEqual(["UIKit", "WebKit"]); - expect(m.preprocessorDefines.map((d: { name: string }) => d.name)).toEqual(["A", "B", "IOS"]); + expect(m.preprocessorDefines.map((d: { name: string }) => d.name)).toEqual(["A", "B", "KEPT", "IOS"]); + }); + + it("merges a subspec's ios dependencies into its own", () => { + const m = flattenSubspecs({ + name: "Foo", + subspecs: [{ name: "c", dependencies: { A: [] }, ios: { dependencies: { B: [">= 1"] } }, osx: { dependencies: { C: [] } } }], + }); + expect(m.dependencies).toEqual(["A", "B"]); + expect(m.subspecDependencies).toEqual({ c: ["A", "B"] }); }); it("warns about keys the scaffold does not apply", () => { diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index 8a7e3df..a3ab7e6 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -161,7 +161,7 @@ resolveLocalHermesCompilerVersion, --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2872,9 +2872,15 @@ +@@ -2882,9 +2882,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 799b744..2d2eb43 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -2164,8 +2164,10 @@ const isHash = (v /*: mixed */) /*: boolean */ => * A spec (or subspec) of the shim's model as CocoaPods' consumer reads it for * an iOS target: each value under its `ios` merged over the spec's. An * ARRAY_ATTRIBUTES value is the spec's followed by the platform's (a string - * read as a one-element array); two hashes merge key by key, two strings - * under one key joined by one space; anything else is the platform's value. + * read as a one-element array); two hashes merge key by key as CocoaPods' + * `merge_hash_value` does (two strings joined by one space, an array on + * either side concatenated with the other read as an array, any other pair + * the platform's value); anything else is the platform's value. * The other platforms (`osx`, `tvos`, `visionos`, `watchos`) are never read. * The reduced reader's model has no `ios`: it is returned as it is. */ @@ -2197,8 +2199,16 @@ function mergeIos(layer /*: mixed */) /*: mixed */ { for (const k of Object.keys(platformHash)) { const a = ownHash[k]; const b = platformHash[k]; - merged[k] = - typeof a === 'string' && typeof b === 'string' ? `${a} ${b}` : b; + if (typeof a === 'string' && typeof b === 'string') { + merged[k] = `${a} ${b}`; + } else if (a != null && (Array.isArray(a) || Array.isArray(b))) { + merged[k] = [ + ...(Array.isArray(a) ? a : [a]), + ...(Array.isArray(b) ? b : [b]), + ].filter(v => v != null); + } else { + merged[k] = b; + } } out[key] = merged; } else { @@ -2546,7 +2556,7 @@ function flattenSubspecs( } return out; } - for (const sub of selected) { + for (const sub of layers.slice(1)) { // $FlowFixMe[prop-missing] dynamic shape if (sub == null || typeof sub.name !== 'string') continue; // $FlowFixMe[prop-missing] dynamic shape From 371ec7a9c439678132dcf67e42e27e7911463ae1 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 15:36:08 -0600 Subject: [PATCH 15/53] fix: stop rn-spm on a podspec reader failure --- docs/RELEASING.md | 2 +- patches/react-native+0.88.0.patch | 51 +++++++++++++++ patches/react-native+0.88.1.patch | 51 +++++++++++++++ tests/podspecReader.test.ts | 64 ++++++++++++++++++- tests/vendor-rn-spm.test.ts | 24 ++++++- vendor/rn-spm/README.md | 8 ++- vendor/rn-spm/rn-xtool-edits.patch | 29 +++++++++ vendor/rn-spm/spm/expand-spm-dependencies.js | 18 ++++-- vendor/rn-spm/spm/generate-spm-autolinking.js | 13 +++- 9 files changed, 248 insertions(+), 12 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 8321fa1..a7ae999 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -47,7 +47,7 @@ versions). Check the result: `npm view react-native-xtool dist-tags` and `npx re React Native's scaffolder ships twice: as `patches/react-native+0.88.0.patch` and its byte-identical copy `react-native+0.88.1.patch`, applied to an installed 0.88.x, and as `vendor/rn-spm/`, pristine 0.88.0 with that patch -and `vendor/rn-spm/rn-xtool-edits.patch` (E1–E5) applied, for 0.85–0.87 and Expo SDK 57. A change to the scaffolder: +and `vendor/rn-spm/rn-xtool-edits.patch` (E1–E6) applied, for 0.85–0.87 and Expo SDK 57. A change to the scaffolder: 1. Edits the vendored copy (`vendor/rn-spm/spm/*.js`), and documents the fix in [upstream/react-native-scaffolder.md](upstream/react-native-scaffolder.md) and the count in diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index eaac900..728d75b 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -1,3 +1,54 @@ +diff --git a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +index 872450e..79dd476 100644 +--- a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js ++++ b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +@@ -12,6 +12,7 @@ + + const { + findPodspecs, ++ isPodspecReadError, + readPodspecCached, + readPodspecNames, + } = require('./read-podspec'); +@@ -300,7 +301,8 @@ function expandSpmDependencies( + byName.set(dep.name, {...dep, spmDependencies: []}); + } + // A podspec that cannot be read leaves the name to the next precedence step, +- // rather than failing a build over a file only CocoaPods needs. ++ // rather than failing a build over a file only CocoaPods needs. One the ++ // podspec reader failed on stops the run with its message instead. + const podspecFor = ( + root /*: string */, + podspecPath /*: ?string */, +@@ -310,7 +312,10 @@ function expandSpmDependencies( + } + try { + return readPodspec(root, podspecPath); +- } catch { ++ } catch (e) { ++ if (isPodspecReadError(e)) { ++ throw e; ++ } + return null; + } + }; +@@ -478,9 +483,14 @@ function defaultReadPodspec( + } + try { + // Ruby-computed fields need the real evaluator; everything else is spared +- // the `pod ipc spec` spawn. ++ // the Ruby shim's spawn. + return readPodspecNames(found) ?? readPodspecCached(found); +- } catch { ++ } catch (e) { ++ // A file that cannot be read names nothing; a podspec the reader failed on ++ // stops the run. ++ if (isPodspecReadError(e)) { ++ throw e; ++ } + return null; + } + } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 index 0000000..1536aa7 diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index eaac900..728d75b 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -1,3 +1,54 @@ +diff --git a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +index 872450e..79dd476 100644 +--- a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js ++++ b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +@@ -12,6 +12,7 @@ + + const { + findPodspecs, ++ isPodspecReadError, + readPodspecCached, + readPodspecNames, + } = require('./read-podspec'); +@@ -300,7 +301,8 @@ function expandSpmDependencies( + byName.set(dep.name, {...dep, spmDependencies: []}); + } + // A podspec that cannot be read leaves the name to the next precedence step, +- // rather than failing a build over a file only CocoaPods needs. ++ // rather than failing a build over a file only CocoaPods needs. One the ++ // podspec reader failed on stops the run with its message instead. + const podspecFor = ( + root /*: string */, + podspecPath /*: ?string */, +@@ -310,7 +312,10 @@ function expandSpmDependencies( + } + try { + return readPodspec(root, podspecPath); +- } catch { ++ } catch (e) { ++ if (isPodspecReadError(e)) { ++ throw e; ++ } + return null; + } + }; +@@ -478,9 +483,14 @@ function defaultReadPodspec( + } + try { + // Ruby-computed fields need the real evaluator; everything else is spared +- // the `pod ipc spec` spawn. ++ // the Ruby shim's spawn. + return readPodspecNames(found) ?? readPodspecCached(found); +- } catch { ++ } catch (e) { ++ // A file that cannot be read names nothing; a podspec the reader failed on ++ // stops the run. ++ if (isPodspecReadError(e)) { ++ throw e; ++ } + return null; + } + } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 index 0000000..1536aa7 diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 8d01f7c..188930e 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -1,4 +1,4 @@ -import { chmodSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs"; +import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; @@ -582,3 +582,65 @@ describe("flattenSubspecs on the shim's model", () => { } }); }); + +describe("reader failures propagate", () => { + const { autolinkingDepToSpmTarget } = req("./generate-spm-autolinking.js"); + const { defaultReadPodspec, expandSpmDependencies } = req("./expand-spm-dependencies.js"); + beforeEach(() => { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + vi.stubEnv("RN_SPM_APP_IOS_DIR", undefined); + vi.stubEnv("RN_SPM_PODSPEC_READS", undefined); + }); + /** + * An installed copy ({@link installedCopy}) of `react-native-foo`, whose `Foo.podspec` is `podspec` (a symlink to + * nowhere when null), listed as autolinking.json lists it, with the autolinker's output folder beside its app's `ios/`. + */ + function installedDep(podspec: string | null) { + const src = path.dirname(library(spec(), { "package.json": JSON.stringify({ name: "react-native-foo", version: "1.0.0" }) })); + const root = installedCopy(src); + const podspecPath = path.join(root, "Foo.podspec"); + if (podspec == null) { + rmSync(podspecPath); + symlinkSync(path.join(root, "Missing.podspec"), podspecPath); + } else writeFileSync(podspecPath, podspec); + const base = path.resolve(root, "..", ".."); + vi.stubEnv("RN_SPM_RN_ROOT", path.join(base, "node_modules", "react-native")); + const dep = { name: "react-native-foo", root, swiftName: "Foo", platforms: { ios: { podspecPath, sourceDir: root } } }; + return { root, podspecPath, dep, outputDir: path.join(base, "ios", "build", "generated", "autolinking") }; + } + const expand = (dep: { name: string; root: string; platforms: object }, readPodspec: unknown) => + expandSpmDependencies([{ name: dep.name, root: dep.root, platforms: dep.platforms }], { + readConfig: () => null, + resolveDep: () => null, + readSwiftpmConfig: () => null, + readPodspec, + }); + + it.skipIf(needsRuby !== "")(`stops autolinking on a shim failure${needsRuby}`, () => { + const { podspecPath, dep, outputDir } = installedDep(spec(' s.source_files = sources_for("ios")')); + const e = thrown(() => autolinkingDepToSpmTarget(dep.name, dep, outputDir, new Map())); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("method"); + expect(e.message.startsWith(`${podspecPath}:`)).toBe(true); + }); + + it.skipIf(needsRuby !== "")(`stops name resolution on a shim failure${needsRuby}`, () => { + const { root, podspecPath, dep } = installedDep(["Pod::Spec.new do |s|", " s.name = compute_name()", "end"].join("\n")); + const e = thrown(() => defaultReadPodspec(root, podspecPath)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.message.startsWith(`${podspecPath}:`)).toBe(true); + expect(thrown(() => defaultReadPodspec(root, undefined)).message).toBe(e.message); + expect(thrown(() => expand(dep, defaultReadPodspec)).message).toBe(e.message); + }); + + it("keeps the old answer for an unreadable file", () => { + const { root, podspecPath, dep, outputDir } = installedDep(null); + expect(defaultReadPodspec(root, podspecPath)).toBeNull(); + expect(defaultReadPodspec(root, undefined)).toBeNull(); + expect(autolinkingDepToSpmTarget(dep.name, dep, outputDir, new Map())).toMatchObject({ name: "Foo", headerSearchPaths: undefined }); + const unreadable = () => { + throw new Error(`readPodspec: file does not exist: ${podspecPath}`); + }; + expect(expand(dep, unreadable)[0]).toMatchObject({ swiftNameSource: "npm" }); + }); +}); diff --git a/tests/vendor-rn-spm.test.ts b/tests/vendor-rn-spm.test.ts index ab8da54..7de77d5 100644 --- a/tests/vendor-rn-spm.test.ts +++ b/tests/vendor-rn-spm.test.ts @@ -1,5 +1,5 @@ import { createHash } from "node:crypto"; -import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import { tmpdir } from "node:os"; import path from "node:path"; @@ -45,6 +45,7 @@ const spmUtils = () => req("./spm-utils.js"); const downloader = () => req("./download-spm-artifacts.js"); const podspec = () => req("./read-podspec.js"); const plugins = () => req("./autolinking-plugins.js"); +const autolinking = () => req("./generate-spm-autolinking.js"); describe("vendor/rn-spm provenance", () => { provenance("the cached tarball is react-native 0.88.0", () => { @@ -171,6 +172,27 @@ describe("vendor/rn-spm dependencies and edits", () => { } }); + it("E6 stops autolinking's header-search-path read on a podspec reader failure", () => { + // A `ruby` that passes the reader's probe and then writes no model: the shim run fails without a real Ruby. + const bin = mkTmp("vendor-e6-bin-"); + writeFileSync(path.join(bin, "ruby"), `#!/bin/sh\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'\n`); + chmodSync(path.join(bin, "ruby"), 0o755); + const lib = mkTmp("vendor-e6-lib-"); + const podspecPath = path.join(lib, "Lib.podspec"); + writeFileSync(podspecPath, 'Pod::Spec.new do |s|\n s.name = "Lib"\nend\n'); + vi.stubEnv("PATH", bin); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + const dep = { name: "lib", root: lib, swiftName: "Lib", platforms: { ios: { podspecPath, sourceDir: lib } } }; + let e: any; + try { + autolinking().autolinkingDepToSpmTarget(dep.name, dep, path.join(lib, "out"), new Map()); + } catch (err) { + e = err; + } + expect(podspec().isPodspecReadError(e)).toBe(true); + expect(e.message.startsWith(`${podspecPath}: ruby exited with`)).toBe(true); + }); + it("E4 keeps a pre-headers-spec slot only when asked", () => { const slot = mkTmp("vendor-e4-"); const entries = () => ({ diff --git a/vendor/rn-spm/README.md b/vendor/rn-spm/README.md index 76382d6..d1d60d5 100644 --- a/vendor/rn-spm/README.md +++ b/vendor/rn-spm/README.md @@ -8,12 +8,14 @@ versions that ship no `scripts/spm` of their own. - Modifications, in order: 1. The 28 fixes of `docs/upstream/react-native-scaffolder.md`, applied with `patches/react-native+0.88.0.patch` (`patch -p4`, run in the extracted `scripts/`). - 2. Five rn-xtool edits (E1-E5) in `rn-xtool-edits.patch` (`patch -p1`, run in this directory): + 2. Six rn-xtool edits (E1-E6) in `rn-xtool-edits.patch` (`patch -p1`, run in this directory): the codegen template resolves relative to this copy, the installed React Native root comes - only from `RN_SPM_RN_ROOT`, `download-spm-artifacts.js` gains `--allow-pre-headers-spec`, and + only from `RN_SPM_RN_ROOT`, `download-spm-artifacts.js` gains `--allow-pre-headers-spec`, (E5) `spm/autolinking-plugins.js` takes the autolinking plugin of the dependency named `expo` from `RN_SPM_EXPO_PLUGIN` (an absolute path, set by the driver's `--expo-plugin`) when `expo` - declares none, which is the case for Expo SDK 57. + declares none, which is the case for Expo SDK 57, and (E6) `spm/generate-spm-autolinking.js` + rethrows a podspec reader failure from the header-search-path read instead of returning `[]` + (React Native 0.88.1 has no such read, so the 0.88 patches cannot carry it). - `package.json` (`{ "type": "commonjs" }`) is needed because rn-xtool is `"type": "module"`. - The `__dirname` candidates in `spm/spm-utils.js` and `setup-apple-spm.js` `resolveReactNativeRoot` are untouched and unreachable: the driver always passes `--react-native-root`. diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index a3ab7e6..3f85030 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -159,6 +159,35 @@ resolveCacheSlotVersion, resolveHermesArtifact, resolveLocalHermesCompilerVersion, +--- a/spm/generate-spm-autolinking.js ++++ b/spm/generate-spm-autolinking.js +@@ -71,7 +71,11 @@ + MIN_IOS_VERSION_SUPPORTED, + sanitizeIosDeploymentTarget, + } = require('./ios-deployment-target'); +-const {findPodspecs, readPodspecCached} = require('./read-podspec'); ++const { ++ findPodspecs, ++ isPodspecReadError, ++ readPodspecCached, ++} = require('./read-podspec'); + const { + AUTOLINKED_PACKAGE_NAME, + REACT_CODEGEN_PACKAGE_NAME, +@@ -833,7 +837,12 @@ + let model; + try { + model = readPodspecCached(podspecPath); +- } catch { ++ } catch (e) { ++ // A file that cannot be read adds no search paths; a podspec the reader ++ // failed on stops the run. ++ if (isPodspecReadError(e)) { ++ throw e; ++ } + return []; + } + --- a/spm/read-podspec.js +++ b/spm/read-podspec.js @@ -2882,9 +2882,15 @@ diff --git a/vendor/rn-spm/spm/expand-spm-dependencies.js b/vendor/rn-spm/spm/expand-spm-dependencies.js index 872450e..79dd476 100644 --- a/vendor/rn-spm/spm/expand-spm-dependencies.js +++ b/vendor/rn-spm/spm/expand-spm-dependencies.js @@ -12,6 +12,7 @@ const { findPodspecs, + isPodspecReadError, readPodspecCached, readPodspecNames, } = require('./read-podspec'); @@ -300,7 +301,8 @@ function expandSpmDependencies( byName.set(dep.name, {...dep, spmDependencies: []}); } // A podspec that cannot be read leaves the name to the next precedence step, - // rather than failing a build over a file only CocoaPods needs. + // rather than failing a build over a file only CocoaPods needs. One the + // podspec reader failed on stops the run with its message instead. const podspecFor = ( root /*: string */, podspecPath /*: ?string */, @@ -310,7 +312,10 @@ function expandSpmDependencies( } try { return readPodspec(root, podspecPath); - } catch { + } catch (e) { + if (isPodspecReadError(e)) { + throw e; + } return null; } }; @@ -478,9 +483,14 @@ function defaultReadPodspec( } try { // Ruby-computed fields need the real evaluator; everything else is spared - // the `pod ipc spec` spawn. + // the Ruby shim's spawn. return readPodspecNames(found) ?? readPodspecCached(found); - } catch { + } catch (e) { + // A file that cannot be read names nothing; a podspec the reader failed on + // stops the run. + if (isPodspecReadError(e)) { + throw e; + } return null; } } diff --git a/vendor/rn-spm/spm/generate-spm-autolinking.js b/vendor/rn-spm/spm/generate-spm-autolinking.js index 17ecbbe..bfcd5b8 100644 --- a/vendor/rn-spm/spm/generate-spm-autolinking.js +++ b/vendor/rn-spm/spm/generate-spm-autolinking.js @@ -71,7 +71,11 @@ const { MIN_IOS_VERSION_SUPPORTED, sanitizeIosDeploymentTarget, } = require('./ios-deployment-target'); -const {findPodspecs, readPodspecCached} = require('./read-podspec'); +const { + findPodspecs, + isPodspecReadError, + readPodspecCached, +} = require('./read-podspec'); const { AUTOLINKED_PACKAGE_NAME, REACT_CODEGEN_PACKAGE_NAME, @@ -833,7 +837,12 @@ function extractPodspecHeaderSearchPaths( let model; try { model = readPodspecCached(podspecPath); - } catch { + } catch (e) { + // A file that cannot be read adds no search paths; a podspec the reader + // failed on stops the run. + if (isPodspecReadError(e)) { + throw e; + } return []; } From 895366b9ad1c42dcace360bd6b067a848437d435 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 15:56:46 -0600 Subject: [PATCH 16/53] feat: record the podspec reader, revision 8 --- docs/upstream/react-native-scaffolder.md | 105 ++++++++++++++-- patches/react-native+0.88.0.patch | 100 +++++++++------ patches/react-native+0.88.1.patch | 100 +++++++++------ scripts/rn-spm-generate.js | 5 +- src/pipeline/patches.ts | 2 +- tests/capabilities.test.ts | 2 +- .../datetimepicker/Package.swift | 3 +- .../Package.swift | 7 +- .../react-native-pager-view/Package.swift | 3 +- .../Package@swift-6.5.swift | 3 +- .../react-native-screens/Package.swift | 3 +- .../react-native-svg/Package.swift | 3 +- .../react-native-webview/Package.swift | 3 +- tests/patches.test.ts | 56 +++++---- tests/podspecReader.test.ts | 6 +- tests/rn-scaffolder.test.ts | 118 +++++++++++++----- tests/rn-spm-generate.test.ts | 11 +- tests/support/rnScaffold.ts | 56 ++++++--- vendor/rn-spm/README.md | 2 +- vendor/rn-spm/spm/scaffold-package-swift.js | 18 ++- vendor/rn-spm/spm/spm-types.js | 2 + 21 files changed, 433 insertions(+), 175 deletions(-) diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 1867244..347a1f2 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -873,6 +873,90 @@ react-native-keychain, react-native-video, @aws-amplify/react-native) now get it its `FOLLY_*` defines stay dropped, as for every library. The scaffold revision moves to 6, then to 7 for the package.json defines revision 6 lost. +## 29. `scripts/spm/read-podspec.js`: podspecs are read without React Native's helpers, or in part + +`readPodspec` had two readers, and neither read a podspec as CocoaPods does. With CocoaPods installed it wrote a copy +of the podspec with `install_modules_dependencies(…)` and `use_react_native!(…)` commented out and ran `pod ipc spec` +on it. With the helpers stripped, `defined?(install_modules_dependencies())` and +`respond_to?(:install_modules_dependencies, true)` were false, so react-native-webview, +`@react-native-async-storage/async-storage`, react-native-keychain and react-native-video took their old-architecture +branch. And `flattenSubspecs`, which reads that JSON, read no `ios` key: in CocoaPods' JSON form an `s.ios.` attribute +lives under `"ios"`, so react-native-svg's `s.ios.exclude_files` did not apply there, while the regex path merged it +(fix 6). Without CocoaPods (every Linux machine), fix 28's evaluator read the subset of Ruby it models. It left out +the rest with a warning, such as react-native-gesture-handler 3.3.0's `-DRNGH_USE_WORKLETS=1`, which its own +`GestureHandlerUtils` computes by running `node`, or refused the library. So the same podspec gave a different model +on a machine with CocoaPods, and an incomplete one on a machine without. + +Fix: the podspec runs in real Ruby. `read-podspec-shim.rb`, next to `read-podspec.js`, is run by the system `ruby` +(2.7 or later, standard library only) once per podspec, in the podspec's folder, with an empty stdin, a 30 s timeout +and an environment of `PATH`, `HOME`, `LANG` and fix 19's two variables (`RCT_NEW_ARCH_ENABLED=1`, +`RCT_HERMES_V1_ENABLED=1`). It evaluates the podspec inside `module Pod`, as CocoaPods-core does, against a +`Pod::Specification` with the attributes of CocoaPods 1.16's DSL (a setter and a getter each, the singular aliases +stored under their plural keys), `dependency`, `subspec`, `test_spec`, `app_spec` and the platform proxies (`s.ios`, +`s.osx`, `s.tvos`, `s.visionos`, `s.watchos`; `s.macos` stores under `osx`). It writes the spec in CocoaPods' JSON +form, what `pod ipc spec` printed, so `flattenSubspecs` reads it unchanged. `ruby --probe` checks the Ruby +version before anything loads. + +The shim models what a static scan found called in the podspecs of the reference apps, of the Expo SDK 57 and 58 +references and of the podspec fixtures, and in the scripts they load. React Native's helpers: +`install_modules_dependencies` is recorded and adds nothing (the scaffold supplies React core and +`RCT_NEW_ARCH_ENABLED` from the record, which replaces the source regex `usesInstallModulesDependencies` used); +`add_dependency` adds the dependency and drops `subspec:`, as React Native's does; `get_folly_config` returns a fresh +hash of React Native's folly version, git URL and compiler flags on each call; `min_ios_version_supported` returns +`15.1`; and `spm_dependency` is recorded with its arguments. `defined?` and `respond_to?` answer for them as under +React Native's Podfile, and `use_expo_modules!` is not defined. Expo's `PackagesConfig` answers a source build +(`coreFeatures` is empty, `try_link_with_prebuilt_xcframework` is false). `Pod::UI` lines are captured, not printed. +`Pod::Config.instance` gives the app's `ios` folder as `installation_root` and `project_root` (`RN_SPM_APP_IOS_DIR` +when set, else the podspec's path cut before its first `/node_modules/` plus `/ios`, else the podspec's folder), that +folder's `Pods` as `project_pods_root`, and no `@podfile`. `Pod::VERSION` is `1.16.2`. `require` loads a name on +Ruby's own load path, the library's files by path, and a stub of `colored2`; `require_relative`, backticks, `system`, +`raise` and `abort` are real Ruby, so a library's own scripts run as under CocoaPods (worklets finds React Native, and +gesture-handler finds worklets, with `node`). Every `ENV` name the podspec reads is recorded; other environment +variables and globals are unset. React Native's other helpers stay undefined, and a call to one fails as `method`. + +A podspec Ruby cannot read stops the read with a `PodspecReadError`; nothing falls back. A gap of the shim names where +it stopped (`:`, or ` (:)` in another of the library's files): `method` (the +podspec calls `(…)`, which the reader does not model), `constant`, `attribute` (one CocoaPods does not define), +`require` (a gem other than `colored2`) or `not-a-spec`. Its message, like a podspec that does not finish in 30 s, +ends with `Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with +rn-xtool doctor --report.` A podspec's own `raise`, `abort`, `exit` or syntax error (`raised`) keeps Ruby's message, +and a Ruby that ends without a model says `ruby exited with ` with its last stderr line. Without a +usable Ruby (none, older than 2.7, no `json`, the shim missing), or with `RN_XTOOL_PODSPEC_READER=reduced`, fix 28's +evaluator reads the podspec as before, and `podspecReader()` says why; another value of the variable is named in a +warning and ignored. `name`, `module_name` and `version` stay the literal readings under both readers. +`readPodspecCached` keys on the reader too. When `RN_SPM_PODSPEC_READS` names a file, each read appends one JSON line +to it: the podspec, the reader and why, whether it was forced, the Ruby, the `ENV` names and helpers the podspec used, +and whether it read, with the error. + +`pod ipc spec` is never run (`patchPodspecForPodIpc`, `runPodIpcSpec` and `cleanupPatchedPodspec` are gone), so a +machine with CocoaPods reads a podspec as any machine with Ruby. `flattenSubspecs` merges each selected layer's `ios` +over it, as CocoaPods' consumer does for an iOS target: arrays concatenated, the layer's first (a string read as a +one-element array); hashes key by key, two strings joined by one space and an array on either side concatenated; +anything else the platform's value. `osx`, `tvos`, `visionos` and `watchos` are never read, and a subspec's `ios` +dependencies count when fix 20 drops a subspec. A key a CocoaPods build applies and the scaffold does not, in any +selected layer or its `ios`, gets a warning: `The podspec sets , which a CocoaPods build applies and rn-xtool's +scaffold does not.` for `script_phases`, `prepare_command`, `info_plist` and `module_map`. A podspec that calls +`spm_dependency` is refused with `status: 'error'` and `: uses spm_dependency(url: , products: ), +which rn-xtool does not map yet`: the target would not link without that package. + +The reader's callers caught every throw, which a reader that can fail would hide: the name facts (`podspecFor` and +`defaultReadPodspec` in `expand-spm-dependencies.js`) returned null, and the autolinking's header search paths +(`extractPodspecHeaderSearchPaths` in `generate-spm-autolinking.js`) returned `[]`. The three catches now rethrow a +`PodspecReadError` and keep their old answer for any other error, so a podspec Ruby cannot read stops autolinking with +its message. The two in `expand-spm-dependencies.js` are in the 0.88 patches. The third is edit E6 of +`vendor/rn-spm/rn-xtool-edits.patch`, in the vendored copy only: React Native 0.88.1 has no +`extractPodspecHeaderSearchPaths`, so the identical 0.88 patches cannot carry it, and on 0.88.0 the scaffold's own +read of the same podspec still stops. + +Each scaffolded manifest records its reader on the last line of the marker block, after the cache slot: +`// rn-xtool-podspec-reader: ruby` or `// rn-xtool-podspec-reader: reduced`, and the scaffold's result carries it as +`reader`. Effect on the libraries checked (the golden): react-native-gesture-handler 3.3.0 gets `RNGH_USE_WORKLETS=1` +when react-native-worklets 0.8 or later is installed, as under CocoaPods. react-native-webview 14.0.1 takes its +`install_modules_dependencies` branch, so the `-Wno-comma -Wno-shorten-64-to-32` that fix 28 read from its `else` +branch no longer apply. React Native 0.88's helper adds only `-DRCT_NEW_ARCH_ENABLED=1`, which the scaffold defines. +react-native-screens 4.30.0, react-native-pager-view 9.0.7, react-native-svg 15.16.0 and +`@react-native-community/datetimepicker` 9.2.1 scaffold as before. The scaffold revision moves to 8. + ## Known limitation (deferred): pure-Swift packages importing a mixed Expo module A Swift module built with a bridging header (every mixed target) makes each Swift importer re-read that @@ -885,11 +969,16 @@ every generated or scaffolded Swift target that depends on a mixed module the sa ## Tests -`tests/rn-scaffolder.test.ts` loads the patched modules from the reference app and checks the -fixes against fixtures (skipped when the reference app is not present; set `RN_XTOOL_REF_APP` to point at it). It also -asserts that each hunk is present in the installed RN files. Fixes 14 to 28 are tested on the vendored copy (`vendor/rn-spm/spm`), so they never skip, -against podspec fixtures from the SDK 57 pins in `tests/fixtures/podspecs/` (worklets 0.10.1, reanimated 4.5.1, -screens 4.26.2, gesture-handler 2.32.0), from screens 4.30.1 (the clang-only importer paths and module map), from -worklets 0.8.3 (the `RCT_HERMES_V1_ENABLED` ternary) and from screens 4.24.0 (fix 28's locals and conditions). A golden test re-scaffolds the reference app's libraries and compares them -with `tests/fixtures/scaffold-golden/`. Upstream, equivalent tests belong in -RN's own `__tests__` next to `read-podspec` and `scaffold-package-swift`. +`tests/rn-scaffolder.test.ts` loads the patched modules from the reference app and checks the fixes against fixtures +(skipped when the reference app is not present; set `RN_XTOOL_REF_APP` to point at it). It also asserts that each hunk +is present in the installed RN files. Fixes 14 to 29 are tested on the vendored copy (`vendor/rn-spm/spm`), so they +run without the reference app, against podspec fixtures from the SDK 57 pins in `tests/fixtures/podspecs/` (worklets +0.10.1, reanimated 4.5.1, screens 4.26.2, gesture-handler 2.32.0), from screens 4.30.1 (the clang-only importer paths +and module map), from worklets 0.8.3 (the `RCT_HERMES_V1_ENABLED` ternary) and from screens 4.24.0 (fix 28's locals +and conditions). Fix 29's shim is tested in `tests/podspecShim.test.ts` (also on Ruby 2.7, in CI's `shim-ruby-floor` +job), the reader's choice, its runs of the shim, `readPodspec`, the `ios` merge and the rethrows in +`tests/podspecReader.test.ts`, and the reader sweep (`tests/podspecReaderSweep.test.ts`) reads the podspecs of pinned +library tarballs with both readers against reviewed goldens. A golden test re-scaffolds the reference app's libraries, +read by Ruby, and compares them with `tests/fixtures/scaffold-golden/` (`RN_XTOOL_WRITE_GOLDEN=1` writes them +instead). Upstream, equivalent tests belong in RN's own `__tests__` next to `read-podspec` and +`scaffold-package-swift`. diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 728d75b..37ec321 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -3554,7 +3554,7 @@ index 8fcf04b..032bc7c 100644 + unresolvedSourcesReason, }; diff --git a/node_modules/react-native/scripts/spm/scaffold-package-swift.js b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -index cf7e587..0986d43 100644 +index cf7e587..75d9715 100644 --- a/node_modules/react-native/scripts/spm/scaffold-package-swift.js +++ b/node_modules/react-native/scripts/spm/scaffold-package-swift.js @@ -45,7 +45,12 @@ const { @@ -3579,7 +3579,7 @@ index cf7e587..0986d43 100644 } = require('./spm-utils'); const {readSwiftpmConfig, writeSwiftpmName} = require('./swiftpm-config'); const fs = require('node:fs'); -@@ -113,6 +119,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); +@@ -113,6 +119,289 @@ const {log, warn} = makeLogger('scaffold-package-swift'); const SCAFFOLDER_VERSION = 20; const SCAFFOLDER_VERSION_LINE_RE = /^\/\/ AUTO-SCAFFOLDED-VERSION: (\d+)$/m; @@ -3601,7 +3601,10 @@ index cf7e587..0986d43 100644 +// condition rules out left out of the target. Revision 7: the defines a +// podspec builds from its package.json and partly evaluated strings +// (react-native-worklets 0.8.3's WORKLETS_VERSION), which revision 6 lost. -+const RN_XTOOL_SCAFFOLD_REVISION = 7; ++// Revision 8 (fix 29): podspecs read by real Ruby through ++// read-podspec-shim.rb, `ios` attributes merged, and the reader recorded in ++// the marker. ++const RN_XTOOL_SCAFFOLD_REVISION = 8; +const RN_XTOOL_SCAFFOLD_REVISION_RE = /^\/\/ rn-xtool-scaffold-revision: (\d+)$/m; + +// An importer (Swift, or a Clang module) builds the target's module from its @@ -3651,6 +3654,11 @@ index cf7e587..0986d43 100644 +// the importer paths (or the revision line). +const POD_PINS_MARKER = '// rn-xtool-pods: '; + ++// Which reader read the podspec (fix 29): `ruby` (read-podspec-shim.rb) or ++// `reduced` (the reduced reader, without Ruby or when forced), on the line ++// after the cache slot, the last line of the marker block. ++const PODSPEC_READER_MARKER = '// rn-xtool-podspec-reader: '; ++ +// One pod table entry in its full shape; `product: string` is read as +// `products: [product]`. An entry with `binary` is a binary pod (fix 27) and +// its other keys are ignored. Throws with the key that has the wrong shape. @@ -3861,7 +3869,7 @@ index cf7e587..0986d43 100644 const AUTOGEN_MARKER = '// AUTO-GENERATED by scripts/generate-spm-autolinking.js'; -@@ -145,6 +426,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm +@@ -145,6 +434,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm #endif `; @@ -4235,7 +4243,7 @@ index cf7e587..0986d43 100644 // Names of deps the scaffolder always refuses to touch — `react-native` // itself is handled by the xcframework subpackage, never as an autolinked // target. -@@ -167,10 +815,27 @@ const REACT_CORE_DEP_PREFIXES = [ +@@ -167,10 +823,27 @@ const REACT_CORE_DEP_PREFIXES = [ 'DoubleConversion', 'Yoga', 'hermes-engine', @@ -4264,7 +4272,7 @@ index cf7e587..0986d43 100644 } // True when the dep ships a `codegenConfig` in package.json — RN's standard -@@ -248,6 +913,12 @@ function translatePodspecToSpmTarget( +@@ -248,6 +921,12 @@ function translatePodspecToSpmTarget( // npm name → resolved Swift name for every autolinked dep, so a sibling // reference honors that sibling's `spm.name` instead of re-deriving it. swiftNameByNpm /*: Map */ = new Map(), @@ -4277,7 +4285,7 @@ index cf7e587..0986d43 100644 ) /*: SpmScaffoldSpec */ { const warnings = [...model.warnings]; -@@ -322,46 +993,92 @@ function translatePodspecToSpmTarget( +@@ -322,46 +1001,92 @@ function translatePodspecToSpmTarget( } } @@ -4398,7 +4406,7 @@ index cf7e587..0986d43 100644 } } -@@ -427,15 +1144,55 @@ function translatePodspecToSpmTarget( +@@ -427,15 +1152,55 @@ function translatePodspecToSpmTarget( f => f !== SCAFFOLD_PREFIX_HEADER && f !== 'Package.swift' && @@ -4456,7 +4464,7 @@ index cf7e587..0986d43 100644 try { for (const f of expandSpmSourceGlobs(dep.root, model.publicHeaderFiles)) { if (/\.(h|hh|hpp)$/i.test(f)) headerFiles.push(f); -@@ -497,6 +1254,51 @@ function translatePodspecToSpmTarget( +@@ -497,6 +1262,51 @@ function translatePodspecToSpmTarget( } } let namespacedShimHeaders /*: Array */ = []; @@ -4508,7 +4516,7 @@ index cf7e587..0986d43 100644 if (publicHeadersPath == null) { // Root-level podspecs (`s.source_files = "*.{h,m,mm}"`) keep their // headers in the package root. CocoaPods exposes them to dependents as -@@ -518,6 +1320,101 @@ function translatePodspecToSpmTarget( +@@ -518,6 +1328,101 @@ function translatePodspecToSpmTarget( ); } @@ -4610,7 +4618,7 @@ index cf7e587..0986d43 100644 const siblingSwiftNames /*: {[npmName: string]: string} */ = {}; for (const npmName of siblingNames) { const resolved = swiftNameByNpm.get(npmName); -@@ -526,21 +1423,201 @@ function translatePodspecToSpmTarget( +@@ -526,21 +1431,201 @@ function translatePodspecToSpmTarget( } } @@ -4814,7 +4822,7 @@ index cf7e587..0986d43 100644 warnings, }; } -@@ -565,6 +1642,9 @@ type EmitContext = { +@@ -565,7 +1650,12 @@ type EmitContext = { // Relative path to the app's local xcframeworks package // (/build/xcframeworks). Only referenced when remote == null. localXcfwPackageDir?: ?string, @@ -4822,9 +4830,21 @@ index cf7e587..0986d43 100644 + // (/build/pod-binaries, fix 27). Only referenced for binary pods. + podBinariesPackageDir?: ?string, iosDeploymentTarget?: ?string, ++ // The reader that read the podspec (PODSPEC_READER_MARKER); no line without. ++ reader?: ?('ruby' | 'reduced'), }; */ -@@ -629,10 +1709,25 @@ function emitScaffoldedPackageSwift( + +@@ -582,6 +1672,8 @@ function emitScaffoldedPackageSwift( + ) /*: string */ { + const slotComment = + ctx.cacheSlotLabel != null ? `\n// Cache slot: ${ctx.cacheSlotLabel}` : ''; ++ const readerLine = ++ ctx.reader != null ? `\n${PODSPEC_READER_MARKER}${ctx.reader}` : ''; + const iosDeploymentTarget /*: string */ = + ctx.iosDeploymentTarget ?? MIN_IOS_VERSION_SUPPORTED; + +@@ -629,10 +1721,25 @@ function emitScaffoldedPackageSwift( const prefixFlag = spec.needsObjCPrefix ? `.unsafeFlags(["-include", "${SCAFFOLD_PREFIX_HEADER}"])` : ''; @@ -4851,7 +4871,7 @@ index cf7e587..0986d43 100644 ...(customFlagsCxx.length > 0 ? [`.unsafeFlags([${customFlagsCxx.join(', ')}])`] : []), -@@ -723,6 +1818,32 @@ function emitScaffoldedPackageSwift( +@@ -723,6 +1830,32 @@ function emitScaffoldedPackageSwift( `.product(name: "${swiftSibling}", package: "${swiftSibling}")`, ); } @@ -4884,7 +4904,7 @@ index cf7e587..0986d43 100644 // sources: emit only when the podspec declared them. If empty (regex-fallback // podspec), no `sources:`/`exclude:` is emitted and SPM auto-scans the target -@@ -740,6 +1861,11 @@ function emitScaffoldedPackageSwift( +@@ -740,6 +1873,11 @@ function emitScaffoldedPackageSwift( ? `\n publicHeadersPath: "${spec.publicHeadersPath}",` : ''; @@ -4896,7 +4916,7 @@ index cf7e587..0986d43 100644 const resourcesLine = spec.resources.length > 0 ? `\n resources: [${spec.resources.map(r => `.copy("${r}")`).join(', ')}],` -@@ -755,9 +1881,71 @@ function emitScaffoldedPackageSwift( +@@ -755,9 +1893,71 @@ function emitScaffoldedPackageSwift( ? `\n dependencies: [${targetDeps.join(', ')}],` : ''; @@ -4966,11 +4986,11 @@ index cf7e587..0986d43 100644 ${SCAFFOLDER_MARKER} -// AUTO-SCAFFOLDED-VERSION: ${SCAFFOLDER_VERSION}${slotComment} +// AUTO-SCAFFOLDED-VERSION: ${SCAFFOLDER_VERSION} -+// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment} ++// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment}${readerLine} // Edit the contents below if needed and re-run \`npx patch-package \` // to persist across \`npm install\`. To regenerate from the podspec, remove // this file (or just this marker) and re-run \`npx react-native spm scaffold\`. -@@ -768,7 +1956,7 @@ ${SCAFFOLDER_MARKER} +@@ -768,7 +1968,7 @@ ${SCAFFOLDER_MARKER} // (dropping the file) anyway. import PackageDescription @@ -4979,7 +4999,7 @@ index cf7e587..0986d43 100644 let package = Package( name: "${spec.swiftName}", platforms: [.iOS("${iosDeploymentTarget}")], -@@ -778,13 +1966,13 @@ let package = Package( +@@ -778,13 +1978,13 @@ let package = Package( ${packageDepsBlock} targets: [ .target( name: "${spec.swiftName}",${targetDepsLine} @@ -4996,7 +5016,7 @@ index cf7e587..0986d43 100644 ) `; } -@@ -844,6 +2032,61 @@ function reportSwiftName( +@@ -844,6 +2044,61 @@ function reportSwiftName( } } @@ -5058,7 +5078,7 @@ index cf7e587..0986d43 100644 // --------------------------------------------------------------------------- // Per-dep orchestrator // --------------------------------------------------------------------------- -@@ -953,7 +2196,11 @@ function scaffoldPackageSwiftForDep( +@@ -953,7 +2208,11 @@ function scaffoldPackageSwiftForDep( // regenerating existing files; --force is not needed here. const vMatch = existing.match(SCAFFOLDER_VERSION_LINE_RE); const existingVersion = vMatch != null ? parseInt(vMatch[1], 10) : 1; @@ -5071,7 +5091,7 @@ index cf7e587..0986d43 100644 if (!ctx.force && !versionStale) { // Slot label change is the other auto-regen trigger — bumps SPM's // manifest hash so the cache-slot path gets re-resolved. -@@ -970,7 +2217,7 @@ function scaffoldPackageSwiftForDep( +@@ -970,7 +2229,7 @@ function scaffoldPackageSwiftForDep( } if (versionStale) { log( @@ -5080,7 +5100,7 @@ index cf7e587..0986d43 100644 ); } // Fall through: regenerate (force, slot changed, or version bumped). -@@ -998,9 +2245,44 @@ function scaffoldPackageSwiftForDep( +@@ -998,9 +2257,44 @@ function scaffoldPackageSwiftForDep( }; } @@ -5125,7 +5145,7 @@ index cf7e587..0986d43 100644 } catch (e) { return { depName, -@@ -1008,39 +2290,33 @@ function scaffoldPackageSwiftForDep( +@@ -1008,39 +2302,33 @@ function scaffoldPackageSwiftForDep( reason: `Podspec read failed: ${e.message}`, }; } @@ -5186,15 +5206,16 @@ index cf7e587..0986d43 100644 // Relative paths into the app, embedded in the scaffolded Package.swift. // -@@ -1072,6 +2348,7 @@ function scaffoldPackageSwiftForDep( +@@ -1072,6 +2360,8 @@ function scaffoldPackageSwiftForDep( iosDeploymentTarget: ctx.iosDeploymentTarget, codegenPackageDir: relFromManifest('build', 'generated', 'ios'), localXcfwPackageDir: relFromManifest('build', 'xcframeworks'), + podBinariesPackageDir: relFromManifest('build', 'pod-binaries'), ++ reader: model.reader, }); // Distinguish "first-time scaffold" (no file at all) from "regenerate" -@@ -1081,15 +2358,36 @@ function scaffoldPackageSwiftForDep( +@@ -1081,15 +2371,36 @@ function scaffoldPackageSwiftForDep( // regens are silent because we're maintaining a file we already own. const previouslyExisted = fs.existsSync(pkgSwiftPath); @@ -5234,7 +5255,7 @@ index cf7e587..0986d43 100644 ); } // Mirror root-level headers into the generated include// shim -@@ -1099,18 +2397,96 @@ function scaffoldPackageSwiftForDep( +@@ -1099,18 +2410,96 @@ function scaffoldPackageSwiftForDep( const shimDir = path.join(dep.root, 'include', spec.swiftName); fs.mkdirSync(shimDir, {recursive: true}); for (const header of spec.namespacedShimHeaders) { @@ -5335,7 +5356,7 @@ index cf7e587..0986d43 100644 reportSwiftName(dep, spec.swiftName, model); // Migration: record a name we derived from the podspec, so the library can -@@ -1120,6 +2496,12 @@ function scaffoldPackageSwiftForDep( +@@ -1120,6 +2509,12 @@ function scaffoldPackageSwiftForDep( dep.swiftNameSource === 'podspec' ? writeSwiftpmName(dep.root, spec.swiftName, {dryRun: ctx.dryRun}) : undefined; @@ -5348,15 +5369,16 @@ index cf7e587..0986d43 100644 return { depName, -@@ -1128,6 +2510,7 @@ function scaffoldPackageSwiftForDep( +@@ -1128,6 +2523,8 @@ function scaffoldPackageSwiftForDep( warnings: spec.warnings, previouslyExisted, swiftpmName, + files: [...written].sort(), ++ reader: model.reader, }; } -@@ -1141,7 +2524,7 @@ function collectAutolinkedDeps( +@@ -1141,7 +2538,7 @@ function collectAutolinkedDeps( opts /*: { autolinkingJsonPath: string, remote: ?{url: string, version: string, identity: string}, @@ -5365,7 +5387,7 @@ index cf7e587..0986d43 100644 } */, ) /*: ?Array */ { const {autolinkingJsonPath, remote, onSkipped} = opts; -@@ -1162,7 +2545,7 @@ function collectAutolinkedDeps( +@@ -1162,7 +2559,7 @@ function collectAutolinkedDeps( const root = raw.root; const ios = raw.platforms?.ios; if (typeof root !== 'string' || ios == null) { @@ -5374,7 +5396,7 @@ index cf7e587..0986d43 100644 continue; } // $FlowFixMe[incompatible-type] `ios` shape is runtime-validated above -@@ -1294,6 +2677,11 @@ type ScaffoldAllOptions = { +@@ -1294,6 +2691,11 @@ type ScaffoldAllOptions = { // confirmation prompt for first-time scaffolds. Skipped deps still // appear in the returned results array with status='skipped-opt-out'. skipDeps?: ReadonlyArray, @@ -5386,7 +5408,7 @@ index cf7e587..0986d43 100644 }; */ -@@ -1323,6 +2711,17 @@ function scaffoldAll( +@@ -1323,6 +2725,17 @@ function scaffoldAll( // scaffolded here — leaving `react-native spm scaffold` unable to clear the // autolinker's missing-manifest error. const results /*: Array */ = []; @@ -5404,7 +5426,7 @@ index cf7e587..0986d43 100644 // Outside collectAutolinkedDeps' own try: a malformed remote config // (RemoteVersionError) is a misconfiguration to surface, not an expansion // failure to degrade past. -@@ -1330,24 +2729,23 @@ function scaffoldAll( +@@ -1330,24 +2743,23 @@ function scaffoldAll( const allDeps = collectAutolinkedDeps({ autolinkingJsonPath, remote, @@ -5440,7 +5462,7 @@ index cf7e587..0986d43 100644 for (const dep of allDeps) { const podspecPath = dep.platforms?.ios?.podspecPath; if (typeof podspecPath === 'string' && podspecPath.length > 0) { -@@ -1386,6 +2784,9 @@ function scaffoldAll( +@@ -1386,6 +2798,9 @@ function scaffoldAll( const skipSet /*: Set */ = new Set(opts.skipDeps ?? []); for (const dep of allDeps) { @@ -5450,7 +5472,7 @@ index cf7e587..0986d43 100644 if (skipSet.has(dep.name)) { results.push({ depName: dep.name, -@@ -1404,6 +2805,9 @@ function scaffoldAll( +@@ -1404,6 +2819,9 @@ function scaffoldAll( } module.exports = { @@ -5461,7 +5483,7 @@ index cf7e587..0986d43 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..4493621 100644 +index a89142f..4eb4089 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5556,13 +5578,15 @@ index a89142f..4493621 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +555,9 @@ export type ScaffoldResult = +@@ -539,6 +555,11 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, + // Every file the scaffold wrote under the library, relative to its root + // (posix separators), sorted. + files: Array, ++ // Which reader read the podspec (PodspecModel.reader). ++ reader: 'ruby' | 'reduced', } | { depName: string, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 728d75b..37ec321 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -3554,7 +3554,7 @@ index 8fcf04b..032bc7c 100644 + unresolvedSourcesReason, }; diff --git a/node_modules/react-native/scripts/spm/scaffold-package-swift.js b/node_modules/react-native/scripts/spm/scaffold-package-swift.js -index cf7e587..0986d43 100644 +index cf7e587..75d9715 100644 --- a/node_modules/react-native/scripts/spm/scaffold-package-swift.js +++ b/node_modules/react-native/scripts/spm/scaffold-package-swift.js @@ -45,7 +45,12 @@ const { @@ -3579,7 +3579,7 @@ index cf7e587..0986d43 100644 } = require('./spm-utils'); const {readSwiftpmConfig, writeSwiftpmName} = require('./swiftpm-config'); const fs = require('node:fs'); -@@ -113,6 +119,281 @@ const {log, warn} = makeLogger('scaffold-package-swift'); +@@ -113,6 +119,289 @@ const {log, warn} = makeLogger('scaffold-package-swift'); const SCAFFOLDER_VERSION = 20; const SCAFFOLDER_VERSION_LINE_RE = /^\/\/ AUTO-SCAFFOLDED-VERSION: (\d+)$/m; @@ -3601,7 +3601,10 @@ index cf7e587..0986d43 100644 +// condition rules out left out of the target. Revision 7: the defines a +// podspec builds from its package.json and partly evaluated strings +// (react-native-worklets 0.8.3's WORKLETS_VERSION), which revision 6 lost. -+const RN_XTOOL_SCAFFOLD_REVISION = 7; ++// Revision 8 (fix 29): podspecs read by real Ruby through ++// read-podspec-shim.rb, `ios` attributes merged, and the reader recorded in ++// the marker. ++const RN_XTOOL_SCAFFOLD_REVISION = 8; +const RN_XTOOL_SCAFFOLD_REVISION_RE = /^\/\/ rn-xtool-scaffold-revision: (\d+)$/m; + +// An importer (Swift, or a Clang module) builds the target's module from its @@ -3651,6 +3654,11 @@ index cf7e587..0986d43 100644 +// the importer paths (or the revision line). +const POD_PINS_MARKER = '// rn-xtool-pods: '; + ++// Which reader read the podspec (fix 29): `ruby` (read-podspec-shim.rb) or ++// `reduced` (the reduced reader, without Ruby or when forced), on the line ++// after the cache slot, the last line of the marker block. ++const PODSPEC_READER_MARKER = '// rn-xtool-podspec-reader: '; ++ +// One pod table entry in its full shape; `product: string` is read as +// `products: [product]`. An entry with `binary` is a binary pod (fix 27) and +// its other keys are ignored. Throws with the key that has the wrong shape. @@ -3861,7 +3869,7 @@ index cf7e587..0986d43 100644 const AUTOGEN_MARKER = '// AUTO-GENERATED by scripts/generate-spm-autolinking.js'; -@@ -145,6 +426,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm +@@ -145,6 +434,373 @@ const SCAFFOLD_PREFIX_HEADER_CONTENTS = `// AUTO-SCAFFOLDED by react-native spm #endif `; @@ -4235,7 +4243,7 @@ index cf7e587..0986d43 100644 // Names of deps the scaffolder always refuses to touch — `react-native` // itself is handled by the xcframework subpackage, never as an autolinked // target. -@@ -167,10 +815,27 @@ const REACT_CORE_DEP_PREFIXES = [ +@@ -167,10 +823,27 @@ const REACT_CORE_DEP_PREFIXES = [ 'DoubleConversion', 'Yoga', 'hermes-engine', @@ -4264,7 +4272,7 @@ index cf7e587..0986d43 100644 } // True when the dep ships a `codegenConfig` in package.json — RN's standard -@@ -248,6 +913,12 @@ function translatePodspecToSpmTarget( +@@ -248,6 +921,12 @@ function translatePodspecToSpmTarget( // npm name → resolved Swift name for every autolinked dep, so a sibling // reference honors that sibling's `spm.name` instead of re-deriving it. swiftNameByNpm /*: Map */ = new Map(), @@ -4277,7 +4285,7 @@ index cf7e587..0986d43 100644 ) /*: SpmScaffoldSpec */ { const warnings = [...model.warnings]; -@@ -322,46 +993,92 @@ function translatePodspecToSpmTarget( +@@ -322,46 +1001,92 @@ function translatePodspecToSpmTarget( } } @@ -4398,7 +4406,7 @@ index cf7e587..0986d43 100644 } } -@@ -427,15 +1144,55 @@ function translatePodspecToSpmTarget( +@@ -427,15 +1152,55 @@ function translatePodspecToSpmTarget( f => f !== SCAFFOLD_PREFIX_HEADER && f !== 'Package.swift' && @@ -4456,7 +4464,7 @@ index cf7e587..0986d43 100644 try { for (const f of expandSpmSourceGlobs(dep.root, model.publicHeaderFiles)) { if (/\.(h|hh|hpp)$/i.test(f)) headerFiles.push(f); -@@ -497,6 +1254,51 @@ function translatePodspecToSpmTarget( +@@ -497,6 +1262,51 @@ function translatePodspecToSpmTarget( } } let namespacedShimHeaders /*: Array */ = []; @@ -4508,7 +4516,7 @@ index cf7e587..0986d43 100644 if (publicHeadersPath == null) { // Root-level podspecs (`s.source_files = "*.{h,m,mm}"`) keep their // headers in the package root. CocoaPods exposes them to dependents as -@@ -518,6 +1320,101 @@ function translatePodspecToSpmTarget( +@@ -518,6 +1328,101 @@ function translatePodspecToSpmTarget( ); } @@ -4610,7 +4618,7 @@ index cf7e587..0986d43 100644 const siblingSwiftNames /*: {[npmName: string]: string} */ = {}; for (const npmName of siblingNames) { const resolved = swiftNameByNpm.get(npmName); -@@ -526,21 +1423,201 @@ function translatePodspecToSpmTarget( +@@ -526,21 +1431,201 @@ function translatePodspecToSpmTarget( } } @@ -4814,7 +4822,7 @@ index cf7e587..0986d43 100644 warnings, }; } -@@ -565,6 +1642,9 @@ type EmitContext = { +@@ -565,7 +1650,12 @@ type EmitContext = { // Relative path to the app's local xcframeworks package // (/build/xcframeworks). Only referenced when remote == null. localXcfwPackageDir?: ?string, @@ -4822,9 +4830,21 @@ index cf7e587..0986d43 100644 + // (/build/pod-binaries, fix 27). Only referenced for binary pods. + podBinariesPackageDir?: ?string, iosDeploymentTarget?: ?string, ++ // The reader that read the podspec (PODSPEC_READER_MARKER); no line without. ++ reader?: ?('ruby' | 'reduced'), }; */ -@@ -629,10 +1709,25 @@ function emitScaffoldedPackageSwift( + +@@ -582,6 +1672,8 @@ function emitScaffoldedPackageSwift( + ) /*: string */ { + const slotComment = + ctx.cacheSlotLabel != null ? `\n// Cache slot: ${ctx.cacheSlotLabel}` : ''; ++ const readerLine = ++ ctx.reader != null ? `\n${PODSPEC_READER_MARKER}${ctx.reader}` : ''; + const iosDeploymentTarget /*: string */ = + ctx.iosDeploymentTarget ?? MIN_IOS_VERSION_SUPPORTED; + +@@ -629,10 +1721,25 @@ function emitScaffoldedPackageSwift( const prefixFlag = spec.needsObjCPrefix ? `.unsafeFlags(["-include", "${SCAFFOLD_PREFIX_HEADER}"])` : ''; @@ -4851,7 +4871,7 @@ index cf7e587..0986d43 100644 ...(customFlagsCxx.length > 0 ? [`.unsafeFlags([${customFlagsCxx.join(', ')}])`] : []), -@@ -723,6 +1818,32 @@ function emitScaffoldedPackageSwift( +@@ -723,6 +1830,32 @@ function emitScaffoldedPackageSwift( `.product(name: "${swiftSibling}", package: "${swiftSibling}")`, ); } @@ -4884,7 +4904,7 @@ index cf7e587..0986d43 100644 // sources: emit only when the podspec declared them. If empty (regex-fallback // podspec), no `sources:`/`exclude:` is emitted and SPM auto-scans the target -@@ -740,6 +1861,11 @@ function emitScaffoldedPackageSwift( +@@ -740,6 +1873,11 @@ function emitScaffoldedPackageSwift( ? `\n publicHeadersPath: "${spec.publicHeadersPath}",` : ''; @@ -4896,7 +4916,7 @@ index cf7e587..0986d43 100644 const resourcesLine = spec.resources.length > 0 ? `\n resources: [${spec.resources.map(r => `.copy("${r}")`).join(', ')}],` -@@ -755,9 +1881,71 @@ function emitScaffoldedPackageSwift( +@@ -755,9 +1893,71 @@ function emitScaffoldedPackageSwift( ? `\n dependencies: [${targetDeps.join(', ')}],` : ''; @@ -4966,11 +4986,11 @@ index cf7e587..0986d43 100644 ${SCAFFOLDER_MARKER} -// AUTO-SCAFFOLDED-VERSION: ${SCAFFOLDER_VERSION}${slotComment} +// AUTO-SCAFFOLDED-VERSION: ${SCAFFOLDER_VERSION} -+// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment} ++// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment}${readerLine} // Edit the contents below if needed and re-run \`npx patch-package \` // to persist across \`npm install\`. To regenerate from the podspec, remove // this file (or just this marker) and re-run \`npx react-native spm scaffold\`. -@@ -768,7 +1956,7 @@ ${SCAFFOLDER_MARKER} +@@ -768,7 +1968,7 @@ ${SCAFFOLDER_MARKER} // (dropping the file) anyway. import PackageDescription @@ -4979,7 +4999,7 @@ index cf7e587..0986d43 100644 let package = Package( name: "${spec.swiftName}", platforms: [.iOS("${iosDeploymentTarget}")], -@@ -778,13 +1966,13 @@ let package = Package( +@@ -778,13 +1978,13 @@ let package = Package( ${packageDepsBlock} targets: [ .target( name: "${spec.swiftName}",${targetDepsLine} @@ -4996,7 +5016,7 @@ index cf7e587..0986d43 100644 ) `; } -@@ -844,6 +2032,61 @@ function reportSwiftName( +@@ -844,6 +2044,61 @@ function reportSwiftName( } } @@ -5058,7 +5078,7 @@ index cf7e587..0986d43 100644 // --------------------------------------------------------------------------- // Per-dep orchestrator // --------------------------------------------------------------------------- -@@ -953,7 +2196,11 @@ function scaffoldPackageSwiftForDep( +@@ -953,7 +2208,11 @@ function scaffoldPackageSwiftForDep( // regenerating existing files; --force is not needed here. const vMatch = existing.match(SCAFFOLDER_VERSION_LINE_RE); const existingVersion = vMatch != null ? parseInt(vMatch[1], 10) : 1; @@ -5071,7 +5091,7 @@ index cf7e587..0986d43 100644 if (!ctx.force && !versionStale) { // Slot label change is the other auto-regen trigger — bumps SPM's // manifest hash so the cache-slot path gets re-resolved. -@@ -970,7 +2217,7 @@ function scaffoldPackageSwiftForDep( +@@ -970,7 +2229,7 @@ function scaffoldPackageSwiftForDep( } if (versionStale) { log( @@ -5080,7 +5100,7 @@ index cf7e587..0986d43 100644 ); } // Fall through: regenerate (force, slot changed, or version bumped). -@@ -998,9 +2245,44 @@ function scaffoldPackageSwiftForDep( +@@ -998,9 +2257,44 @@ function scaffoldPackageSwiftForDep( }; } @@ -5125,7 +5145,7 @@ index cf7e587..0986d43 100644 } catch (e) { return { depName, -@@ -1008,39 +2290,33 @@ function scaffoldPackageSwiftForDep( +@@ -1008,39 +2302,33 @@ function scaffoldPackageSwiftForDep( reason: `Podspec read failed: ${e.message}`, }; } @@ -5186,15 +5206,16 @@ index cf7e587..0986d43 100644 // Relative paths into the app, embedded in the scaffolded Package.swift. // -@@ -1072,6 +2348,7 @@ function scaffoldPackageSwiftForDep( +@@ -1072,6 +2360,8 @@ function scaffoldPackageSwiftForDep( iosDeploymentTarget: ctx.iosDeploymentTarget, codegenPackageDir: relFromManifest('build', 'generated', 'ios'), localXcfwPackageDir: relFromManifest('build', 'xcframeworks'), + podBinariesPackageDir: relFromManifest('build', 'pod-binaries'), ++ reader: model.reader, }); // Distinguish "first-time scaffold" (no file at all) from "regenerate" -@@ -1081,15 +2358,36 @@ function scaffoldPackageSwiftForDep( +@@ -1081,15 +2371,36 @@ function scaffoldPackageSwiftForDep( // regens are silent because we're maintaining a file we already own. const previouslyExisted = fs.existsSync(pkgSwiftPath); @@ -5234,7 +5255,7 @@ index cf7e587..0986d43 100644 ); } // Mirror root-level headers into the generated include// shim -@@ -1099,18 +2397,96 @@ function scaffoldPackageSwiftForDep( +@@ -1099,18 +2410,96 @@ function scaffoldPackageSwiftForDep( const shimDir = path.join(dep.root, 'include', spec.swiftName); fs.mkdirSync(shimDir, {recursive: true}); for (const header of spec.namespacedShimHeaders) { @@ -5335,7 +5356,7 @@ index cf7e587..0986d43 100644 reportSwiftName(dep, spec.swiftName, model); // Migration: record a name we derived from the podspec, so the library can -@@ -1120,6 +2496,12 @@ function scaffoldPackageSwiftForDep( +@@ -1120,6 +2509,12 @@ function scaffoldPackageSwiftForDep( dep.swiftNameSource === 'podspec' ? writeSwiftpmName(dep.root, spec.swiftName, {dryRun: ctx.dryRun}) : undefined; @@ -5348,15 +5369,16 @@ index cf7e587..0986d43 100644 return { depName, -@@ -1128,6 +2510,7 @@ function scaffoldPackageSwiftForDep( +@@ -1128,6 +2523,8 @@ function scaffoldPackageSwiftForDep( warnings: spec.warnings, previouslyExisted, swiftpmName, + files: [...written].sort(), ++ reader: model.reader, }; } -@@ -1141,7 +2524,7 @@ function collectAutolinkedDeps( +@@ -1141,7 +2538,7 @@ function collectAutolinkedDeps( opts /*: { autolinkingJsonPath: string, remote: ?{url: string, version: string, identity: string}, @@ -5365,7 +5387,7 @@ index cf7e587..0986d43 100644 } */, ) /*: ?Array */ { const {autolinkingJsonPath, remote, onSkipped} = opts; -@@ -1162,7 +2545,7 @@ function collectAutolinkedDeps( +@@ -1162,7 +2559,7 @@ function collectAutolinkedDeps( const root = raw.root; const ios = raw.platforms?.ios; if (typeof root !== 'string' || ios == null) { @@ -5374,7 +5396,7 @@ index cf7e587..0986d43 100644 continue; } // $FlowFixMe[incompatible-type] `ios` shape is runtime-validated above -@@ -1294,6 +2677,11 @@ type ScaffoldAllOptions = { +@@ -1294,6 +2691,11 @@ type ScaffoldAllOptions = { // confirmation prompt for first-time scaffolds. Skipped deps still // appear in the returned results array with status='skipped-opt-out'. skipDeps?: ReadonlyArray, @@ -5386,7 +5408,7 @@ index cf7e587..0986d43 100644 }; */ -@@ -1323,6 +2711,17 @@ function scaffoldAll( +@@ -1323,6 +2725,17 @@ function scaffoldAll( // scaffolded here — leaving `react-native spm scaffold` unable to clear the // autolinker's missing-manifest error. const results /*: Array */ = []; @@ -5404,7 +5426,7 @@ index cf7e587..0986d43 100644 // Outside collectAutolinkedDeps' own try: a malformed remote config // (RemoteVersionError) is a misconfiguration to surface, not an expansion // failure to degrade past. -@@ -1330,24 +2729,23 @@ function scaffoldAll( +@@ -1330,24 +2743,23 @@ function scaffoldAll( const allDeps = collectAutolinkedDeps({ autolinkingJsonPath, remote, @@ -5440,7 +5462,7 @@ index cf7e587..0986d43 100644 for (const dep of allDeps) { const podspecPath = dep.platforms?.ios?.podspecPath; if (typeof podspecPath === 'string' && podspecPath.length > 0) { -@@ -1386,6 +2784,9 @@ function scaffoldAll( +@@ -1386,6 +2798,9 @@ function scaffoldAll( const skipSet /*: Set */ = new Set(opts.skipDeps ?? []); for (const dep of allDeps) { @@ -5450,7 +5472,7 @@ index cf7e587..0986d43 100644 if (skipSet.has(dep.name)) { results.push({ depName: dep.name, -@@ -1404,6 +2805,9 @@ function scaffoldAll( +@@ -1404,6 +2819,9 @@ function scaffoldAll( } module.exports = { @@ -5461,7 +5483,7 @@ index cf7e587..0986d43 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..4493621 100644 +index a89142f..4eb4089 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5556,13 +5578,15 @@ index a89142f..4493621 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +555,9 @@ export type ScaffoldResult = +@@ -539,6 +555,11 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, + // Every file the scaffold wrote under the library, relative to its root + // (posix separators), sorted. + files: Array, ++ // Which reader read the podspec (PodspecModel.reader). ++ reader: 'ruby' | 'reduced', } | { depName: string, diff --git a/scripts/rn-spm-generate.js b/scripts/rn-spm-generate.js index a8d7897..9e52736 100644 --- a/scripts/rn-spm-generate.js +++ b/scripts/rn-spm-generate.js @@ -220,8 +220,8 @@ async function scaffold(rn, scaffoldAll, opts, resultsPath) { } } -// rn-xtool reads this to tell which named library failed, and why, before anything is persisted, and -// which files each scaffold wrote, which is what it persists. +// rn-xtool reads this to tell which named library failed, and why, before anything is persisted, which +// files each scaffold wrote, which is what it persists, and which reader read its podspec. function writeResults(file, results, autolinkingJsonPath) { let deps = {}; try { @@ -236,6 +236,7 @@ function writeResults(file, results, autolinkingJsonPath) { ...(r.warnings != null && r.warnings.length > 0 ? {warnings: r.warnings} : {}), ...(typeof root === 'string' ? {root} : {}), ...(Array.isArray(r.files) ? {files: r.files} : {}), + ...(r.reader != null ? {reader: r.reader} : {}), }; }); fs.mkdirSync(path.dirname(file), {recursive: true}); diff --git a/src/pipeline/patches.ts b/src/pipeline/patches.ts index 07ff7bd..0b78850 100644 --- a/src/pipeline/patches.ts +++ b/src/pipeline/patches.ts @@ -359,7 +359,7 @@ const SLOT_LABEL_RE = /^\+\/\/ Cache slot: (\S+)\/dual-flavor\s*$/m; const REVISION_RE = /^\+\/\/ (?:rn|expo)-xtool-scaffold-revision: (\d+)\s*$/m; /** The scaffolder's RN_XTOOL_SCAFFOLD_REVISION (patches/react-native+0.88.{0,1}.patch and vendor/rn-spm). */ -export const SCAFFOLD_REVISION = 7; +export const SCAFFOLD_REVISION = 8; const PATCH_PODS_RE = /^\+\/\/ rn-xtool-pods: (.*?)\s*$/m; const MANIFEST_PODS_RE = /^\/\/ rn-xtool-pods: (.*?)\s*$/m; diff --git a/tests/capabilities.test.ts b/tests/capabilities.test.ts index 9e04963..09d4b48 100644 --- a/tests/capabilities.test.ts +++ b/tests/capabilities.test.ts @@ -605,7 +605,7 @@ describe("detectCapabilities", () => { }); const lines = [ "// AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package.", - "// rn-xtool-scaffold-revision: 7", + "// rn-xtool-scaffold-revision: 8", "// rn-xtool-pods: AppAuth=3.0.0", "// Cache slot: 0.88.1/dual-flavor", ]; diff --git a/tests/fixtures/scaffold-golden/@react-native-community/datetimepicker/Package.swift b/tests/fixtures/scaffold-golden/@react-native-community/datetimepicker/Package.swift index b1c6028..02187e7 100644 --- a/tests/fixtures/scaffold-golden/@react-native-community/datetimepicker/Package.swift +++ b/tests/fixtures/scaffold-golden/@react-native-community/datetimepicker/Package.swift @@ -1,9 +1,10 @@ // swift-tools-version: 6.0 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["ios","ios/fabric","ios/fabric/cpp/react/renderer/components/RNDateTimePicker","."] // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/fixtures/scaffold-golden/react-native-gesture-handler/Package.swift b/tests/fixtures/scaffold-golden/react-native-gesture-handler/Package.swift index 08d0812..bdc52db 100644 --- a/tests/fixtures/scaffold-golden/react-native-gesture-handler/Package.swift +++ b/tests/fixtures/scaffold-golden/react-native-gesture-handler/Package.swift @@ -1,9 +1,10 @@ // swift-tools-version: 6.0 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["apple/Handlers","apple","shared/runtime","shared/shadowNodes/react/renderer/components/rngesturehandler_codegen","."] // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. @@ -98,8 +99,8 @@ let package = Package( "shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorState.h", ], publicHeadersPath: "include", - cSettings: [.define("RCT_NEW_ARCH_ENABLED", to: "1"), .headerSearchPath("apple/Handlers"), .headerSearchPath("apple"), .headerSearchPath("shared/runtime"), .headerSearchPath("shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), .headerSearchPath("."), .unsafeFlags(["-include", "react-native-spm-prefix.h"])], - cxxSettings: [.define("RCT_NEW_ARCH_ENABLED", to: "1"), .headerSearchPath("apple/Handlers"), .headerSearchPath("apple"), .headerSearchPath("shared/runtime"), .headerSearchPath("shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), .headerSearchPath("."), .unsafeFlags(["-include", "react-native-spm-prefix.h"]), .define("DEBUG", .when(configuration: .debug)), .define("NDEBUG", .when(configuration: .release))], + cSettings: [.define("RNGH_USE_WORKLETS", to: "1"), .define("RCT_NEW_ARCH_ENABLED", to: "1"), .headerSearchPath("apple/Handlers"), .headerSearchPath("apple"), .headerSearchPath("shared/runtime"), .headerSearchPath("shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), .headerSearchPath("."), .unsafeFlags(["-include", "react-native-spm-prefix.h"])], + cxxSettings: [.define("RNGH_USE_WORKLETS", to: "1"), .define("RCT_NEW_ARCH_ENABLED", to: "1"), .headerSearchPath("apple/Handlers"), .headerSearchPath("apple"), .headerSearchPath("shared/runtime"), .headerSearchPath("shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), .headerSearchPath("."), .unsafeFlags(["-include", "react-native-spm-prefix.h"]), .define("DEBUG", .when(configuration: .debug)), .define("NDEBUG", .when(configuration: .release))], linkerSettings: [.linkedFramework("UIKit"), .linkedFramework("Foundation"), .linkedFramework("CoreGraphics")] ), ], diff --git a/tests/fixtures/scaffold-golden/react-native-pager-view/Package.swift b/tests/fixtures/scaffold-golden/react-native-pager-view/Package.swift index ea3c025..c2e9293 100644 --- a/tests/fixtures/scaffold-golden/react-native-pager-view/Package.swift +++ b/tests/fixtures/scaffold-golden/react-native-pager-view/Package.swift @@ -1,10 +1,11 @@ // swift-tools-version: 6.4;(experimentalMultiLang) // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["ios",".","rn-spm-swift"] // rn-xtool-pods: SwiftUIIntrospect=1.5.0 // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/fixtures/scaffold-golden/react-native-pager-view/Package@swift-6.5.swift b/tests/fixtures/scaffold-golden/react-native-pager-view/Package@swift-6.5.swift index 83bee0e..42761f7 100644 --- a/tests/fixtures/scaffold-golden/react-native-pager-view/Package@swift-6.5.swift +++ b/tests/fixtures/scaffold-golden/react-native-pager-view/Package@swift-6.5.swift @@ -1,10 +1,11 @@ // swift-tools-version: 6.5 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["ios",".","rn-spm-swift"] // rn-xtool-pods: SwiftUIIntrospect=1.5.0 // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/fixtures/scaffold-golden/react-native-screens/Package.swift b/tests/fixtures/scaffold-golden/react-native-screens/Package.swift index 9798423..3197c85 100644 --- a/tests/fixtures/scaffold-golden/react-native-screens/Package.swift +++ b/tests/fixtures/scaffold-golden/react-native-screens/Package.swift @@ -1,9 +1,10 @@ // swift-tools-version: 6.0 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["common/cpp","common/cpp/react/renderer/components/rnscreens","common/cpp/react/renderer/components/rnscreens/utils","cpp","ios","ios/bridging","ios/conversion","ios/events","ios/helpers/container","ios/helpers/image","ios/helpers/scroll-view","ios/integrations","ios/safe-area","ios/stubs","ios/tabs","ios/tabs/bottom-accessory","ios/tabs/extensions","ios/tabs/host","ios/tabs/screen","ios/utils","ios/utils/extensions",".","include"] // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/fixtures/scaffold-golden/react-native-svg/Package.swift b/tests/fixtures/scaffold-golden/react-native-svg/Package.swift index bcc1fd1..dd502ff 100644 --- a/tests/fixtures/scaffold-golden/react-native-svg/Package.swift +++ b/tests/fixtures/scaffold-golden/react-native-svg/Package.swift @@ -1,9 +1,10 @@ // swift-tools-version: 6.0 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["common/cpp","apple/Brushes","apple/Elements","apple/Filters/MetalCI","apple/Filters","apple","apple/Shapes","apple/Text","apple/Utils","apple/ViewManagers","common/cpp/react/renderer/components/rnsvg",".","include"] // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/fixtures/scaffold-golden/react-native-webview/Package.swift b/tests/fixtures/scaffold-golden/react-native-webview/Package.swift index ce80066..d4c8d47 100644 --- a/tests/fixtures/scaffold-golden/react-native-webview/Package.swift +++ b/tests/fixtures/scaffold-golden/react-native-webview/Package.swift @@ -1,9 +1,10 @@ // swift-tools-version: 6.0 // AUTO-SCAFFOLDED by react-native spm scaffold — safe to edit & commit via patch-package. // AUTO-SCAFFOLDED-VERSION: 20 -// rn-xtool-scaffold-revision: 7 +// rn-xtool-scaffold-revision: 8 // rn-xtool-swift-importer-paths: ["apple","."] // Cache slot: 0.86.3/dual-flavor +// rn-xtool-podspec-reader: ruby // Edit the contents below if needed and re-run `npx patch-package ` // to persist across `npm install`. To regenerate from the podspec, remove // this file (or just this marker) and re-run `npx react-native spm scaffold`. diff --git a/tests/patches.test.ts b/tests/patches.test.ts index 2c4501d..139391c 100644 --- a/tests/patches.test.ts +++ b/tests/patches.test.ts @@ -929,7 +929,7 @@ describe("scaffold patches from another React Native version", () => { await writeFile(path.join(root, "patches", "@scope+lib+1.0.0.patch"), scaffoldPatch(null, 1)); // Revision 2 wrote no importer paths for a clang-only target. await writeFile(path.join(root, "patches", "react-native-screens+4.30.1.patch"), scaffoldPatch("0.87.1", 2)); - await writeFile(path.join(root, "patches", "react-native-svg+15.16.0.patch"), scaffoldPatch("0.87.1", 7)); + await writeFile(path.join(root, "patches", "react-native-svg+15.16.0.patch"), scaffoldPatch("0.87.1", 8)); // Both stale: the slot warning wins, one line per patch. await writeFile(path.join(root, "patches", "react-native-safe-area-context+5.6.0.patch"), scaffoldPatch("0.86.3", 1)); await installPkg(root, "react-native-screens"); @@ -937,15 +937,15 @@ describe("scaffold patches from another React Native version", () => { await installPkg(root, "react-native-svg"); await installPkg(root, "react-native-safe-area-context"); expect(scaffoldPatchWarnings(root)).toEqual([ - "⚠ patches/@scope+lib+1.0.0.patch was written by an older rn-xtool scaffolder (revision 1, now 7); delete it so rn-xtool " + + "⚠ patches/@scope+lib+1.0.0.patch was written by an older rn-xtool scaffolder (revision 1, now 8); delete it so rn-xtool " + "regenerates it (also remove node_modules/@scope/lib and reinstall: that copy still has the old Package.swift)", "⚠ patches/react-native-safe-area-context+5.6.0.patch was scaffolded for React Native 0.86.3; delete it so rn-xtool " + "regenerates it for 0.87.1 (also remove node_modules/react-native-safe-area-context and reinstall: that copy still has " + "the old Package.swift)", - "⚠ patches/react-native-screens+4.30.0.patch was written by an older rn-xtool scaffolder (revision 1, now 7); delete it so " + + "⚠ patches/react-native-screens+4.30.0.patch was written by an older rn-xtool scaffolder (revision 1, now 8); delete it so " + "rn-xtool regenerates it (also remove node_modules/react-native-screens and reinstall: that copy still has the old " + "Package.swift)", - "⚠ patches/react-native-screens+4.30.1.patch was written by an older rn-xtool scaffolder (revision 2, now 7); delete it so " + + "⚠ patches/react-native-screens+4.30.1.patch was written by an older rn-xtool scaffolder (revision 2, now 8); delete it so " + "rn-xtool regenerates it (also remove node_modules/react-native-screens and reinstall: that copy still has the old " + "Package.swift)", ]); @@ -958,7 +958,7 @@ describe("scaffold patches from another React Native version", () => { await writeFile(path.join(root, "patches", "react-native-svg+15.16.0.patch"), scaffoldPatch("0.88.1", 3)); await installPkg(root, "react-native-svg"); expect(scaffoldPatchWarnings(root)).toEqual([ - "⚠ patches/react-native-svg+15.16.0.patch was written by an older rn-xtool scaffolder (revision 3, now 7); delete it " + + "⚠ patches/react-native-svg+15.16.0.patch was written by an older rn-xtool scaffolder (revision 3, now 8); delete it " + "so rn-xtool regenerates it (also remove node_modules/react-native-svg and reinstall: that copy still has the old " + "Package.swift)", ]); @@ -976,7 +976,7 @@ describe("scaffold patches from another React Native version", () => { expect(scaffoldPatchWarnings(root)).toEqual([ "⚠ patches/react-native-screens+4.30.0.patch was scaffolded for React Native 0.88.0; delete it so rn-xtool regenerates " + "it for 0.88.1 (also remove node_modules/react-native-screens and reinstall: that copy still has the old Package.swift)", - "⚠ patches/react-native-svg+15.16.0.patch was written by an older rn-xtool scaffolder (revision 1, now 7); delete it " + + "⚠ patches/react-native-svg+15.16.0.patch was written by an older rn-xtool scaffolder (revision 1, now 8); delete it " + "so rn-xtool regenerates it (also remove node_modules/react-native-svg and reinstall: that copy still has the old " + "Package.swift)", ]); @@ -1051,7 +1051,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the it("replaces an older node_modules copy of a current persisted patch (a teammate's pull)", async () => { const root = await project(); await installPkg(root, "react-native-screens", "4.30.0"); - const current = { "Package.swift": manifest(7, "0.87.1"), "include/rnscreens/RNSDefines.h": stub("RNSDefines.h") }; + const current = { "Package.swift": manifest(8, "0.87.1"), "include/rnscreens/RNSDefines.h": stub("RNSDefines.h") }; await put(root, "patches/react-native-screens+4.30.0.patch", newFilesPatch("react-native-screens", current)); // What the old patch left in node_modules: revision 1, slot 0.86.3, a stub the new scaffold no longer writes. await put(root, "node_modules/react-native-screens/Package.swift", manifest(1, "0.86.3")); @@ -1064,7 +1064,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the expect(existsSync(path.join(root, "node_modules/react-native-screens/include/rnscreens/Gone.h"))).toBe(true); expect(lines).toEqual([ "ℹ node_modules/react-native-screens/Package.swift was scaffolded with revision 1 for React Native 0.86.3, " + - "older than patches/react-native-screens+4.30.0.patch (revision 7, React Native 0.87.1): rn-xtool replaced it " + + "older than patches/react-native-screens+4.30.0.patch (revision 8, React Native 0.87.1): rn-xtool replaced it " + "with the persisted one", ]); // Idempotent: the next build changes nothing. @@ -1080,7 +1080,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the const forwarder = "// AUTO-SCAFFOLDED by react-native spm scaffold — forwards to the public headers of the pod AppAuth.\n" + "#import \n#import \n"; - const current = { "Package.swift": manifest(7, "0.87.1"), "rn-spm-pod-headers/AppAuth/AppAuth.h": forwarder }; + const current = { "Package.swift": manifest(8, "0.87.1"), "rn-spm-pod-headers/AppAuth/AppAuth.h": forwarder }; await put(root, "patches/react-native-app-auth+8.5.1.patch", newFilesPatch("react-native-app-auth", current)); await put(root, "node_modules/react-native-app-auth/Package.swift", manifest(3, "0.87.1")); await put(root, "node_modules/react-native-app-auth/rn-spm-pod-headers/AppAuth/AppAuth.h", forwarder); @@ -1090,7 +1090,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the expect(read(root, "node_modules/react-native-app-auth/rn-spm-pod-headers/AppAuth/AppAuth.h")).toBe(forwarder); expect(lines).toEqual([ "ℹ node_modules/react-native-app-auth/Package.swift was scaffolded with revision 3 for React Native 0.87.1, " + - "older than patches/react-native-app-auth+8.5.1.patch (revision 7, React Native 0.87.1): rn-xtool replaced it " + + "older than patches/react-native-app-auth+8.5.1.patch (revision 8, React Native 0.87.1): rn-xtool replaced it " + "with the persisted one", ]); }, 30_000); @@ -1113,7 +1113,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the " line 3", "", ].join("\n"); - await put(root, "patches/lib+1.0.0.patch", newFilesPatch("lib", { "Package.swift": manifest(7, "0.87.1") }) + fix); + await put(root, "patches/lib+1.0.0.patch", newFilesPatch("lib", { "Package.swift": manifest(8, "0.87.1") }) + fix); await put(root, "node_modules/lib/Package.swift", manifest(1, "0.86.3")); await put(root, "node_modules/lib/ios/Foo.m", "line 1\nnew\nline 3\n"); for (const run of [1, 2]) { @@ -1122,7 +1122,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the expect(read(root, "node_modules/lib/Package.swift"), `run ${run}`).toBe(manifest(1, "0.86.3")); expect(lines, `run ${run}`).toEqual([ "⚠ node_modules/lib/Package.swift was scaffolded with revision 1 for React Native 0.86.3, older than " + - "patches/lib+1.0.0.patch (revision 7, React Native 0.87.1), and that patch also changes the library's own " + + "patches/lib+1.0.0.patch (revision 8, React Native 0.87.1), and that patch also changes the library's own " + "files, so rn-xtool does not replace it: run rm -rf node_modules/lib && npm install, then build again", ]); } @@ -1131,14 +1131,14 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the it("treats the pre-rename marker in node_modules as an older revision", async () => { const root = await project(); await installPkg(root, "react-native-svg", "15.16.0"); - await put(root, "patches/react-native-svg+15.16.0.patch", newFilesPatch("react-native-svg", { "Package.swift": manifest(7, "0.87.1") })); + await put(root, "patches/react-native-svg+15.16.0.patch", newFilesPatch("react-native-svg", { "Package.swift": manifest(8, "0.87.1") })); await put(root, "node_modules/react-native-svg/Package.swift", manifest(1, "0.87.1", "expo-xtool-scaffold-revision")); const lines: string[] = []; await applyPatches(root, undefined, { ...noBundled, log: (l) => lines.push(l) }); - expect(read(root, "node_modules/react-native-svg/Package.swift")).toBe(manifest(7, "0.87.1")); + expect(read(root, "node_modules/react-native-svg/Package.swift")).toBe(manifest(8, "0.87.1")); expect(lines).toEqual([ "ℹ node_modules/react-native-svg/Package.swift was scaffolded with revision 1 for React Native 0.87.1, older than " + - "patches/react-native-svg+15.16.0.patch (revision 7, React Native 0.87.1): rn-xtool replaced it with the " + + "patches/react-native-svg+15.16.0.patch (revision 8, React Native 0.87.1): rn-xtool replaced it with the " + "persisted one", ]); }, 30_000); @@ -1146,7 +1146,7 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the it("removes a stale scaffold with no persisted patch, so the rn-spm step scaffolds it again", async () => { const root = await project(); await put(root, "node_modules/react-native-webview/Package.swift", manifest(2, "0.87.1")); - await put(root, "node_modules/@react-native-community/datetimepicker/Package.swift", manifest(7, "0.86.3")); + await put(root, "node_modules/@react-native-community/datetimepicker/Package.swift", manifest(8, "0.86.3")); await put(root, "node_modules/legacy-lib/Package.swift", manifest(1, null, "expo-xtool-scaffold-revision")); // Revision 4 (0.1.0-alpha.6) wrote pod header forwarders with @import, which Objective-C++ cannot compile. await put(root, "node_modules/react-native-app-auth/Package.swift", manifest(4, "0.87.1")); @@ -1154,32 +1154,36 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the await put(root, "node_modules/react-native-screens/Package.swift", manifest(5, "0.87.1")); // Revision 6 lost the defines react-native-worklets 0.8.3 builds from its package.json. await put(root, "node_modules/react-native-worklets/Package.swift", manifest(6, "0.87.1")); + // Revision 7 read podspecs without Ruby: no `ios` attributes merged, no record of the reader. + await put(root, "node_modules/react-native-pager-view/Package.swift", manifest(7, "0.87.1")); const lines: string[] = []; await applyPatches(root, async () => ({ exitCode: 0 }), { ...noBundled, log: (l) => lines.push(l) }); - for (const pkg of ["react-native-webview", "@react-native-community/datetimepicker", "legacy-lib", "react-native-app-auth", "react-native-screens", "react-native-worklets"]) { + for (const pkg of ["react-native-webview", "@react-native-community/datetimepicker", "legacy-lib", "react-native-app-auth", "react-native-pager-view", "react-native-screens", "react-native-worklets"]) { expect(existsSync(path.join(root, "node_modules", pkg, "Package.swift")), pkg).toBe(false); } expect(lines).toEqual([ "ℹ node_modules/@react-native-community/datetimepicker/Package.swift was scaffolded for React Native 0.86.3, not " + "0.87.1: rn-xtool removed it so the rn-spm step scaffolds it again", - "ℹ node_modules/legacy-lib/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 1, now 7): " + + "ℹ node_modules/legacy-lib/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 1, now 8): " + "rn-xtool removed it so the rn-spm step scaffolds it again", "ℹ node_modules/react-native-app-auth/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 4, now " + - "7): rn-xtool removed it so the rn-spm step scaffolds it again", + "8): rn-xtool removed it so the rn-spm step scaffolds it again", + "ℹ node_modules/react-native-pager-view/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 7, now " + + "8): rn-xtool removed it so the rn-spm step scaffolds it again", "ℹ node_modules/react-native-screens/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 5, now " + - "7): rn-xtool removed it so the rn-spm step scaffolds it again", + "8): rn-xtool removed it so the rn-spm step scaffolds it again", "ℹ node_modules/react-native-webview/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 2, now " + - "7): rn-xtool removed it so the rn-spm step scaffolds it again", + "8): rn-xtool removed it so the rn-spm step scaffolds it again", "ℹ node_modules/react-native-worklets/Package.swift was scaffolded by an older rn-xtool scaffolder (revision 6, now " + - "7): rn-xtool removed it so the rn-spm step scaffolds it again", + "8): rn-xtool removed it so the rn-spm step scaffolds it again", ]); }); it("leaves current, foreign and stale-patch manifests alone", async () => { const root = await project(); const files: Record = { - // Current: revision 7 on the installed React Native. - "node_modules/current-lib/Package.swift": manifest(7, "0.87.1"), + // Current: revision 8 on the installed React Native. + "node_modules/current-lib/Package.swift": manifest(8, "0.87.1"), // Not rn-xtool's: the upstream scaffolder without rn-xtool's marker (a library may ship it), or hand-written. "node_modules/upstream-lib/Package.swift": manifest(0, null, null), "node_modules/own-lib/Package.swift": "// swift-tools-version: 6.0\nimport PackageDescription\n", @@ -1187,8 +1191,8 @@ describe("scaffolded manifests in node_modules older than the scaffolder or the "node_modules/react-native-screens/Package.swift": manifest(1, "0.86.3"), "patches/react-native-screens+4.30.0.patch": newFilesPatch("react-native-screens", { "Package.swift": manifest(1, "0.86.3") }), // A current patch over a current copy. - "node_modules/react-native-svg/Package.swift": manifest(7, "0.87.1"), - "patches/react-native-svg+15.16.0.patch": newFilesPatch("react-native-svg", { "Package.swift": manifest(7, "0.87.1") }), + "node_modules/react-native-svg/Package.swift": manifest(8, "0.87.1"), + "patches/react-native-svg+15.16.0.patch": newFilesPatch("react-native-svg", { "Package.swift": manifest(8, "0.87.1") }), }; for (const [rel, text] of Object.entries(files)) await put(root, rel, text); for (const pkg of ["react-native-screens", "react-native-svg"]) await installPkg(root, pkg); diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 188930e..faad125 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -537,7 +537,11 @@ describe("flattenSubspecs on the shim's model", () => { expect(reduced.model.dependencies).toEqual(["React-Core"]); expect(ruby.scaffolded.status).toBe("written"); expect(reduced.scaffolded.status).toBe("written"); - expect(reduced.scaffolded.packageSwift).toBe(ruby.scaffolded.packageSwift); + // The same manifest but for the marker's reader line (fix 29). + expect(ruby.scaffolded.packageSwift).toMatch(/^\/\/ rn-xtool-podspec-reader: ruby$/m); + expect(reduced.scaffolded.packageSwift).toMatch(/^\/\/ rn-xtool-podspec-reader: reduced$/m); + const withoutReader = (pkg: string) => pkg.replace(/^\/\/ rn-xtool-podspec-reader: \w+\n/m, ""); + expect(withoutReader(reduced.scaffolded.packageSwift)).toBe(withoutReader(ruby.scaffolded.packageSwift)); }); it.skipIf(needsRuby !== "")(`drops a subspec on Ruby's model as on the reduced one${needsRuby}`, () => { diff --git a/tests/rn-scaffolder.test.ts b/tests/rn-scaffolder.test.ts index 82fce45..e3cb329 100644 --- a/tests/rn-scaffolder.test.ts +++ b/tests/rn-scaffolder.test.ts @@ -12,6 +12,7 @@ import { readGolden, scaffoldLibraries, withRnRoot, + writeGolden, } from "./support/rnScaffold.js"; import { needsRuby } from "./support/ruby.js"; import { needsTarball, packageFromTarball, patchedSpm, tarballPath } from "./support/tarballs.js"; @@ -147,7 +148,7 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () expect(src("read-podspec.js")).toContain("const RN_POD_ENV"); expect(src("read-podspec.js")).toContain("...RN_POD_ENV"); const f = src("scaffold-package-swift.js"); - expect(f).toContain("RN_XTOOL_SCAFFOLD_REVISION = 7"); + expect(f).toContain("RN_XTOOL_SCAFFOLD_REVISION = 8"); expect(f).toContain("rn-xtool-swift-importer-paths"); expect(f).toContain("function importsOwnSwiftHeader"); expect(f).toContain("function clangModuleExcludes"); @@ -208,6 +209,9 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () expect(src("scaffold-package-swift.js")).toContain("unresolvedSourcesReason(podspecPath, model)"); }); it("the scaffolder has the fix 29 shim", () => expect(existsSync(path.join(SPM, "read-podspec-shim.rb"))).toBe(true)); + it("scaffold-package-swift.js has the fix 29 reader marker hunk", () => { + expect(src("scaffold-package-swift.js")).toContain("const PODSPEC_READER_MARKER = '// rn-xtool-podspec-reader: '"); + }); }); it("gives the per-app header farm a header-less module map, so Objective-C imports it textually", () => { @@ -1109,7 +1113,7 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () it("emits the rn-xtool-scaffold-revision marker next to AUTO-SCAFFOLDED-VERSION", () => { const pkg = readFileSync(path.join(fresh(), "Package.swift"), "utf8"); - expect(pkg).toMatch(/^\/\/ AUTO-SCAFFOLDED-VERSION: \d+\n\/\/ rn-xtool-scaffold-revision: 7$/m); + expect(pkg).toMatch(/^\/\/ AUTO-SCAFFOLDED-VERSION: \d+\n\/\/ rn-xtool-scaffold-revision: 8$/m); }); it("keeps a scaffold that carries the current marker", () => { @@ -1122,14 +1126,14 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () writeFileSync(file, readFileSync(file, "utf8").replace(/^\/\/ rn-xtool-scaffold-revision: \d+\n/m, "").replace("exact:", "from:")); expect(scaffoldAgain(root)).toBe("written"); const pkg = readFileSync(file, "utf8"); - expect(pkg).toContain("rn-xtool-scaffold-revision: 7"); + expect(pkg).toContain("rn-xtool-scaffold-revision: 8"); expect(pkg).toContain('exact: "1.5.0"'); }); it("regenerates a scaffold whose marker is lower than the current revision", () => { const root = fresh(); const file = path.join(root, "Package.swift"); - writeFileSync(file, readFileSync(file, "utf8").replace("revision: 7", "revision: 6")); + writeFileSync(file, readFileSync(file, "utf8").replace("revision: 8", "revision: 7")); expect(scaffoldAgain(root)).toBe("written"); }); }); @@ -1156,6 +1160,39 @@ describe.skipIf(NEEDS_RN !== "")(`patched RN SwiftPM scaffolder${NEEDS_RN}`, () }); }); +// The reference app's libraries scaffolded as rn-xtool's driver does, their podspecs read by Ruby, against +// tests/fixtures/scaffold-golden. RN_XTOOL_WRITE_GOLDEN=1 writes the run there instead of comparing. +describe("the scaffold golden (vendor/rn-spm)", () => { + beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined)); + afterEach(() => vi.unstubAllEnvs()); + + it.skipIf(needsRuby !== "" || !GOLDEN_LIBS.every((l) => existsSync(path.join(APP, "node_modules", l))))( + `scaffolds the reference app's libraries as the golden (needs RN_XTOOL_REF_APP or ../app with the eight golden libraries)${needsRuby}`, + () => { + const now = scaffoldLibraries( + VENDORED_RN_SPM, + Object.fromEntries(GOLDEN_LIBS.map((l) => [l, path.join(APP, "node_modules", l)])), + ); + const manifests = Object.keys(now.files).filter((k) => /\/Package(@swift-[\d.]+)?\.swift$/.test(k)); + expect(manifests.length).toBeGreaterThan(0); + expect(manifests.some((k) => k.startsWith("react-native-pager-view/"))).toBe(true); + // Mixed (pager-view) or clang-only, each of these targets searches beyond its public headers path, so each + // manifest records its importer paths right after the revision line, and the reader after the slot. + for (const k of manifests) { + expect(now.files[k], k).toMatch(/^\/\/ rn-xtool-scaffold-revision: 8\n\/\/ rn-xtool-swift-importer-paths: \[.+\]$/m); + expect(now.files[k], k).toMatch(/^\/\/ Cache slot: .+\n\/\/ rn-xtool-podspec-reader: ruby$/m); + } + if (process.env["RN_XTOOL_WRITE_GOLDEN"] === "1") { + writeGolden(now); + return; + } + const golden = readGolden(); + expect(now.statuses).toEqual(golden.statuses); + expect(now.files).toEqual(golden.files); + }, + ); +}); + // Fixes 14–19 (React Native 0.88.0 patch), exercised on the vendored copy, so they never skip. // The podspec fixtures are the SDK 57 pins: worklets 0.10.1, reanimated 4.5.1, screens 4.26.2 and // gesture-handler 2.32.0, plus screens 4.30.1, which has no Swift (a clang-only target), and @@ -1202,27 +1239,6 @@ describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { }); const defineOf = (pkg: string, name: string) => pkg.match(new RegExp(`\\.define\\("${name}", to: "([^"]*)"\\)`))?.[1]; - it.skipIf(!GOLDEN_LIBS.every((l) => existsSync(path.join(APP, "node_modules", l))))( - "scaffolds the reference app's libraries as the golden (needs RN_XTOOL_REF_APP or ../app with the eight golden libraries)", - () => { - const golden = readGolden(); - const now = scaffoldLibraries( - VENDORED_RN_SPM, - Object.fromEntries(GOLDEN_LIBS.map((l) => [l, path.join(APP, "node_modules", l)])), - ); - expect(now.statuses).toEqual(golden.statuses); - const manifests = Object.keys(now.files).filter((k) => /\/Package(@swift-[\d.]+)?\.swift$/.test(k)); - expect(manifests.length).toBeGreaterThan(0); - expect(manifests.some((k) => k.startsWith("react-native-pager-view/"))).toBe(true); - // Mixed (pager-view) or clang-only, each of these targets searches beyond its public headers path, so each - // manifest records its importer paths right after the revision line. - for (const k of manifests) { - expect(now.files[k], k).toMatch(/^\/\/ rn-xtool-scaffold-revision: 7\n\/\/ rn-xtool-swift-importer-paths: \[.+\]$/m); - } - expect(now.files).toEqual(golden.files); - }, - ); - it("14: keeps own -Swift.h importers out of the mixed umbrella", () => { const umbrella = file("react-native-screens/rn-spm-swift/umbrella.h"); expect(umbrella).toContain('#import "../ios/bridging/RNSReactBaseView.h"'); @@ -1320,7 +1336,7 @@ describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { it("17: records the Swift importer paths", () => { for (const manifest of ["Package.swift", "Package@swift-6.5.swift"]) { const pkg = file(`react-native-screens/${manifest}`); - expect(pkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 7\n\/\/ rn-xtool-swift-importer-paths: \[.*\]$/m); + expect(pkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 8\n\/\/ rn-xtool-swift-importer-paths: \[.*\]$/m); const paths = JSON.parse(pkg.match(IMPORTER)![1]!) as string[]; expect(paths).toContain("."); expect(paths).toContain("ios/bridging"); @@ -1335,7 +1351,7 @@ describe("scaffolder fixes 14–19 (vendor/rn-spm)", () => { expect(pkg.split("\n")[0]).toBe("// swift-tools-version: 6.0"); expect(files["react-native-screens/Package@swift-6.5.swift"]).toBeUndefined(); expect(pkg).toContain('publicHeadersPath: "ios",'); - expect(pkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 7\n\/\/ rn-xtool-swift-importer-paths: \[.*\]$/m); + expect(pkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 8\n\/\/ rn-xtool-swift-importer-paths: \[.*\]$/m); const paths = JSON.parse(pkg.match(IMPORTER)![1]!) as string[]; expect(paths).toContain("ios/utils"); expect(paths).toEqual(searchPaths(pkg)); @@ -2158,7 +2174,7 @@ describe("scaffolder fix 13: the pod table (vendor/rn-spm)", () => { const pkg = manifest(scaffold(`${APPAUTH_DEP}\n s.dependency "SwiftUIIntrospect", '~> 1.0'`, table)); // Clang-only, searching beyond its public headers: after the importer-paths line. expect(pkg).toMatch( - /^\/\/ rn-xtool-scaffold-revision: 7\n\/\/ rn-xtool-swift-importer-paths: \[.*\]\n\/\/ rn-xtool-pods: AppAuth=3\.0\.0, SwiftUIIntrospect=1\.5\.0\n\/\/ Cache slot: /m, + /^\/\/ rn-xtool-scaffold-revision: 8\n\/\/ rn-xtool-swift-importer-paths: \[.*\]\n\/\/ rn-xtool-pods: AppAuth=3\.0\.0, SwiftUIIntrospect=1\.5\.0\n\/\/ Cache slot: /m, ); // Pure Swift (no importer-paths line): after the revision line. const swift = tempDir(); @@ -2170,9 +2186,9 @@ describe("scaffolder fix 13: the pod table (vendor/rn-spm)", () => { `Pod::Spec.new do |s|\n s.name = "Foo"\n s.source_files = "ios/**/*.swift"\n${APPAUTH_DEP}\nend\n`, ); const swiftPkg = manifest(withTable(table, () => scaffoldLibraries(VENDORED_RN_SPM, { foo: swift }))); - expect(swiftPkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 7\n\/\/ rn-xtool-pods: AppAuth=3\.0\.0\n/m); + expect(swiftPkg).toMatch(/^\/\/ rn-xtool-scaffold-revision: 8\n\/\/ rn-xtool-pods: AppAuth=3\.0\.0\n/m); // No pinned pod, no line. - expect(manifest(scaffold("", table))).not.toContain("rn-xtool-pods"); + expect(manifest(scaffold("", table))).not.toContain("// rn-xtool-pods: "); }); it("13: sorts the rn-xtool-pods line by pod name", () => { @@ -2401,7 +2417,7 @@ describe("scaffolder fix 27: binary pods (vendor/rn-spm)", () => { const run = scaffold({}); const pkg = manifestOf(run); expect(pkg).not.toContain("pod-binaries"); - expect(pkg).not.toContain("rn-xtool-pods"); + expect(pkg).not.toContain("// rn-xtool-pods: "); expect(run.results[0]!.warnings.some((w) => w.startsWith('Dependency "GoogleMLKit" is a CocoaPods pod with no known SwiftPM equivalent'))).toBe(true); }); }); @@ -2582,6 +2598,46 @@ describe("scaffolder fix 28: podspec locals and conditions (vendor/rn-spm)", () }); }); +// Fix 29: podspecs read by Ruby through read-podspec-shim.rb, and the reader recorded in each manifest's marker. +describe("scaffolder fix 29: the podspec reader in the marker (vendor/rn-spm)", () => { + afterEach(() => vi.unstubAllEnvs()); + /** A library both readers read alike: one header and one Objective-C file under ios/. */ + function podLib(): string { + const root = tempDir(); + writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "react-native-foo", version: "1.0.0" })); + mkdirSync(path.join(root, "ios")); + writeFileSync(path.join(root, "ios", "Foo.h"), "#import \n"); + writeFileSync(path.join(root, "ios", "Foo.m"), '#import "Foo.h"\n'); + writeFileSync( + path.join(root, "Foo.podspec"), + 'Pod::Spec.new do |s|\n s.name = "Foo"\n s.version = "1.0.0"\n s.source_files = "ios/**/*.{h,m}"\nend\n', + ); + return root; + } + /** The scaffold of {@link podLib}: its manifest and the reader its result names. */ + function scaffoldFoo(): { pkg: string; reader: string | undefined } { + const run = scaffoldLibraries(VENDORED_RN_SPM, { "react-native-foo": podLib() }); + const result = run.results[0]!; + expect(result.status, result.reason).toBe("written"); + return { pkg: run.files["react-native-foo/Package.swift"]!, reader: result.reader }; + } + + it.skipIf(needsRuby !== "")(`29: records the podspec reader in the marker, after the slot${needsRuby}`, () => { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + const { pkg, reader } = scaffoldFoo(); + expect(pkg).toMatch(/^\/\/ Cache slot: .+\n\/\/ rn-xtool-podspec-reader: ruby$/m); + expect(reader).toBe("ruby"); + }); + + it("29: records the reduced reader when it is forced", () => { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced"); + const { pkg, reader } = scaffoldFoo(); + expect(pkg).toMatch(/^\/\/ Cache slot: .+\n\/\/ rn-xtool-podspec-reader: reduced$/m); + expect(pkg.match(/^\/\/ rn-xtool-podspec-reader: /gm)).toHaveLength(1); + expect(reader).toBe("reduced"); + }); +}); + describe("React Native's own pods are core (vendor/rn-spm)", () => { type Classify = (depName: string, ctx: object) => { kind: string }; const classify = (name: string): string => diff --git a/tests/rn-spm-generate.test.ts b/tests/rn-spm-generate.test.ts index 3c597b1..1393213 100644 --- a/tests/rn-spm-generate.test.ts +++ b/tests/rn-spm-generate.test.ts @@ -75,7 +75,7 @@ module.exports = { scaffoldAll(opts) { record('scaffoldAll', opts); return [ - {depName: 'lib-a', status: 'written', warnings: ['check the header paths'], files: ['Package.swift', 'include/Foo/Foo.h']}, + {depName: 'lib-a', status: 'written', warnings: ['check the header paths'], files: ['Package.swift', 'include/Foo/Foo.h'], reader: 'ruby'}, {depName: 'lib-b', status: 'error', reason: 'no podspec readable'}, {depName: 'lib-c', status: 'already-set'}, ]; @@ -364,7 +364,14 @@ describe("rn-spm-generate.js", () => { expect(r.exitCode, r.all).toBe(0); expect(JSON.parse(readFileSync(results, "utf8"))).toEqual({ results: [ - { depName: "lib-a", status: "written", warnings: ["check the header paths"], root: "/nm/lib-a", files: ["Package.swift", "include/Foo/Foo.h"] }, + { + depName: "lib-a", + status: "written", + warnings: ["check the header paths"], + root: "/nm/lib-a", + files: ["Package.swift", "include/Foo/Foo.h"], + reader: "ruby", + }, { depName: "lib-b", status: "error", reason: "no podspec readable", root: "/nm/lib-b" }, { depName: "lib-c", status: "already-set" }, ], diff --git a/tests/support/rnScaffold.ts b/tests/support/rnScaffold.ts index 0fc769a..dc4aade 100644 --- a/tests/support/rnScaffold.ts +++ b/tests/support/rnScaffold.ts @@ -47,7 +47,7 @@ function mkTmp(prefix: string): string { return d; } -export type ScaffoldResult = { depName: string; status: string; reason?: string; warnings?: string[] }; +export type ScaffoldResult = { depName: string; status: string; reason?: string; warnings?: string[]; reader?: string }; type ScaffoldAll = { scaffoldAll(o: object): ScaffoldResult[] }; function listFiles(dir: string, rel = ""): string[] { @@ -103,7 +103,9 @@ export function podspecCopy(file: string): string { * Copies each library (`name` → its source dir) into a temp `node_modules`, drops the scaffolder's * earlier output (a persisted scaffold patch), runs `scaffoldAll` over them with `spmDir`, and * returns each library's status and every file the run created or changed, keyed - * `/`, with the temp root replaced by ``. The libraries in `noIos` are listed + * `/`, with the temp root replaced by ``. The temp tree is an app's install: `/app` + * with its package.json and `ios/` (`RN_SPM_APP_IOS_DIR` for the run), beside a `node_modules/react-native` of 0.86.3, + * so a podspec read by Ruby finds React Native and the app as in a project. The libraries in `noIos` are listed * without an iOS platform, as autolinking lists a package a config takes out of iOS. `options` are passed * to `scaffoldAll` over the defaults (`force: true` among them), and `rerun` runs it again on the same copies. */ @@ -121,6 +123,10 @@ export function scaffoldLibraries( const base = mkTmp("rn-scaffold-"); const projectRoot = path.join(base, "app"); const appRoot = path.join(projectRoot, "ios"); + mkdirSync(appRoot, { recursive: true }); + writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify({ name: "app", version: "1.0.0" })); + mkdirSync(path.join(base, "node_modules", "react-native"), { recursive: true }); + writeFileSync(path.join(base, "node_modules", "react-native", "package.json"), JSON.stringify({ name: "react-native", version: "0.86.3" })); const dependencies: Record = {}; const before = new Map(); const roots: Record = {}; @@ -160,19 +166,27 @@ export function scaffoldLibraries( writeFileSync(autolinkingJsonPath, JSON.stringify({ root: projectRoot, dependencies }, null, 2)); const { scaffoldAll } = createRequire(import.meta.url)(path.join(spmDir, "scaffold-package-swift.js")) as ScaffoldAll; - const run = (over: Record) => - withRnRoot("0.86.3", () => - scaffoldAll({ - appRoot, - projectRoot, - reactNativeRoot: path.join(base, "node_modules", "react-native"), - autolinkingJsonPath, - iosDeploymentTarget: "16.4", - cacheSlotLabel: "0.86.3/dual-flavor", - force: true, - ...over, - }), - ); + const run = (over: Record) => { + const saved = process.env["RN_SPM_APP_IOS_DIR"]; + process.env["RN_SPM_APP_IOS_DIR"] = appRoot; + try { + return withRnRoot("0.86.3", () => + scaffoldAll({ + appRoot, + projectRoot, + reactNativeRoot: path.join(base, "node_modules", "react-native"), + autolinkingJsonPath, + iosDeploymentTarget: "16.4", + cacheSlotLabel: "0.86.3/dual-flavor", + force: true, + ...over, + }), + ); + } finally { + if (saved === undefined) delete process.env["RN_SPM_APP_IOS_DIR"]; + else process.env["RN_SPM_APP_IOS_DIR"] = saved; + } + }; const results = run(options); const files: Record = {}; @@ -198,3 +212,15 @@ export function readGolden(): { statuses: Record; files: Record< } return { statuses, files }; } + +/** Writes `golden` (a {@link scaffoldLibraries} run over {@link GOLDEN_LIBS}) as the golden files {@link readGolden} reads. */ +export function writeGolden(golden: { statuses: Record; files: Record }): void { + for (const lib of GOLDEN_LIBS) rmSync(path.join(SCAFFOLD_GOLDEN, lib), { recursive: true, force: true }); + mkdirSync(SCAFFOLD_GOLDEN, { recursive: true }); + writeFileSync(path.join(SCAFFOLD_GOLDEN, "statuses.json"), `${JSON.stringify(golden.statuses, null, 2)}\n`); + for (const [key, text] of Object.entries(golden.files)) { + const file = path.join(SCAFFOLD_GOLDEN, key); + mkdirSync(path.dirname(file), { recursive: true }); + writeFileSync(file, text); + } +} diff --git a/vendor/rn-spm/README.md b/vendor/rn-spm/README.md index d1d60d5..4e84c18 100644 --- a/vendor/rn-spm/README.md +++ b/vendor/rn-spm/README.md @@ -6,7 +6,7 @@ versions that ship no `scripts/spm` of their own. - Origin: react-native 0.88.0, MIT, Meta Platforms, Inc. and affiliates (see `LICENSE`). - Modifications, in order: - 1. The 28 fixes of `docs/upstream/react-native-scaffolder.md`, applied with + 1. The 29 fixes of `docs/upstream/react-native-scaffolder.md`, applied with `patches/react-native+0.88.0.patch` (`patch -p4`, run in the extracted `scripts/`). 2. Six rn-xtool edits (E1-E6) in `rn-xtool-edits.patch` (`patch -p1`, run in this directory): the codegen template resolves relative to this copy, the installed React Native root comes diff --git a/vendor/rn-spm/spm/scaffold-package-swift.js b/vendor/rn-spm/spm/scaffold-package-swift.js index 0986d43..75d9715 100644 --- a/vendor/rn-spm/spm/scaffold-package-swift.js +++ b/vendor/rn-spm/spm/scaffold-package-swift.js @@ -137,7 +137,10 @@ const SCAFFOLDER_VERSION_LINE_RE = /^\/\/ AUTO-SCAFFOLDED-VERSION: (\d+)$/m; // condition rules out left out of the target. Revision 7: the defines a // podspec builds from its package.json and partly evaluated strings // (react-native-worklets 0.8.3's WORKLETS_VERSION), which revision 6 lost. -const RN_XTOOL_SCAFFOLD_REVISION = 7; +// Revision 8 (fix 29): podspecs read by real Ruby through +// read-podspec-shim.rb, `ios` attributes merged, and the reader recorded in +// the marker. +const RN_XTOOL_SCAFFOLD_REVISION = 8; const RN_XTOOL_SCAFFOLD_REVISION_RE = /^\/\/ rn-xtool-scaffold-revision: (\d+)$/m; // An importer (Swift, or a Clang module) builds the target's module from its @@ -187,6 +190,11 @@ const POD_TABLE_ENV = 'RN_SPM_POD_TABLE'; // the importer paths (or the revision line). const POD_PINS_MARKER = '// rn-xtool-pods: '; +// Which reader read the podspec (fix 29): `ruby` (read-podspec-shim.rb) or +// `reduced` (the reduced reader, without Ruby or when forced), on the line +// after the cache slot, the last line of the marker block. +const PODSPEC_READER_MARKER = '// rn-xtool-podspec-reader: '; + // One pod table entry in its full shape; `product: string` is read as // `products: [product]`. An entry with `binary` is a binary pod (fix 27) and // its other keys are ignored. Throws with the key that has the wrong shape. @@ -1646,6 +1654,8 @@ type EmitContext = { // (/build/pod-binaries, fix 27). Only referenced for binary pods. podBinariesPackageDir?: ?string, iosDeploymentTarget?: ?string, + // The reader that read the podspec (PODSPEC_READER_MARKER); no line without. + reader?: ?('ruby' | 'reduced'), }; */ @@ -1662,6 +1672,8 @@ function emitScaffoldedPackageSwift( ) /*: string */ { const slotComment = ctx.cacheSlotLabel != null ? `\n// Cache slot: ${ctx.cacheSlotLabel}` : ''; + const readerLine = + ctx.reader != null ? `\n${PODSPEC_READER_MARKER}${ctx.reader}` : ''; const iosDeploymentTarget /*: string */ = ctx.iosDeploymentTarget ?? MIN_IOS_VERSION_SUPPORTED; @@ -1945,7 +1957,7 @@ let rnSpmBridgingHeader = Context.packageDirectory + "/${mixed.bridgingHeader}" return `${toolsVersionLine} ${SCAFFOLDER_MARKER} // AUTO-SCAFFOLDED-VERSION: ${SCAFFOLDER_VERSION} -// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment} +// rn-xtool-scaffold-revision: ${RN_XTOOL_SCAFFOLD_REVISION}${importerPathsLine}${podsLine}${slotComment}${readerLine} // Edit the contents below if needed and re-run \`npx patch-package \` // to persist across \`npm install\`. To regenerate from the podspec, remove // this file (or just this marker) and re-run \`npx react-native spm scaffold\`. @@ -2349,6 +2361,7 @@ function scaffoldPackageSwiftForDep( codegenPackageDir: relFromManifest('build', 'generated', 'ios'), localXcfwPackageDir: relFromManifest('build', 'xcframeworks'), podBinariesPackageDir: relFromManifest('build', 'pod-binaries'), + reader: model.reader, }); // Distinguish "first-time scaffold" (no file at all) from "regenerate" @@ -2511,6 +2524,7 @@ function scaffoldPackageSwiftForDep( previouslyExisted, swiftpmName, files: [...written].sort(), + reader: model.reader, }; } diff --git a/vendor/rn-spm/spm/spm-types.js b/vendor/rn-spm/spm/spm-types.js index 4493621..4eb4089 100644 --- a/vendor/rn-spm/spm/spm-types.js +++ b/vendor/rn-spm/spm/spm-types.js @@ -558,6 +558,8 @@ export type ScaffoldResult = // Every file the scaffold wrote under the library, relative to its root // (posix separators), sorted. files: Array, + // Which reader read the podspec (PodspecModel.reader). + reader: 'ruby' | 'reduced', } | { depName: string, From 79fa04883f691c245093bf674f5a71082e56ea7b Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:09:31 -0600 Subject: [PATCH 17/53] feat: report Ruby in doctor and setup --- src/commands/doctor.ts | 17 ++++++--- src/commands/setup.ts | 13 +++++++ src/tools/podspecReader.ts | 29 +++++++++++++++ tests/doctor.test.ts | 73 ++++++++++++++++++++++++++++++++----- tests/podspecReader.test.ts | 11 ++++++ tests/report.test.ts | 2 + tests/setup.test.ts | 35 +++++++++++++++--- 7 files changed, 160 insertions(+), 20 deletions(-) create mode 100644 src/tools/podspecReader.ts diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts index d569069..8d8496b 100644 --- a/src/commands/doctor.ts +++ b/src/commands/doctor.ts @@ -22,6 +22,7 @@ import { readState } from "../state.js"; import { NO_FINGERPRINT_WARNING } from "./start.js"; import { sha256File } from "../tools/download.js"; import { toolEnv } from "../tools/exec.js"; +import { podspecReaderHere, rubyCheck, type PodspecReaderChoice } from "../tools/podspecReader.js"; import { authStatus, listDevices, defaultXtoolPath, xtoolBin, xtoolUnrunnableError, type AuthStatus, type Device } from "../tools/xtool.js"; import { XTOOL_VERSION, @@ -59,6 +60,8 @@ export interface DoctorReport { export interface DoctorProbes { nodeVersion: () => string; + /** Which reader the scaffolder reads podspecs with: Ruby, or the reduced reader and why (a local probe only). */ + podspecReader: () => PodspecReaderChoice; swiftVersion: () => Promise; /** The LLVM version of the Swift toolchain's llvm-nm (G4 needs it); rejects with LLVM_NM_MISSING when it is missing. */ llvmNmVersion: () => Promise; @@ -172,6 +175,7 @@ export function realProbes(config: ExpoXtoolConfig, opts: { offline?: boolean } const bin = (): string => xtoolBin(config); return { nodeVersion: () => process.versions.node, + podspecReader: () => podspecReaderHere(), swiftVersion: () => swiftVersionText(PROBE_TIMEOUT_MS), llvmNmVersion: async () => /LLVM version (\S+)/.exec(await makeNmRunner("llvm-nm", PROBE_TIMEOUT_MS)(["--version"]))?.[1] ?? "unknown", @@ -519,12 +523,12 @@ async function check(name: string, fn: () => Promise>) } /** - * Every check, or with `projectOnly` (`doctor --project`) only node, the project and its capabilities: no toolchain, - * login, device or build-state probe runs, so it works where Swift and xtool are not installed. `withCapabilities` - * (`doctor --report`) appends the capability lines to every check when there is a root; as under `--project`, a - * capability probe that throws fails the project line. `noLiveProbes` (`doctor --report`) leaves out the device probe - * (`xtool devices` opens a lockdown connection to each iPhone, over Wi‑Fi too) and the Wi‑Fi probe (a lockdown session - * with the USB iPhone, a connection to its last known IP). + * Every check, or with `projectOnly` (`doctor --project`) only node, ruby, the project and its capabilities: no + * toolchain, login, device or build-state probe runs, so it works where Swift and xtool are not installed. + * `withCapabilities` (`doctor --report`) appends the capability lines to every check when there is a root; as under + * `--project`, a capability probe that throws fails the project line. `noLiveProbes` (`doctor --report`) leaves out the + * device probe (`xtool devices` opens a lockdown connection to each iPhone, over Wi‑Fi too) and the Wi‑Fi probe (a + * lockdown session with the USB iPhone, a connection to its last known IP). */ export async function doctorWithProbes( p: DoctorProbes, @@ -542,6 +546,7 @@ export async function doctorWithProbes( ? { status: "ok", detail: v } : { status: "fail", detail: `${v} (need ${NODE_MIN} or newer)` }; }); + await add("ruby", async () => rubyCheck(p.podspecReader())); if (opts.projectOnly) { const dir = root ?? process.cwd(); const [project, caps] = await Promise.all([settle(() => p.project(dir)), settle(() => p.capabilities(dir))]); diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 8568dd6..f2d8f6c 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -6,6 +6,7 @@ import path from "node:path"; import { cacheDir } from "../paths.js"; import { downloadFile } from "../tools/download.js"; import { run, toolEnv } from "../tools/exec.js"; +import { podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; import { authStatus, defaultXtoolPath } from "../tools/xtool.js"; import { SWIFT_VERSION, XTOOL_SHA256, XTOOL_VERSION } from "../versions.js"; @@ -28,6 +29,15 @@ export interface SetupDeps { log: (line: string) => void; /** Message to fail with while Swift's system packages from a previous run are still missing. */ checkSwiftPackages: () => Promise; + /** Which reader the scaffolder reads podspecs with; setup only reports it. */ + podspecReader: () => PodspecReaderChoice; +} + +/** setup's Ruby line: Ruby is never installed, only named. */ +function rubySetupLine(c: PodspecReaderChoice): string { + return c.reader === "ruby" + ? `✔ ruby ${c.ruby}` + : `⚠ ${c.why}: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby`; } export const GB = 1024 ** 3; @@ -330,8 +340,10 @@ export async function setup( log(`ℹ Removing ${tilde(staging)}, left by an interrupted Darwin SDK install.`); await rm(staging, { recursive: true, force: true }); }; + const logRuby = (): void => log(rubySetupLine((deps.podspecReader ?? podspecReaderHere)())); if (actions.length === 0) { await removeSdkStaging(); + logRuby(); log("✔ Nothing to do: toolchain already set up"); return; } @@ -348,6 +360,7 @@ export async function setup( installSdk: (to: string, xip: string) => installSdk(to, xip, log), ...deps.actions, }; + logRuby(); for (const action of actions) { switch (action) { case "install-swift": diff --git a/src/tools/podspecReader.ts b/src/tools/podspecReader.ts new file mode 100644 index 0000000..33d30ff --- /dev/null +++ b/src/tools/podspecReader.ts @@ -0,0 +1,29 @@ +import { createRequire } from "node:module"; +import path from "node:path"; +import type { DoctorCheck } from "../commands/doctor.js"; +import { packageRoot } from "./exec.js"; + +/** Which reader the vendored scaffolder reads podspecs with (`podspecReader` in vendor/rn-spm/spm/read-podspec.js). */ +export type PodspecReaderChoice = + | { reader: "ruby"; ruby: string; forced: false; warning: string | null } + | { reader: "reduced"; why: string; forced: boolean; warning: string | null }; + +type PodspecReader = (opts: { env?: NodeJS.ProcessEnv }) => PodspecReaderChoice; + +/** The reader rn-xtool's vendored scaffolder picks in `env`: its own `podspecReader`, never a copy of its rules. */ +export function podspecReaderHere(env: NodeJS.ProcessEnv = process.env): PodspecReaderChoice { + const file = path.join(packageRoot(), "vendor", "rn-spm", "spm", "read-podspec.js"); + return (createRequire(import.meta.url)(file) as { podspecReader: PodspecReader }).podspecReader({ env }); +} + +const REDUCED = "podspecs are read with the reduced reader"; + +/** doctor's `ruby` check: a reader other than Ruby, or a Ruby with a warning, is a warning, never a failure. */ +export function rubyCheck(c: PodspecReaderChoice): Omit { + if (c.reader === "ruby") { + return c.warning ? { status: "warn", detail: `${c.ruby}; ${c.warning}` } : { status: "ok", detail: c.ruby }; + } + if (c.forced) return { status: "warn", detail: `${c.why} — ${REDUCED}` }; + const why = c.why === "Ruby was not found" ? "not found" : c.why; + return { status: "warn", detail: `${why} — ${REDUCED}; sudo apt install ruby` }; +} diff --git a/tests/doctor.test.ts b/tests/doctor.test.ts index e74a85d..be42c49 100644 --- a/tests/doctor.test.ts +++ b/tests/doctor.test.ts @@ -88,6 +88,7 @@ const good: DoctorProbes = { portFree: async () => true, wifi: async () => ({ usb: { udid: "u1", enabled: true } }), capabilities: async () => expo58Caps, + podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }), }; const statusOf = (r: { checks: { name: string; status: string }[] }, name: string) => @@ -124,7 +125,7 @@ describe("doctorWithProbes", () => { const r = await doctorWithProbes(good); expect(r.ok).toBe(true); expect(r.checks.map((c) => c.name)).toEqual([ - "node", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", + "node", "ruby", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", ]); expect(r.checks.every((c) => c.status === "ok")).toBe(true); }); @@ -371,7 +372,7 @@ describe("doctorWithProbes", () => { const r = await doctorWithProbes({ ...good, ufwActive: async () => true, buildState: async () => ({ metroPort: 8099, lanIp: "1.2.3.4" }) }, "/p"); expect(r.checks.find((c) => c.name === "firewall")?.detail).toContain("ufw allow 8099/tcp"); expect(r.checks.map((c) => c.name)).toEqual([ - "node", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", "project", "project-config", "build-state", "deps", "metro-port", + "node", "ruby", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", "project", "project-config", "build-state", "deps", "metro-port", ]); }); @@ -522,9 +523,63 @@ describe("wifi check", () => { }); }); +describe("ruby check", () => { + const reduced = { reader: "reduced", forced: false, warning: null } as const; + + it("reports Ruby", async () => { + const r = await doctorWithProbes(good); + expect(r.checks.slice(0, 2)).toEqual([ + { name: "node", status: "ok", detail: "24.15.0" }, + { name: "ruby", status: "ok", detail: "3.3.8" }, + ]); + const warned = await doctorWithProbes({ + ...good, + podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby" }), + }); + expect(warned.checks[1]).toEqual({ + name: "ruby", + status: "warn", + detail: "3.3.8; RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby", + }); + expect(warned.ok).toBe(true); + }); + + it("warns without Ruby, also under --project", async () => { + const noRuby = { ...good, podspecReader: () => ({ ...reduced, why: "Ruby was not found" }) }; + const expected = { + name: "ruby", + status: "warn", + detail: "not found — podspecs are read with the reduced reader; sudo apt install ruby", + }; + for (const r of [await doctorWithProbes(noRuby, "/proj", { projectOnly: true }), await doctorWithProbes(noRuby)]) { + expect(r.checks[1]).toEqual(expected); + expect(r.ok).toBe(true); + } + const old = await doctorWithProbes({ ...good, podspecReader: () => ({ ...reduced, why: "ruby 2.5.1 is older than 2.7.0" }) }); + expect(old.checks[1]).toEqual({ + name: "ruby", + status: "warn", + detail: "ruby 2.5.1 is older than 2.7.0 — podspecs are read with the reduced reader; sudo apt install ruby", + }); + }); + + it("names the forced reduced reader", async () => { + const r = await doctorWithProbes({ + ...good, + podspecReader: () => ({ reader: "reduced", why: "RN_XTOOL_PODSPEC_READER=reduced is set", forced: true, warning: null }), + }); + expect(r.checks[1]).toEqual({ + name: "ruby", + status: "warn", + detail: "RN_XTOOL_PODSPEC_READER=reduced is set — podspecs are read with the reduced reader", + }); + expect(r.ok).toBe(true); + }); +}); + describe("doctor --project", () => { /** The only probes --project may call. */ - const PROJECT_PROBES = new Set(["nodeVersion", "project", "capabilities"]); + const PROJECT_PROBES = new Set(["nodeVersion", "podspecReader", "project", "capabilities"]); /** Every other probe, recording its name and throwing: --project must never call them. */ function forbidden(called: string[]): Partial { return Object.fromEntries( @@ -540,7 +595,7 @@ describe("doctor --project", () => { ); } - it("makes every probe but node, project and capabilities throw", () => { + it("makes every probe but node, ruby, project and capabilities throw", () => { expect(Object.keys(forbidden([])).sort()).toEqual([ "authStatus", "buildState", "configLanIp", "depsFingerprint", "devices", "hasBinaryPods", "llvmArVersion", "llvmNmVersion", "lanRoute", "portFree", "sdkInstalled", "swiftVersion", "ufwActive", "wifi", "xtoolInstalled", "xtoolPath", "xtoolSha256", "xtoolVersion", @@ -552,7 +607,7 @@ describe("doctor --project", () => { const r = await doctorWithProbes({ ...good, ...forbidden(called) }, "/proj", { projectOnly: true }); expect(called).toEqual([]); expect(r.checks.map((c) => c.name)).toEqual([ - "node", "project", "project-config", "versions", "rn-scripts", "rn-artifacts", "expo-plugin", "expo-modules", "podspecs", + "node", "ruby", "project", "project-config", "versions", "rn-scripts", "rn-artifacts", "expo-plugin", "expo-modules", "podspecs", ]); expect(r.ok).toBe(true); }); @@ -752,7 +807,7 @@ describe("doctor --project", () => { ); expect(called).toEqual([]); expect(r.checks.map((c) => c.name)).toEqual([ - "node", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", + "node", "ruby", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", "project", "project-config", "build-state", "deps", "metro-port", ]); expect(r.capabilities).toBeUndefined(); @@ -761,7 +816,7 @@ describe("doctor --project", () => { it("withCapabilities appends the capability lines", async () => { const r = await doctorWithProbes(good, "/proj", { withCapabilities: true }); expect(r.checks.map((c) => c.name)).toEqual([ - "node", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", + "node", "ruby", "swift", "llvm-nm", "llvm-ar", "xtool", "darwin-sdk", "apple-login", "device", "wifi", "firewall", "lan-ip", "project", "project-config", "build-state", "deps", "metro-port", "versions", "rn-scripts", "rn-artifacts", "expo-plugin", "expo-modules", "podspecs", ]); @@ -855,7 +910,7 @@ describe("doctor --project", () => { status: "fail", detail: "Unexpected token } in JSON at position 20", }); - expect(r.checks.map((c) => c.name)).toEqual(["node", "project", "project-config"]); + expect(r.checks.map((c) => c.name)).toEqual(["node", "ruby", "project", "project-config"]); expect(r.ok).toBe(false); }); @@ -870,7 +925,7 @@ describe("doctor --project", () => { const project = r.checks.find((c) => c.name === "project"); expect(project?.status).toBe("fail"); expect(project?.detail).toMatch(/^rn-xtool\.config\.json: .*JSON/); - expect(r.checks.map((c) => c.name)).toEqual(["node", "project", "project-config"]); + expect(r.checks.map((c) => c.name)).toEqual(["node", "ruby", "project", "project-config"]); expect(r.ok).toBe(false); } finally { await rm(dir, { recursive: true, force: true }); diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index faad125..a0ef778 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -2,6 +2,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, wr import { createRequire } from "node:module"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { podspecReaderHere } from "../src/tools/podspecReader.js"; import { PODSPEC_FIXTURES, VENDORED_RN_SPM, installedCopy, podspecCopy } from "./support/rnScaffold.js"; import { SHIM, needsRuby, tempDir } from "./support/ruby.js"; import { needsTarball, packageFromTarball } from "./support/tarballs.js"; @@ -648,3 +649,13 @@ describe("reader failures propagate", () => { expect(expand(dep, unreadable)[0]).toMatchObject({ swiftNameSource: "npm" }); }); }); + +describe("the podspec reader rn-xtool reports", () => { + it("doctor and the scaffolder pick the same reader", () => { + const forced = { ...process.env, RN_XTOOL_PODSPEC_READER: "reduced" }; + expect(podspecReaderHere(forced)).toEqual(podspecReader({ env: forced })); + const withFake = { PATH: usableRuby() }; + expect(podspecReaderHere(withFake)).toEqual(podspecReader({ env: withFake })); + expect(podspecReaderHere(withFake)).toEqual({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }); + }); +}); diff --git a/tests/report.test.ts b/tests/report.test.ts index e90d243..4030543 100644 --- a/tests/report.test.ts +++ b/tests/report.test.ts @@ -89,6 +89,7 @@ const probes: DoctorProbes = { portFree: async () => true, wifi: async () => ({ usb: { udid: "00008110-000000000000AAAA", enabled: true } }), capabilities: async () => caps, + podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }), }; const env: ReportEnv = { rnXtoolVersion: "9.9.9", os: "Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic", arch: "x64", home: "/home/me" }; @@ -152,6 +153,7 @@ describe("doctorReport", () => { "os: Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic, x64", "project: expo, Expo SDK 58, expo 58.0.21, react-native 0.88.1", "✔ node — 24.15.0", + "✔ ruby — 3.3.8", "✔ swift — 6.4", "✔ llvm-nm — LLVM 21.0.0", "✔ llvm-ar — LLVM 21.0.0", diff --git a/tests/setup.test.ts b/tests/setup.test.ts index b088a38..829b30f 100644 --- a/tests/setup.test.ts +++ b/tests/setup.test.ts @@ -20,6 +20,8 @@ import { } from "../src/commands/setup.js"; const all = { hasSwift: true, hasXtool: true, hasSdk: true, loggedIn: true }; +const withRuby = () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }) as const; +const RUBY_LINE = "✔ ruby 3.3.8"; const noPending = async () => undefined; // No test reaches the network: a download that slips through fails here instead. @@ -58,12 +60,14 @@ const noInstaller = (name: string) => async () => { }; /** * Every setup() in this file goes through here: the real installers are replaced by ones that throw (a test's own - * fakes win), the disk is roomy unless the test probes it, and HOME is temporary unless the test set one up. + * fakes win), the disk is roomy unless the test probes it, Ruby 3.3.8 reads podspecs unless the test says otherwise, + * and HOME is temporary unless the test set one up. */ const setup = (opts: Parameters[0], deps: Partial = {}) => { if (!underTmp(process.env.HOME)) tmpHome(); return realSetup(opts, { spaceProbes: { filesystemOf: async () => ({ dev: 1, freeBytes: 100 * GB }) }, + podspecReader: withRuby, ...deps, actions: { installSwift: noInstaller("installSwift"), @@ -110,6 +114,25 @@ describe("setup", () => { await setup({}, { checkSwiftPackages: noPending, probe: async () => all, log }); expect(log).toHaveBeenCalledWith(expect.stringContaining("Nothing to do")); }); + + it("says whether Ruby is there and installs nothing", async () => { + const lines = async (deps: Partial): Promise => { + const log = vi.fn(); + await setup({}, { checkSwiftPackages: noPending, probe: async () => all, ...deps, log }); + return log.mock.calls.map((c) => c[0] as string); + }; + const noRuby = () => ({ reader: "reduced", why: "Ruby was not found", forced: false, warning: null }) as const; + expect(await lines({ podspecReader: noRuby })).toEqual([ + "⚠ Ruby was not found: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby", + "✔ Nothing to do: toolchain already set up", + ]); + expect(await lines({ podspecReader: withRuby })).toEqual(["✔ ruby 3.3.8", "✔ Nothing to do: toolchain already set up"]); + // With an action to run, the line comes before it; the throwing installers prove nothing is installed for Ruby. + expect(await lines({ podspecReader: noRuby, probe: async () => ({ ...all, loggedIn: false }) })).toEqual([ + "⚠ Ruby was not found: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby", + "Run: rn-xtool auth login", + ]); + }); }); describe("preflightSdk", () => { @@ -240,7 +263,9 @@ describe("setup space check", () => { }; await setup({}, { checkSwiftPackages: noPending, probe: async () => state, spaceProbes, actions: spies(), log }); expect(order).toEqual( - state === all ? [removing, "✔ Nothing to do: toolchain already set up"] : [removing, "measured", "✔ xtool 1.24.0"], + state === all + ? [removing, RUBY_LINE, "✔ Nothing to do: toolchain already set up"] + : [removing, "measured", RUBY_LINE, "✔ xtool 1.24.0"], ); expect(existsSync(staging)).toBe(false); } @@ -319,20 +344,20 @@ describe("setup on a second run", () => { const m = machine("'Logged in.' '- Apple ID: me@example.com' '- Team ID: TEAMID0000'"); await m.run(); expect(calls(m)).toEqual([1, 1, 1, 4]); - expect(await m.run()).toEqual(["✔ Nothing to do: toolchain already set up"]); + expect(await m.run()).toEqual([RUBY_LINE, "✔ Nothing to do: toolchain already set up"]); expect(calls(m)).toEqual([1, 1, 1, 4]); const out = machine("'Logged out.'"); expect(await out.run()).toContain("Run: rn-xtool auth login"); expect(calls(out)).toEqual([1, 1, 1, 4]); - expect(await out.run()).toEqual(["Run: rn-xtool auth login"]); + expect(await out.run()).toEqual([RUBY_LINE, "Run: rn-xtool auth login"]); expect(calls(out)).toEqual([1, 1, 1, 4]); }); it("a second run downloads nothing with XDG_CONFIG_HOME set", async () => { const m = machine("'Logged in.'", true); await m.run(); - expect(await m.run()).toEqual(["✔ Nothing to do: toolchain already set up"]); + expect(await m.run()).toEqual([RUBY_LINE, "✔ Nothing to do: toolchain already set up"]); expect(calls(m)).toEqual([1, 1, 1, 4]); }); }); From a06fe7bbb388c4c20b664b57befac280d0213a7e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:11:19 -0600 Subject: [PATCH 18/53] fix: match setup's Ruby line to the reader --- src/commands/setup.ts | 12 ++++++------ tests/setup.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/commands/setup.ts b/src/commands/setup.ts index f2d8f6c..8cf214f 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -33,11 +33,11 @@ export interface SetupDeps { podspecReader: () => PodspecReaderChoice; } -/** setup's Ruby line: Ruby is never installed, only named. */ -function rubySetupLine(c: PodspecReaderChoice): string { - return c.reader === "ruby" - ? `✔ ruby ${c.ruby}` - : `⚠ ${c.why}: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby`; +/** setup's Ruby lines: Ruby is never installed, only named, and a forced reduced reader gets no install advice. */ +function rubySetupLines(c: PodspecReaderChoice): string[] { + if (c.reader === "ruby") return c.warning ? [`✔ ruby ${c.ruby}`, `⚠ ${c.warning}`] : [`✔ ruby ${c.ruby}`]; + const reduced = `⚠ ${c.why}: rn-xtool reads podspecs with its reduced reader`; + return [c.forced ? reduced : `${reduced}; install Ruby with: sudo apt install ruby`]; } export const GB = 1024 ** 3; @@ -340,7 +340,7 @@ export async function setup( log(`ℹ Removing ${tilde(staging)}, left by an interrupted Darwin SDK install.`); await rm(staging, { recursive: true, force: true }); }; - const logRuby = (): void => log(rubySetupLine((deps.podspecReader ?? podspecReaderHere)())); + const logRuby = (): void => rubySetupLines((deps.podspecReader ?? podspecReaderHere)()).forEach((line) => log(line)); if (actions.length === 0) { await removeSdkStaging(); logRuby(); diff --git a/tests/setup.test.ts b/tests/setup.test.ts index 829b30f..c73ee46 100644 --- a/tests/setup.test.ts +++ b/tests/setup.test.ts @@ -133,6 +133,28 @@ describe("setup", () => { "Run: rn-xtool auth login", ]); }); + + it("gives no install advice when the reduced reader is forced", async () => { + const log = vi.fn(); + const forced = () => ({ reader: "reduced", why: "RN_XTOOL_PODSPEC_READER=reduced is set", forced: true, warning: null }) as const; + await setup({}, { checkSwiftPackages: noPending, probe: async () => all, podspecReader: forced, log }); + expect(log.mock.calls.map((c) => c[0] as string)).toEqual([ + "⚠ RN_XTOOL_PODSPEC_READER=reduced is set: rn-xtool reads podspecs with its reduced reader", + "✔ Nothing to do: toolchain already set up", + ]); + }); + + it("names an unknown RN_XTOOL_PODSPEC_READER value under the Ruby line", async () => { + const log = vi.fn(); + const warning = "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby"; + const warned = () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning }) as const; + await setup({}, { checkSwiftPackages: noPending, probe: async () => all, podspecReader: warned, log }); + expect(log.mock.calls.map((c) => c[0] as string)).toEqual([ + "✔ ruby 3.3.8", + `⚠ ${warning}`, + "✔ Nothing to do: toolchain already set up", + ]); + }); }); describe("preflightSdk", () => { From 8371982849be1d2adc402bb4812815bc644aec67 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:17:45 -0600 Subject: [PATCH 19/53] feat: warn when a scaffold's reader differs --- src/pipeline/patches.ts | 49 ++++++++++++++++++++++++++---- tests/patches.test.ts | 67 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/src/pipeline/patches.ts b/src/pipeline/patches.ts index 0b78850..77843ee 100644 --- a/src/pipeline/patches.ts +++ b/src/pipeline/patches.ts @@ -16,6 +16,7 @@ import { scaffoldedPods } from "../project/earlyChecks.js"; import type { PodSource, PodTable } from "../project/podTable.js"; import type { ProjectKind } from "../project/types.js"; import { packageRoot, toolEnv } from "../tools/exec.js"; +import { podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; import { outside, packagesWithManifest } from "./manifests.js"; /** The patch-package pinned in this CLI's own dependencies, not whatever npx would fetch. */ @@ -362,6 +363,13 @@ const REVISION_RE = /^\+\/\/ (?:rn|expo)-xtool-scaffold-revision: (\d+)\s*$/m; export const SCAFFOLD_REVISION = 8; const PATCH_PODS_RE = /^\+\/\/ rn-xtool-pods: (.*?)\s*$/m; +const PODSPEC_READER_RE = /^\+\/\/ rn-xtool-podspec-reader: (ruby|reduced)\s*$/m; + +/** The podspec reader a persisted scaffold patch's marker block names; undefined without the line (before revision 8). */ +export function scaffoldReaderOf(patchText: string): "ruby" | "reduced" | undefined { + const reader = PODSPEC_READER_RE.exec(patchText)?.[1]; + return reader === "ruby" || reader === "reduced" ? reader : undefined; +} const MANIFEST_PODS_RE = /^\/\/ rn-xtool-pods: (.*?)\s*$/m; /** The `pod=exact` pairs of an rn-xtool-pods line; empty without one. */ @@ -428,13 +436,14 @@ const mappedNow = (c: PinChange): string => /** "the config says 3.1.0", "rn-xtool's table says 3.0.0" */ const says = (c: PinChange): string => `${c.source === "config" ? "the config" : "rn-xtool's table"} says ${c.now}`; -type ScaffoldPatchFinding = { kind: "slot" | "revision" | "pins"; line: string }; +type ScaffoldPatchFinding = { kind: "slot" | "revision" | "reader" | "pins"; line: string }; function scaffoldPatchFindings( projectRoot: string, table: PodTable | undefined, exclude: readonly string[], kind: ProjectKind | undefined, + reader: PodspecReaderChoice | undefined, ): ScaffoldPatchFinding[] { const installed = installedVersion(projectRoot, "react-native"); const dir = path.join(projectRoot, "patches"); @@ -480,6 +489,29 @@ function scaffoldPatchFindings( }); continue; } + const written = scaffoldReaderOf(text); + if (written !== undefined) { + // Probed once per call, and only for a patch that names its reader. + reader ??= podspecReaderHere(); + if (written === "reduced" && reader.reader === "ruby") { + findings.push({ + kind: "reader", + line: + `⚠ patches/${name} was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool ` + + `regenerates it ${tail}`, + }); + continue; + } + // Advice to keep the patch, so its pins are still compared below. + if (written === "ruby" && reader.reader === "reduced") { + findings.push({ + kind: "reader", + line: + `⚠ patches/${name} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + + `(${reader.why}): keep the patch, and install Ruby (sudo apt install ruby) before you regenerate it`, + }); + } + } if (table === undefined) continue; expected ??= scaffoldedPods(projectRoot, table, { exclude, ...(kind !== undefined ? { kind } : {}) }); const wanted = pkg === undefined ? [] : (expected.get(pkg) ?? []); @@ -506,17 +538,21 @@ function scaffoldPatchFindings( * Package.swift is only regenerated when the manifest is missing, so one is stale when its cache-slot label names * another React Native version than the installed one, when an older scaffolder revision wrote it, or (with `table`) * when its `rn-xtool-pods` line pins a pod at another version than the table, or leaves out a pod the library's - * podspec maps. One line per patch for the slot (which wins) or the revision, else one per pod. Patches of the - * packages the config's `exclude` lists get none: rn-xtool does not scaffold them again. `kind` decides which packages - * autolinking links, as in the early checks (`scaffoldedPods`). + * podspec maps. One line per patch for the slot (which wins) or the revision, else one per pod. A patch whose + * `rn-xtool-podspec-reader` line names another reader than this machine's (`reader`, else `podspecReaderHere()`) gets + * a line too: the reduced reader's patch where Ruby is available is stale (one line, as the revision), a Ruby patch + * where only the reduced reader runs is kept (its pins are still compared). Patches of the packages the config's + * `exclude` lists get none: rn-xtool does not scaffold them again. `kind` decides which packages autolinking links, as + * in the early checks (`scaffoldedPods`). */ export function scaffoldPatchWarnings( projectRoot: string, table?: PodTable, exclude: readonly string[] = [], kind?: ProjectKind, + reader?: PodspecReaderChoice, ): string[] { - return scaffoldPatchFindings(projectRoot, table, exclude, kind).map((f) => f.line); + return scaffoldPatchFindings(projectRoot, table, exclude, kind, reader).map((f) => f.line); } /** `scaffoldPatchWarnings`' pin lines alone, for `doctor --project`. */ @@ -525,8 +561,9 @@ export function scaffoldPinWarnings( table: PodTable, exclude: readonly string[] = [], kind?: ProjectKind, + reader?: PodspecReaderChoice, ): string[] { - return scaffoldPatchFindings(projectRoot, table, exclude, kind) + return scaffoldPatchFindings(projectRoot, table, exclude, kind, reader) .filter((f) => f.kind === "pins") .map((f) => f.line); } diff --git a/tests/patches.test.ts b/tests/patches.test.ts index 139391c..6e1a98a 100644 --- a/tests/patches.test.ts +++ b/tests/patches.test.ts @@ -27,6 +27,7 @@ import { import { mergedPodTable } from "../src/project/podTable.js"; import { AUTOLINKING_CONFIG_COMMAND, rnSpmArgs } from "../src/pipeline/rnSpm.js"; import { packageRoot } from "../src/tools/exec.js"; +import type { PodspecReaderChoice } from "../src/tools/podspecReader.js"; import { projectPaths } from "../src/paths.js"; const tempDirs: string[] = []; @@ -883,8 +884,15 @@ describe("patch-package failure detection", () => { }); describe("scaffold patches from another React Native version", () => { - /** A persisted scaffold patch; `revision: null` is a hand-made patch without rn-xtool's marker. */ - const scaffoldPatch = (slot: string | null, revision: number | null = SCAFFOLD_REVISION) => + /** + * A persisted scaffold patch; `revision: null` is a hand-made patch without rn-xtool's marker, `reader` the podspec + * reader its marker block names (null: none, as before revision 8). + */ + const scaffoldPatch = ( + slot: string | null, + revision: number | null = SCAFFOLD_REVISION, + reader: "ruby" | "reduced" | null = null, + ) => [ "diff --git a/node_modules/lib/Package.swift b/node_modules/lib/Package.swift", "new file mode 100644", @@ -895,9 +903,52 @@ describe("scaffold patches from another React Native version", () => { "+// AUTO-SCAFFOLDED-VERSION: 20", ...(revision !== null ? [`+// rn-xtool-scaffold-revision: ${revision}`] : []), ...(slot !== null ? [`+// Cache slot: ${slot}/dual-flavor`] : []), + ...(reader !== null ? [`+// rn-xtool-podspec-reader: ${reader}`] : []), "+import PackageDescription", "", ].join("\n"); + const RUBY_HERE: PodspecReaderChoice = { reader: "ruby", ruby: "ruby 3.3.8", forced: false, warning: null }; + const REDUCED_HERE: PodspecReaderChoice = { reader: "reduced", why: "Ruby was not found", forced: false, warning: null }; + const SVG = "react-native-svg+15.16.0.patch"; + /** An app on React Native 0.88.1 whose react-native-svg scaffold patch is `text`. */ + async function svgApp(text: string): Promise { + const { root } = await tempProject(); + await installPkg(root, "react-native", "0.88.1"); + await mkdir(path.join(root, "patches")); + await writeFile(path.join(root, "patches", SVG), text); + await installPkg(root, "react-native-svg"); + return root; + } + + it("warns when a reduced-reader scaffold meets Ruby", async () => { + const root = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "reduced")); + expect(scaffoldPatchWarnings(root, undefined, [], undefined, RUBY_HERE)).toEqual([ + `⚠ patches/${SVG} was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool ` + + "regenerates it (also remove node_modules/react-native-svg and reinstall: that copy still has the old Package.swift)", + ]); + }); + + it("warns when a Ruby scaffold meets the reduced reader", async () => { + const root = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); + expect(scaffoldPatchWarnings(root, undefined, [], undefined, REDUCED_HERE)).toEqual([ + `⚠ patches/${SVG} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + + "(Ruby was not found): keep the patch, and install Ruby (sudo apt install ruby) before you regenerate it", + ]); + }); + + it("says nothing when the readers agree or the patch is older", async () => { + const ruby = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); + expect(scaffoldPatchWarnings(ruby, undefined, [], undefined, RUBY_HERE)).toEqual([]); + const reduced = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "reduced")); + expect(scaffoldPatchWarnings(reduced, undefined, [], undefined, REDUCED_HERE)).toEqual([]); + // Revision 7 wrote no reader line: the revision line says it is stale. + const older = await svgApp(scaffoldPatch("0.88.1", 7)); + expect(scaffoldPatchWarnings(older, undefined, [], undefined, REDUCED_HERE)).toEqual([ + `⚠ patches/${SVG} was written by an older rn-xtool scaffolder (revision 7, now ${SCAFFOLD_REVISION}); delete it so ` + + "rn-xtool regenerates it (also remove node_modules/react-native-svg and reinstall: that copy still has the old " + + "Package.swift)", + ]); + }); it("warns once per scaffold patch whose cache slot names another version", async () => { const { root } = await tempProject(); @@ -1304,6 +1355,18 @@ describe("pod pins in scaffolds", () => { expect(scaffoldPinWarnings(stale, mergedPodTable())).toEqual([]); }); + it("still compares the pins of a Ruby scaffold this machine cannot regenerate with Ruby", async () => { + const reduced: PodspecReaderChoice = { reader: "reduced", why: "Ruby was not found", forced: false, warning: null }; + const root = await app(); + await persist(root, patch("AppAuth=2.1.0").replace("+// Cache slot:", "+// rn-xtool-podspec-reader: ruby\n+// Cache slot:")); + const pins = `⚠ patches/${PATCH} pins AppAuth 2.1.0, rn-xtool's table says 3.0.0; delete it so rn-xtool regenerates it ${TAIL}`; + expect(scaffoldPatchWarnings(root, mergedPodTable(), [], undefined, reduced)).toEqual([ + expect.stringContaining("was written by the Ruby podspec reader"), + pins, + ]); + expect(scaffoldPinWarnings(root, mergedPodTable(), [], undefined, reduced)).toEqual([pins]); + }); + it("expects the pods of a subspec whose sibling Expo's autolinking links as a peer", async () => { // On Expo every installed package is linked, so a subspec declaring a peer sibling is kept and its pods are pinned. const root = await app( From 1ed343d50d1fb93f2fe99d0bf2e8f79746869461 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:21:08 -0600 Subject: [PATCH 20/53] fix: drop the Ruby advice for a forced reader --- src/pipeline/patches.ts | 4 +++- tests/patches.test.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pipeline/patches.ts b/src/pipeline/patches.ts index 77843ee..503e731 100644 --- a/src/pipeline/patches.ts +++ b/src/pipeline/patches.ts @@ -504,11 +504,13 @@ function scaffoldPatchFindings( } // Advice to keep the patch, so its pins are still compared below. if (written === "ruby" && reader.reader === "reduced") { + // A forced reader was chosen on purpose, and Ruby may be installed: no apt advice (as rubyCheck). + const before = reader.forced ? "unset RN_XTOOL_PODSPEC_READER" : "install Ruby (sudo apt install ruby)"; findings.push({ kind: "reader", line: `⚠ patches/${name} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + - `(${reader.why}): keep the patch, and install Ruby (sudo apt install ruby) before you regenerate it`, + `(${reader.why}): keep the patch, and ${before} before you regenerate it`, }); } } diff --git a/tests/patches.test.ts b/tests/patches.test.ts index 6e1a98a..78a6a70 100644 --- a/tests/patches.test.ts +++ b/tests/patches.test.ts @@ -936,6 +936,21 @@ describe("scaffold patches from another React Native version", () => { ]); }); + it("asks to unset the variable when the reduced reader is forced", async () => { + const root = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); + const forced: PodspecReaderChoice = { + reader: "reduced", + why: "RN_XTOOL_PODSPEC_READER=reduced is set", + forced: true, + warning: null, + }; + expect(scaffoldPatchWarnings(root, undefined, [], undefined, forced)).toEqual([ + `⚠ patches/${SVG} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + + "(RN_XTOOL_PODSPEC_READER=reduced is set): keep the patch, and unset RN_XTOOL_PODSPEC_READER before you " + + "regenerate it", + ]); + }); + it("says nothing when the readers agree or the patch is older", async () => { const ruby = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); expect(scaffoldPatchWarnings(ruby, undefined, [], undefined, RUBY_HERE)).toEqual([]); From 70ebbcf90dd0e3eccecf0e470ea533f271ba7bb0 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:29:51 -0600 Subject: [PATCH 21/53] feat: say which podspec reader rn-spm used --- docs/troubleshooting.md | 49 ++++++++++++ src/commands/report.ts | 23 ++++-- src/paths.ts | 3 + src/pipeline/podspecReads.ts | 132 ++++++++++++++++++++++++++++++ src/pipeline/rnSpm.ts | 150 +++++++++++++++++++---------------- tests/podspecReads.test.ts | 95 ++++++++++++++++++++++ tests/report.test.ts | 49 +++++++++++- tests/rnSpm.test.ts | 107 +++++++++++++++++++++++-- 8 files changed, 525 insertions(+), 83 deletions(-) create mode 100644 src/pipeline/podspecReads.ts create mode 100644 tests/podspecReads.test.ts diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 358e641..6e813ac 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -971,6 +971,55 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin read-only, often after `sudo npm install`. Make it writable (reinstall without `sudo`), or apply the portable manifest yourself. +### Podspec reader + +The `rn-spm` step reads each library's podspec with the system `ruby`, through a shim of CocoaPods' DSL and React +Native's podspec helpers, so a podspec gives the same fields it gives under CocoaPods. Without a usable Ruby, it reads +them with its reduced reader, written in JavaScript, which evaluates the subset of Ruby podspecs use for their fields. +`rn-xtool doctor` names the reader this machine uses (`✔ ruby — 3.3.8`, or `⚠ ruby — not found — podspecs are read +with the reduced reader; sudo apt install ruby`). + +- **"⚠ Ruby was not found, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; + install Ruby (sudo apt install ruby) to read them as CocoaPods does.":** `rn-spm` prints this once, after its runs, + when the reduced reader read a podspec. The first words say why: `Ruby was not found`, `ruby 2.6.10 is older than + 2.7.0`, `ruby cannot load json`, or `ruby could not run the podspec reader ()`. The build goes on with the + reduced reader. Install Ruby 2.7 or newer (`sudo apt install ruby`), check it with `rn-xtool doctor`, and build again. + A scaffold the reduced reader persisted in `patches/` stays until you delete it: the `patches` step names each one + (`⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool + regenerates it …`), and the next build after you delete it scaffolds that library with Ruby. +- **"⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read the podspecs with its reduced reader, which evaluates + a subset of Ruby; unset it to read them as CocoaPods does.":** the variable is set in the environment of the build, + so the reduced reader read every podspec, Ruby or not. Unset it (`unset RN_XTOOL_PODSPEC_READER`) once the podspec + that needed it reads with Ruby again. +- **"⚠ RN_XTOOL_PODSPEC_READER= is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby":** + the variable is set to another value (`REDUCED`, `1`, `ruby`), which picks nothing. Set it to `reduced` exactly, or + unset it. +- **The environment a podspec sees:** rn-xtool reads every podspec with only `RCT_NEW_ARCH_ENABLED` and + `RCT_HERMES_V1_ENABLED` set, both to `1`; every other variable a podspec reads (`USE_FRAMEWORKS`, `USE_HERMES`, a + library's own) is unset, whatever your shell has. The podspec runs in its own folder, with `ios/` as CocoaPods' + installation root and nothing on its standard input. The names each podspec read are in `rn-xtool doctor --report`, + under `podspec ENV:`, one `: NAME, NAME` line per podspec; the build does not print them. +- **":: the podspec calls (…), which rn-xtool's podspec reader does not model. Set + RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor + --report.":** the podspec calls a method of CocoaPods or React Native the shim does not provide, and `rn-spm` stops + there. The same stop, with the same last sentence, has these other forms: + - `:: the podspec uses , which rn-xtool's podspec reader does not model` (a constant); + - `:: the podspec sets ., which CocoaPods does not define` (an attribute CocoaPods does + not have, often a typo); + - `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2` (a `require` of a gem); + - `: the podspec does not evaluate to a Pod::Spec`; + - ` did not finish in 30 s.` + + When the failing line is in another of the library's files, `:` reads ` (:)`. A + podspec that raises an error of its own (`raise`, `abort`) stops with its message after `:: `. + To build for one run, set the escape on the command: `RN_XTOOL_PODSPEC_READER=reduced rn-xtool build`. `rn-spm` then + prints the `⚠ RN_XTOOL_PODSPEC_READER=reduced is set` line, and `doctor --report` records the reduced reader. +- **To report a podspec the reader cannot read:** run `rn-xtool doctor --report` in the project folder after the + failed build and paste its block into a GitHub issue, with the stop's text and the library's name and version. Its + `podspec reader:` line names the reader of the last `rn-spm` and how many podspecs it read (`podspec reader: reduced: + RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 12 podspecs)`), and `podspec ENV:` lists the names each podspec + read. + ### Scaffolded libraries The `rn-spm` step scaffolds only the libraries React Native reports without a `Package.swift`, and it forces nothing: diff --git a/src/commands/report.ts b/src/commands/report.ts index a0eb185..3d1aba2 100644 --- a/src/commands/report.ts +++ b/src/commands/report.ts @@ -9,6 +9,8 @@ import { readFileSync } from "node:fs"; import os from "node:os"; import path from "node:path"; import { DEFAULT_CONFIG, loadConfig, type ExpoXtoolConfig } from "../config.js"; +import { projectPaths } from "../paths.js"; +import { podspecReportLines, readPodspecReads } from "../pipeline/podspecReads.js"; import { MissingBundleIdentifierError } from "../project/index.js"; import { packageRoot } from "../tools/exec.js"; import { doctorWithProbes, realProbes, renderReport, type DoctorProbes, type DoctorReport } from "./doctor.js"; @@ -253,14 +255,17 @@ function projectLine(r: DoctorReport, inProject: boolean): string { return parts.length > 0 ? parts.join(", ") : "unknown (see the project line)"; } -/** The block, fenced as text, before redaction. */ +/** + * The block, fenced as text, before redaction. `podspecLines` are the last `rn-spm`'s reader and `ENV` names + * (`podspecReportLines`): the report is the only place outside the reads file that names them (R2, R4). + */ export function renderIssueReport( r: DoctorReport, env: ReportEnv, - opts: { projectOnly: boolean; nodeVersion: string; inProject: boolean }, + opts: { projectOnly: boolean; nodeVersion: string; inProject: boolean; podspecLines: string[] }, ): string { - const tool = (name: string): string => - opts.projectOnly ? "not checked (--project)" : (r.checks.find((c) => c.name === name)?.detail ?? "not checked"); + const detail = (name: string): string => r.checks.find((c) => c.name === name)?.detail ?? "not checked"; + const tool = (name: string): string => (opts.projectOnly ? "not checked (--project)" : detail(name)); return [ "```text", "rn-xtool doctor --report", @@ -268,6 +273,9 @@ export function renderIssueReport( `node: ${opts.nodeVersion}`, `swift: ${tool("swift")}`, `xtool: ${tool("xtool")}`, + // doctor --project checks Ruby too. + `ruby: ${detail("ruby")}`, + ...opts.podspecLines, `os: ${env.os}, ${env.arch}`, `project: ${projectLine(r, opts.inProject)}`, renderReport(r.checks), @@ -329,10 +337,15 @@ export async function doctorReport( withCapabilities: true, noLiveProbes: true, }); + const inProject = root !== undefined || projectOnly; + // Without a project there is no reads file. + const project = inProject ? projectPaths(root ?? process.cwd()) : undefined; + const reads = project !== undefined ? readPodspecReads(project.podspecReads) : []; const text = renderIssueReport(r, env, { projectOnly, nodeVersion: probes.nodeVersion(), - inProject: root !== undefined || projectOnly, + inProject, + podspecLines: podspecReportLines(reads, project?.root ?? ""), }); return `${redact(text, { home, seen })}\n${REVIEW_LINE}`; }); diff --git a/src/paths.ts b/src/paths.ts index cdaed29..a9e36bf 100644 --- a/src/paths.ts +++ b/src/paths.ts @@ -20,6 +20,8 @@ export interface ProjectPaths { projectPatchesDir: string; /** What the driver's scaffold step did for each library (`rn-spm-generate.js --results`). */ scaffoldResults: string; + /** One JSON line per podspec read of the last `rn-spm` (`RN_SPM_PODSPEC_READS`, src/pipeline/podspecReads.ts). */ + podspecReads: string; /** The generated package of the binary CocoaPods pods (`src/pods/stage.ts`). */ podBinaries: string; sources: string; @@ -48,6 +50,7 @@ export function projectPaths(root: string): ProjectPaths { patchesDir: join(iosXtool, ".patches"), projectPatchesDir: join(iosXtool, ".project-patches"), scaffoldResults: join(iosBuild, "rn-xtool-scaffold-results.json"), + podspecReads: join(iosBuild, "rn-xtool-podspec-reads.jsonl"), podBinaries: join(iosBuild, "pod-binaries"), sources: join(iosXtool, "Sources", "App"), frameworks: join(iosXtool, "Frameworks"), diff --git a/src/pipeline/podspecReads.ts b/src/pipeline/podspecReads.ts new file mode 100644 index 0000000..8a01ff7 --- /dev/null +++ b/src/pipeline/podspecReads.ts @@ -0,0 +1,132 @@ +/** + * The podspec reads the vendored scaffolder records in `RN_SPM_PODSPEC_READS` (`recordPodspecRead` in + * vendor/rn-spm/spm/read-podspec.js): one JSON line per read, turned here into the `⚠` line `rn-spm` prints and the + * lines of `doctor --report`. The `ENV` names a podspec read never go to the terminal during a build (R4). + */ +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { troubleshootingUrl } from "../docs.js"; + +export interface PodspecRead { + /** The podspec's absolute path. */ + podspec: string; + reader: "ruby" | "reduced"; + /** Why the reduced reader read it. */ + why?: string; + /** `RN_XTOOL_PODSPEC_READER=reduced` picked the reduced reader. */ + forced: boolean; + /** The Ruby version that read it. */ + ruby?: string; + /** What the reader choice warned about (an unknown `RN_XTOOL_PODSPEC_READER` value). */ + warning?: string; + /** The `ENV` names the podspec read. */ + env: string[]; + helpers: string[]; + ok: boolean; + error?: string; +} + +const strings = (v: unknown): string[] => (Array.isArray(v) ? v.filter((s): s is string => typeof s === "string") : []); +const text = (v: unknown): string | undefined => (typeof v === "string" && v !== "" ? v : undefined); + +/** One line of the file, or undefined when it is not a read. */ +function podspecRead(line: string): PodspecRead | undefined { + let v: unknown; + try { + v = JSON.parse(line); + } catch { + return undefined; + } + if (typeof v !== "object" || v === null) return undefined; + const o = v as Record; + if (typeof o.podspec !== "string" || (o.reader !== "ruby" && o.reader !== "reduced")) return undefined; + const why = text(o.why); + const ruby = text(o.ruby); + const warning = text(o.warning); + const error = text(o.error); + return { + podspec: o.podspec, + reader: o.reader, + ...(why !== undefined ? { why } : {}), + forced: o.forced === true, + ...(ruby !== undefined ? { ruby } : {}), + ...(warning !== undefined ? { warning } : {}), + env: strings(o.env), + helpers: strings(o.helpers), + ok: o.ok === true, + ...(error !== undefined ? { error } : {}), + }; +} + +/** The reads `file` records, in order: none without the file; a line that is not a read is skipped. */ +export function readPodspecReads(file: string): PodspecRead[] { + let raw: string; + try { + raw = readFileSync(file, "utf8"); + } catch { + return []; + } + return raw + .split("\n") + .filter((l) => l.trim() !== "") + .map(podspecRead) + .filter((r): r is PodspecRead => r !== undefined); +} + +const REDUCED = "so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby"; + +/** + * What `rn-spm` prints about its reads, once per run: the reader choice's warning, then, when the reduced reader read + * a podspec, why and what to do (the escape named when it was used, R2). Nothing when Ruby read every podspec. + */ +export function readerLines(reads: PodspecRead[]): string[] { + const lines: string[] = []; + const warning = reads.find((r) => r.warning !== undefined)?.warning; + if (warning !== undefined) lines.push(`⚠ ${warning}`); + const reduced = reads.find((r) => r.reader === "reduced"); + if (reduced !== undefined) { + const see = `See ${troubleshootingUrl("podspec-reader")}`; + lines.push( + reduced.forced + ? `⚠ RN_XTOOL_PODSPEC_READER=reduced is set, ${REDUCED}; unset it to read them as CocoaPods does. ${see}` + : `⚠ ${reduced.why ?? "Ruby was not used"}, ${REDUCED}; install Ruby (sudo apt install ruby) to read them as ` + + `CocoaPods does. ${see}`, + ); + } + return lines; +} + +/** Each podspec read (once, though several runs read it) with the sorted `ENV` names its reads used, path from `root`. */ +function podspecEnvNames(reads: PodspecRead[], root: string): [string, string[]][] { + const names = new Map>(); + for (const r of reads) { + const set = names.get(r.podspec) ?? new Set(); + for (const n of r.env) set.add(n); + names.set(r.podspec, set); + } + return [...names] + .filter(([, set]) => set.size > 0) + .map(([podspec, set]): [string, string[]] => [path.relative(root, podspec), [...set].sort()]); +} + +/** `ℹ podspec ENV — : A, B` per podspec that read any `ENV` name: for the build log, never the terminal (R4). */ +export function podspecEnvLines(reads: PodspecRead[], root: string): string[] { + return podspecEnvNames(reads, root).map(([podspec, names]) => `ℹ podspec ENV — ${podspec}: ${names.join(", ")}`); +} + +/** + * `doctor --report`'s lines for the last `rn-spm`'s reads: `podspec reader: > (last rn-spm, + * podspecs)`, or `podspec reader: not recorded` without any; then `podspec ENV:` and one ` : A, B` line per + * podspec that read any `ENV` name. + */ +export function podspecReportLines(reads: PodspecRead[], root: string): string[] { + if (reads.length === 0) return ["podspec reader: not recorded"]; + const reduced = reads.find((r) => r.reader === "reduced"); + const reader = reduced !== undefined ? `reduced: ${reduced.why ?? "unknown"}` : `ruby ${reads[0]!.ruby ?? "unknown"}`; + const n = new Set(reads.map((r) => r.podspec)).size; + const env = podspecEnvNames(reads, root); + return [ + `podspec reader: ${reader} (last rn-spm, ${n} ${n === 1 ? "podspec" : "podspecs"})`, + ...(env.length > 0 ? ["podspec ENV:", ...env.map(([podspec, names]) => ` ${podspec}: ${names.join(", ")}`)] : []), + ]; +} diff --git a/src/pipeline/rnSpm.ts b/src/pipeline/rnSpm.ts index ea5fb7c..77ec5dd 100644 --- a/src/pipeline/rnSpm.ts +++ b/src/pipeline/rnSpm.ts @@ -9,6 +9,7 @@ import type { ExpoPlugin, RnScripts } from "../versions.js"; import { packageRoot, runArgv, toolEnv } from "../tools/exec.js"; import type { PodEntry } from "../config.js"; import { POD_TABLE_ENV, mergedPodTable, writePodTable, type PodBinary, type PodTable } from "../project/podTable.js"; +import { readerLines, readPodspecReads } from "./podspecReads.js"; export const AUTOLINKING_CONFIG_COMMAND = [ "npx", @@ -226,13 +227,16 @@ function scaffoldFailureMessage(failed: ScaffoldOutcome["failed"]): string { * Env of every React Native run. RN's scaffolder warns about mixed-language libraries when the * Swift headers dir is unset, and any manifest it evaluates must see the same value the xtool build * uses. The vendored Expo plugin takes its precompiled modules from `ios/build/expo-precompiled`. The scaffolder - * maps CocoaPods pods with the pod table file, when given. + * maps CocoaPods pods with the pod table file, when given. It records each podspec read in the reads file, and reads + * every podspec with the app's `ios/` as CocoaPods' installation root. */ export function rnSpmEnv(paths: ProjectPaths, expoPlugin: ExpoPlugin, podTableFile?: string): Record { return { ...swiftHeadersEnv(paths.iosXtool), ...(expoPlugin === "vendored" ? { EXPO_PRECOMPILED_MODULES_PATH: paths.expoPrecompiled } : {}), ...(podTableFile !== undefined ? { [POD_TABLE_ENV]: podTableFile } : {}), + RN_SPM_PODSPEC_READS: paths.podspecReads, + RN_SPM_APP_IOS_DIR: paths.ios, }; } @@ -521,79 +525,85 @@ export async function runRnSpm( // Every run gets the table: the scaffold step reads it, whichever project kind runs it. const podTableFile = (deps.writePodTable ?? writePodTable)(paths, mergedPodTable(opts.pods, opts.binary)); const env = rnSpmEnv(paths, opts.expoPlugin, podTableFile); + // A file a previous run left must never stand for this run's reads. + rmSync(paths.podspecReads, { force: true }); + try { + const first = await runner("node", rnArgs, { cwd: paths.ios, env }); + if (first.exitCode === 0) return; - const first = await runner("node", rnArgs, { cwd: paths.ios, env }); - if (first.exitCode === 0) return; - - const names = parseMissingPackageSwift(first.output); - if (names.length === 0) - throw new Error( - `React Native SwiftPM setup failed (exit ${first.exitCode}):\n${tail(first.output)}`, - ); + const names = parseMissingPackageSwift(first.output); + if (names.length === 0) + throw new Error( + `React Native SwiftPM setup failed (exit ${first.exitCode}):\n${tail(first.output)}`, + ); - log(`▸ scaffold — generating Package.swift for: ${names.join(", ")}`); - // A file a previous run left must never stand for this run's. - rmSync(paths.scaffoldResults, { force: true }); - const sc = await runner("node", rnSpmScaffoldArgs(paths, opts, names, rnDir), { cwd: paths.ios, env }); - const scaffoldFailed = () => new Error(`React Native spm scaffold failed (exit ${sc.exitCode}):\n${tail(sc.output)}`); - const outcome = scaffoldOutcome(paths, names); - if (outcome === undefined && sc.exitCode !== 0) throw scaffoldFailed(); - - // Only what was scaffolded is persisted; a failed library stops the build before React Native runs again. - for (const name of outcome?.scaffolded ?? names) { - // The library's patch as it was: put back when the new one would carry a binary file. - const before = libraryPatches(paths.root, name); - // The scaffold's files and the existing patch's, never the rest of the package (build outputs). - const scope = persistScope(name, outcome?.files.get(name), before); - if (scope.note !== undefined) log(scope.note); - const [cmd, args] = persistScaffoldArgv(name, scope.include); - let failure: string | undefined; - let persisted = ""; - try { - const r = await runner(cmd, args, { cwd: paths.root }); - persisted = r.output; - if (r.exitCode !== 0) failure = patchPackageReason(r.output, r.exitCode); - } catch (e) { - failure = firstLine(e instanceof Error ? e.message : String(e)) || "spawn error"; + log(`▸ scaffold — generating Package.swift for: ${names.join(", ")}`); + // A file a previous run left must never stand for this run's. + rmSync(paths.scaffoldResults, { force: true }); + const sc = await runner("node", rnSpmScaffoldArgs(paths, opts, names, rnDir), { cwd: paths.ios, env }); + const scaffoldFailed = () => new Error(`React Native spm scaffold failed (exit ${sc.exitCode}):\n${tail(sc.output)}`); + const outcome = scaffoldOutcome(paths, names); + if (outcome === undefined && sc.exitCode !== 0) throw scaffoldFailed(); + + // Only what was scaffolded is persisted; a failed library stops the build before React Native runs again. + for (const name of outcome?.scaffolded ?? names) { + // The library's patch as it was: put back when the new one would carry a binary file. + const before = libraryPatches(paths.root, name); + // The scaffold's files and the existing patch's, never the rest of the package (build outputs). + const scope = persistScope(name, outcome?.files.get(name), before); + if (scope.note !== undefined) log(scope.note); + const [cmd, args] = persistScaffoldArgv(name, scope.include); + let failure: string | undefined; + let persisted = ""; + try { + const r = await runner(cmd, args, { cwd: paths.root }); + persisted = r.output; + if (r.exitCode !== 0) failure = patchPackageReason(r.output, r.exitCode); + } catch (e) { + failure = firstLine(e instanceof Error ? e.message : String(e)) || "spawn error"; + } + if (failure !== undefined) { + log( + `⚠ Could not persist ${name}'s Package.swift to patches/ (${failure}). The build continues; it will be re-scaffolded on the next fresh install.`, + ); + continue; + } + const patchFile = createdPatchFile(persisted) ?? computedPatchFile(paths.root, name); + // Every patch file of the library that is new or changed, and the one it names: the guard fails closed (row 40). + const after = libraryPatches(paths.root, name); + const changed = [...after].filter(([f, bytes]) => !before.get(f)?.equals(bytes)).map(([, bytes]) => bytes); + let named: Buffer | undefined; + try { + named = readFileSync(path.join(paths.root, patchFile)); + } catch { + // Not under the name it printed. + } + if (named === undefined && changed.length === 0) { + restorePatches(paths.root, name, before); + log(`⚠ Did not persist ${name}'s scaffold: rn-xtool could not read ${patchFile} to check it for binary files`); + continue; + } + const binary = [...changed, ...(named !== undefined ? [named] : [])] + .map((bytes) => binaryInPatch(bytes.toString("latin1"))) + .find((b) => b !== undefined); + if (binary !== undefined) { + restorePatches(paths.root, name, before); + log(`⚠ Did not persist ${name}'s scaffold: the patch would contain a binary file (${binary})`); + continue; + } + log(`✔ scaffold — persisted ${patchFile}`); } - if (failure !== undefined) { - log( - `⚠ Could not persist ${name}'s Package.swift to patches/ (${failure}). The build continues; it will be re-scaffolded on the next fresh install.`, + if (outcome !== undefined && outcome.failed.length > 0) throw new Error(scaffoldFailureMessage(outcome.failed)); + if (sc.exitCode !== 0) throw scaffoldFailed(); + + const second = await runner("node", rnArgs, { cwd: paths.ios, env }); + if (second.exitCode !== 0) { + throw new Error( + `React Native SwiftPM setup still failed after scaffolding ${names.join(", ")} (exit ${second.exitCode}):\n${tail(second.output)}`, ); - continue; } - const patchFile = createdPatchFile(persisted) ?? computedPatchFile(paths.root, name); - // Every patch file of the library that is new or changed, and the one it names: the guard fails closed (row 40). - const after = libraryPatches(paths.root, name); - const changed = [...after].filter(([f, bytes]) => !before.get(f)?.equals(bytes)).map(([, bytes]) => bytes); - let named: Buffer | undefined; - try { - named = readFileSync(path.join(paths.root, patchFile)); - } catch { - // Not under the name it printed. - } - if (named === undefined && changed.length === 0) { - restorePatches(paths.root, name, before); - log(`⚠ Did not persist ${name}'s scaffold: rn-xtool could not read ${patchFile} to check it for binary files`); - continue; - } - const binary = [...changed, ...(named !== undefined ? [named] : [])] - .map((bytes) => binaryInPatch(bytes.toString("latin1"))) - .find((b) => b !== undefined); - if (binary !== undefined) { - restorePatches(paths.root, name, before); - log(`⚠ Did not persist ${name}'s scaffold: the patch would contain a binary file (${binary})`); - continue; - } - log(`✔ scaffold — persisted ${patchFile}`); - } - if (outcome !== undefined && outcome.failed.length > 0) throw new Error(scaffoldFailureMessage(outcome.failed)); - if (sc.exitCode !== 0) throw scaffoldFailed(); - - const second = await runner("node", rnArgs, { cwd: paths.ios, env }); - if (second.exitCode !== 0) { - throw new Error( - `React Native SwiftPM setup still failed after scaffolding ${names.join(", ")} (exit ${second.exitCode}):\n${tail(second.output)}`, - ); + } finally { + // Once per run, every React Native run's reads together; also when one failed, before its error. + for (const line of readerLines(readPodspecReads(paths.podspecReads))) log(line); } } diff --git a/tests/podspecReads.test.ts b/tests/podspecReads.test.ts new file mode 100644 index 0000000..f18ba9a --- /dev/null +++ b/tests/podspecReads.test.ts @@ -0,0 +1,95 @@ +import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { afterEach, describe, expect, it } from "vitest"; +import { + podspecEnvLines, + readerLines, + readPodspecReads, + type PodspecRead, +} from "../src/pipeline/podspecReads.js"; + +const LINK = "https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader"; +const read = (podspec: string, over: Partial = {}): PodspecRead => ({ + podspec, + reader: "ruby", + ruby: "3.3.8", + forced: false, + env: [], + helpers: [], + ok: true, + ...over, +}); +const rubyRead = read("/proj/node_modules/a/A.podspec"); +const reduced = (podspec: string): PodspecRead => + read(podspec, { reader: "reduced", ruby: undefined, why: "Ruby was not found" }); +const forced = (podspec: string): PodspecRead => + read(podspec, { reader: "reduced", ruby: undefined, why: "RN_XTOOL_PODSPEC_READER=reduced is set", forced: true }); + +const tmp: string[] = []; +afterEach(() => { + for (const d of tmp.splice(0)) rmSync(d, { recursive: true, force: true }); +}); + +describe("readPodspecReads", () => { + it("reads nothing without the file", () => { + const dir = mkdtempSync(path.join(tmpdir(), "rn-xtool-reads-")); + tmp.push(dir); + expect(readPodspecReads(path.join(dir, "rn-xtool-podspec-reads.jsonl"))).toEqual([]); + }); + + it("skips a line it cannot parse", () => { + const dir = mkdtempSync(path.join(tmpdir(), "rn-xtool-reads-")); + tmp.push(dir); + const file = path.join(dir, "rn-xtool-podspec-reads.jsonl"); + writeFileSync(file, `${JSON.stringify(rubyRead)}\n{"podspec": "/half\n\n${JSON.stringify(forced("/b/B.podspec"))}\n`); + expect(readPodspecReads(file)).toEqual([rubyRead, forced("/b/B.podspec")]); + }); +}); + +describe("readerLines", () => { + it("prints the reduced reader once per run", () => { + const lines = readerLines([reduced("/proj/node_modules/a/A.podspec"), reduced("/proj/node_modules/b/B.podspec")]); + expect(lines).toEqual([ + "⚠ Ruby was not found, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; " + + `install Ruby (sudo apt install ruby) to read them as CocoaPods does. See ${LINK}`, + ]); + expect(lines[0]!.startsWith("⚠ Ruby was not found, so rn-xtool read the podspecs")).toBe(true); + expect(lines[0]!.endsWith(`See ${LINK}`)).toBe(true); + }); + + it("names the forced reader", () => { + expect(readerLines([forced("/proj/node_modules/a/A.podspec"), forced("/proj/node_modules/b/B.podspec")])).toEqual([ + "⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read the podspecs with its reduced reader, which evaluates " + + `a subset of Ruby; unset it to read them as CocoaPods does. See ${LINK}`, + ]); + }); + + it("prints the reader's warning first", () => { + const warning = "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby"; + expect(readerLines([read("/a/A.podspec", { warning }), read("/b/B.podspec", { warning })])).toEqual([`⚠ ${warning}`]); + expect(readerLines([reduced("/a/A.podspec"), { ...reduced("/b/B.podspec"), warning }])).toEqual([ + `⚠ ${warning}`, + expect.stringMatching(/^⚠ Ruby was not found, so rn-xtool read the podspecs/), + ]); + }); + + it("says nothing when Ruby read every podspec", () => expect(readerLines([rubyRead])).toEqual([])); +}); + +describe("podspecEnvLines", () => { + it("lists the ENV names per podspec", () => { + const reads = [ + read("/proj/node_modules/x/X.podspec", { env: ["USE_FRAMEWORKS", "RCT_NEW_ARCH_ENABLED"] }), + read("/proj/node_modules/y/Y.podspec"), + ]; + expect(podspecEnvLines(reads, "/proj")).toEqual([ + "ℹ podspec ENV — node_modules/x/X.podspec: RCT_NEW_ARCH_ENABLED, USE_FRAMEWORKS", + ]); + }); + + it("lists a podspec read in several runs once", () => { + const x = read("/proj/node_modules/x/X.podspec", { env: ["USE_FRAMEWORKS"] }); + expect(podspecEnvLines([x, x], "/proj")).toEqual(["ℹ podspec ENV — node_modules/x/X.podspec: USE_FRAMEWORKS"]); + }); +}); diff --git a/tests/report.test.ts b/tests/report.test.ts index 4030543..d21c2a4 100644 --- a/tests/report.test.ts +++ b/tests/report.test.ts @@ -150,6 +150,8 @@ describe("doctorReport", () => { "node: 24.15.0", "swift: 6.4", `xtool: ${XTOOL_VERSION}`, + "ruby: 3.3.8", + "podspec reader: not recorded", "os: Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic, x64", "project: expo, Expo SDK 58, expo 58.0.21, react-native 0.88.1", "✔ node — 24.15.0", @@ -256,15 +258,60 @@ describe("doctorReport", () => { it("says the toolchain was not checked with --project", async () => { const lines = (await doctorReport("/home/me/apps/demo", { env, probes, projectOnly: true })).split("\n"); - expect(lines.slice(4, 8)).toEqual([ + expect(lines.slice(4, 10)).toEqual([ "swift: not checked (--project)", "xtool: not checked (--project)", + "ruby: 3.3.8", + "podspec reader: not recorded", "os: Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic, x64", "project: expo, Expo SDK 58, expo 58.0.21, react-native 0.88.1", ]); expect(lines.some((l) => l.startsWith("✔ apple-login"))).toBe(false); }); + it("records the last build's reader and ENV names", async () => { + const root = await tempDir("rn-xtool-report-reads-"); + const reads = path.join(root, "ios", "build", "rn-xtool-podspec-reads.jsonl"); + await mkdir(path.dirname(reads), { recursive: true }); + const forced = (podspec: string, names: string[]) => + JSON.stringify({ + podspec: path.join(root, podspec), + reader: "reduced", + why: "RN_XTOOL_PODSPEC_READER=reduced is set", + forced: true, + env: names, + helpers: [], + ok: true, + }); + await writeFile( + reads, + `${forced("node_modules/x/X.podspec", ["USE_FRAMEWORKS", "RCT_NEW_ARCH_ENABLED"])}\n` + + `${forced("node_modules/y/Y.podspec", [])}\n`, + ); + const lines = (await doctorReport(root, { env, probes })).split("\n"); + const at = lines.indexOf(`xtool: ${XTOOL_VERSION}`); + expect(lines.slice(at + 1, at + 5)).toEqual([ + "ruby: 3.3.8", + "podspec reader: reduced: RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 2 podspecs)", + "podspec ENV:", + " node_modules/x/X.podspec: RCT_NEW_ARCH_ENABLED, USE_FRAMEWORKS", + ]); + expect(lines[at + 5]).toMatch(/^os: /); + // Inside the block: the fence closes after them. + expect(lines.indexOf("```")).toBeGreaterThan(at + 4); + + const rubyRead = { podspec: path.join(root, "a.podspec"), reader: "ruby", ruby: "3.3.8", forced: false, env: [], helpers: [], ok: true }; + await writeFile(reads, `${JSON.stringify(rubyRead)}\n`); + const ruby = (await doctorReport(root, { env, probes })).split("\n"); + expect(ruby).toContain("podspec reader: ruby 3.3.8 (last rn-spm, 1 podspec)"); + expect(ruby.some((l) => l.startsWith("podspec ENV:"))).toBe(false); + }); + + it("records no reader without a project", async () => { + const lines = (await doctorReport(undefined, { env, probes })).split("\n"); + expect(lines).toContain("podspec reader: not recorded"); + }); + it("names only the parts the project has", async () => { const bare: Capabilities = { kind: "bare", rnVersion: "0.88.1", podspecs: noPodspecs }; const out = await doctorReport("/home/me/apps/demo", { env, probes: { ...probes, capabilities: async () => bare } }); diff --git a/tests/rnSpm.test.ts b/tests/rnSpm.test.ts index 2924f67..4b5908a 100644 --- a/tests/rnSpm.test.ts +++ b/tests/rnSpm.test.ts @@ -25,9 +25,18 @@ import { mergedPodTable, type PodTable } from "../src/project/podTable.js"; import path from "node:path"; const RESULTS = "/proj/ios/build/rn-xtool-scaffold-results.json"; -const paths = { root: "/proj", ios: "/proj/ios", iosXtool: "/proj/ios-xtool", scaffoldResults: RESULTS } as unknown as ProjectPaths; +const READS = "/proj/ios/build/rn-xtool-podspec-reads.jsonl"; +const paths = { + root: "/proj", + ios: "/proj/ios", + iosXtool: "/proj/ios-xtool", + scaffoldResults: RESULTS, + podspecReads: READS, +} as unknown as ProjectPaths; const SWIFT_HEADERS = "/proj/ios-xtool/.build/out/Intermediates.noindex/GeneratedModuleMaps-iphoneos"; const POD_TABLE = "/proj/ios/build/rn-xtool-pods.json"; +/** What every React Native run gets for the podspec reads (Task 10). */ +const READS_ENV = { RN_SPM_PODSPEC_READS: READS, RN_SPM_APP_IOS_DIR: "/proj/ios" }; const rnDir = "/proj/node_modules/react-native"; const INST = { rnScripts: "installed" } as const; const missing = (n: string) => @@ -203,6 +212,7 @@ describe("Expo on the driver", () => { RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, EXPO_PRECOMPILED_MODULES_PATH: "/proj/ios/build/expo-precompiled", RN_SPM_POD_TABLE: POD_TABLE, + ...READS_ENV, }; expect(h.calls).toEqual([ { cmd: "node", args: generate, cwd: "/proj/ios", env }, @@ -217,7 +227,7 @@ describe("Expo on the driver", () => { const setup = `${rnDir}/scripts/setup-apple-spm.js`; const cfg = '["npx","expo-modules-autolinking","react-native-config","--json","--platform","ios"]'; const offline = ["--download", "skip", "--artifacts", "/art"]; - const env = { RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE }; + const env = { RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE, ...READS_ENV }; const h = harness([ { exitCode: 1, output: missing("lib-a") }, { exitCode: 0, output: "" }, @@ -253,8 +263,12 @@ describe("Expo on the driver", () => { { cmd: persistScaffoldArgv("lib-a")[0], args: persistScaffoldArgv("lib-a")[1], cwd: "/proj" }, { cmd: "node", args: [setup, "add", "--config-command", cfg, "--yes", ...offline], cwd: "/proj/ios", env }, ]); - expect(rnSpmEnv(full, "installed")).toEqual(swiftHeadersEnv(full.iosXtool)); - expect(rnSpmEnv(full, "installed", POD_TABLE)).toEqual({ ...swiftHeadersEnv(full.iosXtool), RN_SPM_POD_TABLE: POD_TABLE }); + expect(rnSpmEnv(full, "installed")).toEqual({ ...swiftHeadersEnv(full.iosXtool), ...READS_ENV }); + expect(rnSpmEnv(full, "installed", POD_TABLE)).toEqual({ + ...swiftHeadersEnv(full.iosXtool), + RN_SPM_POD_TABLE: POD_TABLE, + ...READS_ENV, + }); const bare = harness([{ exitCode: 0, output: "" }]); await runRnSpm(full, { kind: "bare", rnScripts: "vendored", expoPlugin: "installed", rnArtifactsDir: "/art" }, bare.deps); @@ -278,7 +292,7 @@ describe("runRnSpm", () => { cmd: "node", args: rnSpmGenerateArgs(paths, INST, rnDir), cwd: "/proj/ios", - env: { RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE }, + env: { RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE, ...READS_ENV }, }, ]); const expo = harness([{ exitCode: 0, output: "" }]); @@ -286,6 +300,83 @@ describe("runRnSpm", () => { expect(expo.calls[0]!.args).toEqual(rnSpmArgs(paths, {}, rnDir)); }); + it("hands the scaffolder the reads file and the iOS folder", () => { + const full = projectPaths("/proj"); + expect(full.podspecReads).toBe(READS); + expect(rnSpmEnv(full, "installed", POD_TABLE)).toMatchObject({ + RN_SPM_PODSPEC_READS: READS, + RN_SPM_APP_IOS_DIR: "/proj/ios", + }); + }); + + it("prints the reader line after rn-spm, also when it fails", async () => { + const root = mkdtempSync(path.join(tmpdir(), "rn-spm-reads-")); + try { + const full = projectPaths(root); + mkdirSync(full.iosBuild, { recursive: true }); + // A previous run's read, with a warning: never this run's. + writeFileSync(full.podspecReads, `${JSON.stringify({ podspec: "/old.podspec", reader: "ruby", warning: "old" })}\n`); + const events: string[] = []; + const runner: RnRunner = async (_cmd, _args, o) => { + const file = o.env?.["RN_SPM_PODSPEC_READS"]; + if (file === undefined) throw new Error("no RN_SPM_PODSPEC_READS"); + for (const name of ["a", "b"]) { + const read = { + podspec: path.join(root, "node_modules", name, `${name}.podspec`), + reader: "reduced", + why: "Ruby was not found", + forced: false, + env: ["USE_FRAMEWORKS"], + helpers: [], + ok: true, + }; + writeFileSync(file, `${JSON.stringify(read)}\n`, { flag: "a" }); + } + return { exitCode: 1, output: "rn-spm-generate: boom" }; + }; + const deps = { runner, log: (s: string) => events.push(s), rnDir, writePodTable: () => POD_TABLE }; + await runRnSpm(full, { kind: "bare", rnScripts: "vendored", expoPlugin: "installed" }, deps).catch((e: Error) => + events.push(`error: ${e.message.split("\n")[0]}`), + ); + expect(events).toEqual([ + "⚠ Ruby was not found, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; " + + "install Ruby (sudo apt install ruby) to read them as CocoaPods does. " + + "See https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader", + "error: React Native SwiftPM setup failed (exit 1):", + ]); + // The ENV names go to the reads file only, never to the terminal (R4). + expect(events.join("\n")).not.toContain("USE_FRAMEWORKS"); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); + + it("prints the reader line once when React Native runs again", async () => { + const root = mkdtempSync(path.join(tmpdir(), "rn-spm-reads-")); + try { + const full = projectPaths(root); + mkdirSync(full.iosBuild, { recursive: true }); + const logs: string[] = []; + let runs = 0; + const runner: RnRunner = async (_cmd, args, o) => { + runs++; + if (args.includes("--scaffold")) return { exitCode: 0, output: "" }; + const file = o.env?.["RN_SPM_PODSPEC_READS"]; + const read = { podspec: path.join(root, "x.podspec"), reader: "reduced", why: "Ruby was not found", forced: false }; + if (file !== undefined) writeFileSync(file, `${JSON.stringify({ ...read, env: [], helpers: [], ok: true })}\n`, { flag: "a" }); + return runs === 1 ? { exitCode: 2, output: missing("lib-a") } : { exitCode: 0, output: "" }; + }; + await runRnSpm( + full, + { kind: "bare", rnScripts: "vendored", expoPlugin: "installed" }, + { runner, log: (s) => logs.push(s), rnDir, writePodTable: () => POD_TABLE }, + ).catch(() => undefined); + expect(logs.filter((l) => l.startsWith("⚠ Ruby was not found"))).toHaveLength(1); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); + it("refuses to run without the project kind (never `add --yes` by default)", async () => { const h = harness([{ exitCode: 0, output: "" }]); await expect(runRnSpm(paths, {} as never, h.deps)).rejects.toThrow(/project kind/); @@ -317,7 +408,7 @@ describe("runRnSpm", () => { ]); for (const c of [h.calls[0]!, h.calls[1]!, h.calls[3]!]) { expect(c.cwd).toBe("/proj/ios"); - expect(c.env).toEqual({ RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE }); + expect(c.env).toEqual({ RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE, ...READS_ENV }); } }); @@ -402,7 +493,9 @@ describe("runRnSpm", () => { await runRnSpm(paths, { kind: "expo", rnScripts: "installed", expoPlugin: "installed" }, h.deps); const rnRuns = h.calls.filter((c) => c.cmd === "node"); expect(rnRuns.map((c) => c.args[1])).toEqual([expect.stringMatching(/add|update/), "--rn-dir", expect.stringMatching(/add|update/)]); - for (const c of rnRuns) expect(c.env).toEqual({ RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE }); + for (const c of rnRuns) { + expect(c.env).toEqual({ RN_SPM_SWIFT_HEADERS_DIR: SWIFT_HEADERS, RN_SPM_POD_TABLE: POD_TABLE, ...READS_ENV }); + } expect(h.calls[1]!.args).toContain("--scaffold"); expect(h.calls[2]!.args[1]).toBe("pager"); }); From ca3fd918e5fb7d775dcbf2e05d18fc27751b8a93 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:44:58 -0600 Subject: [PATCH 22/53] docs: describe the Ruby podspec reader --- CHANGELOG.md | 55 ++++++++++++ docs/how-it-works.md | 28 +++++-- docs/troubleshooting.md | 102 +++++++++++++++-------- docs/upstream/react-native-scaffolder.md | 4 +- 4 files changed, 149 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c11ebf4..c7c754d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,61 @@ versions follow [Semantic Versioning](https://semver.org/) with `alpha` prerelea ## [Unreleased] +### Upgrading from 0.1.0-alpha.7 +- The scaffolder is now revision 8, so every scaffold patch rn-xtool persisted in your `patches/` before this release + gets a warning at each `build`: "⚠ patches/ was written by an older rn-xtool scaffolder (revision 7, now 8); + delete it so rn-xtool regenerates it (also remove node_modules/ and reinstall: that copy still has the old + Package.swift)". Delete each such patch, remove the library from `node_modules` and reinstall it, then build: + rn-xtool scaffolds it again and persists the new patch. +- Install Ruby 2.7 or newer (`sudo apt install ruby`) before you regenerate those patches, to read podspecs as + CocoaPods does; `rn-xtool doctor` shows the reader this machine uses. Without Ruby, `rn-spm` reads them with the + reduced reader and says so in a `⚠` line. + +### Changed +- The scaffolder reads every podspec with the system `ruby` (2.7 or later) through a shim of CocoaPods' DSL and React + Native's podspec helpers, the way CocoaPods runs it on a Mac: `install_modules_dependencies`, `defined?` and + `respond_to?` answer as under React Native's Podfile, and a library's own Ruby and `node` scripts run. So + react-native-gesture-handler 3.3.0 gets `RNGH_USE_WORKLETS=1` beside react-native-worklets 0.8 or later, and + react-native-webview 14.0.1 takes its `install_modules_dependencies` branch. Without a usable Ruby, the reduced + reader of earlier releases reads them, and `rn-spm` prints one `⚠` line saying why. See + [how-it-works.md](docs/how-it-works.md#cocoapods-only-libraries). +- `pod ipc spec` is no longer run, so a machine with CocoaPods reads a podspec exactly as any machine with Ruby, instead + of with React Native's helpers stripped (react-native-webview, `@react-native-async-storage/async-storage`, + react-native-keychain and react-native-video took their old-architecture branch there). +- A podspec's `ios` attributes (`s.ios.exclude_files`, `ss.ios.dependency`, …) are merged over the spec and each + subspec the scaffold uses, as CocoaPods merges them for an iOS target; `osx`, `tvos`, `visionos` and `watchos` ones + are never read. +- A podspec Ruby cannot read stops `rn-spm` with the podspec (and its line, when Ruby keeps one) and the reason, also + when autolinking reads it for header search paths, instead of leaving that library without them; a gap of the + reader ends with "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it + with rn-xtool doctor --report." See [troubleshooting.md](docs/troubleshooting.md#podspec-reader). For React Native + 0.85–0.87 and Expo SDK 57 this is edit E6 of the vendored scripts (`spm/generate-spm-autolinking.js`). +- A podspec that calls React Native's `spm_dependency` is refused by name, ": uses spm_dependency(url: , + products: ), which rn-xtool does not map yet", instead of scaffolding a target that would not link. +- A podspec that sets `script_phases`, `prepare_command`, `info_plist` or `module_map` gets a line at `rn-spm`, + "! : The podspec sets , which a CocoaPods build applies and rn-xtool's scaffold does not.", instead + of leaving it out silently. + +### Added +- `rn-xtool doctor` (also with `--project`) and `rn-xtool setup` report Ruby: `✔ ruby — 3.3.8`, or `⚠ ruby — not + found — podspecs are read with the reduced reader; sudo apt install ruby`. `setup` names the install command when + Ruby is missing and never installs it. +- `RN_XTOOL_PODSPEC_READER=reduced` reads every podspec with the reduced reader for one run, the escape when Ruby + cannot read one; `rn-spm` says so in a `⚠` line. Another value is named in a warning and ignored. +- Each scaffolded `Package.swift` names its podspec reader on its marker (`// rn-xtool-podspec-reader: ruby` or + `reduced`), and the `patches` step warns about a persisted scaffold patch the other reader wrote: delete one the + reduced reader wrote where Ruby is available, keep one Ruby wrote on a machine that reads with the reduced reader. +- `rn-xtool doctor --report` has `ruby:`, `podspec reader:` (the reader of the last `rn-spm` and how many podspecs it + read) and `podspec ENV:` (the environment variables each podspec read) lines, from + `ios/build/rn-xtool-podspec-reads.jsonl`, which `rn-spm` writes. +- CI runs the podspec reader sweep, which reads the podspecs of a pinned set of libraries with both readers and + compares them with recorded goldens, the shim's tests on Ruby 2.7, and a check that no Markdown file holds a bare + `@` mention, which would notify a GitHub user. + +### Fixed +- The recipe in [RELEASING.md](docs/RELEASING.md) that regenerates the 0.88 patches gives a new file's header the `a/` + side patch-package reads, instead of a patch that patch-package refuses whole. + ## [0.1.0-alpha.7] - 2026-11-06 ### Upgrading from 0.1.0-alpha.6 diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 73cd952..7ce01b4 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -106,10 +106,10 @@ Xcode project, ExpoModulesJSI only with Expo modules): see [bare-react-native.md ## Vendored SwiftPM scripts React Native 0.85 and 0.86 ship no SwiftPM scripts, and 0.87's lack exports and an option rn-xtool's driver calls. -Rather than patching those installs, rn-xtool bundles the 0.88.0 scripts in `vendor/rn-spm/` (the 25 scaffolder fixes +Rather than patching those installs, rn-xtool bundles the 0.88.0 scripts in `vendor/rn-spm/` (the 29 scaffolder fixes already applied; provenance and how it is checked in [vendor/rn-spm/README.md](../vendor/rn-spm/README.md)) and the driver is given `--scripts-root` pointing at them. Expo SDK 57 (React Native 0.86.3) uses them too. The installed React -Native keeps its own codegen. Five edits to the vendored copy: +Native keeps its own codegen. Six edits to the vendored copy: - **E1**: the codegen template (`Package.swift.spm-template`, missing from 0.85 and 0.86) is read from the vendored copy. @@ -120,6 +120,9 @@ Native keeps its own codegen. Five edits to the vendored copy: - **E5**: `spm/autolinking-plugins.js` takes the autolinking plugin of the dependency named `expo` from the `RN_SPM_EXPO_PLUGIN` environment variable (set by the driver's `--expo-plugin`) when `expo` declares none, which is the case on Expo SDK 57. +- **E6**: `spm/generate-spm-autolinking.js` rethrows a podspec reader failure from its header search path read instead + of returning no paths, so autolinking stops with the reader's message (React Native 0.88.1 has no such read, so the + 0.88 patches cannot carry it). React Native 0.88.x keeps using its installed scripts and the bundled patch for its version, else the highest one of its release line (`patches/react-native+0.88.0.patch` or `patches/react-native+0.88.1.patch`, the same content: a fix @@ -352,8 +355,21 @@ patch above is what makes that scaffolder work for real-world podspecs. `Scaffolding failed: `, followed by that library's own warnings, one block per failed library. Nothing is persisted for a failed library, and React Native does not run a second time ([troubleshooting.md](troubleshooting.md#scaffolded-libraries)). -- The scaffolder reads a podspec with `pod ipc spec` when CocoaPods is installed, and otherwise with its own reader, - which runs the podspec's statements over the subset of Ruby podspecs use for their fields: locals (`name = …`, `+=`, +- The scaffolder reads each podspec with the system `ruby` (2.7 or later) through a shim of CocoaPods' DSL and React + Native's podspec helpers, in the podspec's folder, the way CocoaPods runs it on a Mac: the podspec's own Ruby, and + the scripts and `node` calls it makes, run on your machine, with the same trust as installing the library. rn-xtool + never runs `pod ipc spec` or any other CocoaPods command, so a machine with CocoaPods reads a podspec exactly as any + machine with Ruby. The podspec runs with your `PATH`, `HOME` and `LANG`, and with `RCT_NEW_ARCH_ENABLED` and + `RCT_HERMES_V1_ENABLED` set to `1`; every other variable and every Podfile global is unset. Its `ios` attributes are + merged as CocoaPods merges them for an iOS target. A podspec Ruby cannot read stops the build with the podspec and + the reason ([troubleshooting.md](troubleshooting.md#podspec-reader)). Each read is recorded in + `ios/build/rn-xtool-podspec-reads.jsonl` (the reader, the Ruby, the `ENV` names the podspec read), which + `doctor --report` sums up, and each scaffolded manifest names its reader on a marker line, + `// rn-xtool-podspec-reader: ruby` or `// rn-xtool-podspec-reader: reduced` + ([fix 29](upstream/react-native-scaffolder.md#29-scriptsspmread-podspecjs-podspecs-are-read-without-react-natives-helpers-or-in-part)). +- Without a usable Ruby, or with `RN_XTOOL_PODSPEC_READER=reduced`, the reduced reader reads the podspecs instead, and + `rn-spm` says so in one `⚠` line after its runs. It runs the podspec's statements over the subset of Ruby podspecs + use for their fields: locals (`name = …`, `+=`, `||=`; the last assignment that runs wins), single- and double-quoted strings with `#{…}` interpolation, arrays and `%w[…]`, `ENV['…']` and `ENV.fetch` (`RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED` are `1`, as React Native's CocoaPods setup sets them, and every other variable is unset, whatever the shell says), `==`, `!=`, `!`, `&&`, @@ -400,7 +416,9 @@ patch above is what makes that scaffolder work for real-world podspecs. headers (`// rn-xtool-swift-importer-paths: [...]`), and rn-xtool passes them as `-Xcc -I...` to the App target and to the Expo packages that depend on the library. - A persisted patch written by an older scaffolder revision (or for another React Native version) gets a warning at the - `patches` step naming the file to delete and the library to reinstall; rn-xtool then regenerates it. + `patches` step naming the file to delete and the library to reinstall; rn-xtool then regenerates it. So does a patch + the reduced reader wrote, on a machine where Ruby reads podspecs + ([troubleshooting.md](troubleshooting.md#podspec-reader)). - Before anything is scaffolded, `doctor --project` and `build` check every dependency's podspec. A CocoaPods-only library whose podspec declares prebuilt binaries (`vendored_frameworks`, `vendored_libraries`) cannot be scaffolded yet: the generated `Package.swift` cannot link them. Neither can one that depends on a git-source pod the pod table diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 6e813ac..395ae18 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -830,7 +830,7 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin `npm install`, and the next build applies the patch again. A nested package's patch (`+++.patch`) is named ` => `. A package installed at another version than its patch's is not skipped: patch-package applies the patch with its own version warning. -- **"⚠ patches/ was written by an older rn-xtool scaffolder (revision , now 7); delete it so rn-xtool +- **"⚠ patches/ was written by an older rn-xtool scaffolder (revision , now 8); delete it so rn-xtool regenerates it (also remove node_modules/ and reinstall: that copy still has the old Package.swift)":** the `patches` step found a persisted scaffold patch from an older scaffolder. Revision 1 patches lack the Swift importer paths of mixed libraries, revision 2 patches lack those of clang-only libraries and their module map, revision 3 @@ -839,17 +839,19 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin sources of a podspec that builds its globs from Ruby locals and conditions (fix 28: react-native-screens 4.24.0 got no `ios/` sources), and revision 6 patches may lack defines a podspec builds from its package.json (react-native-worklets 0.8.3's `WORKLETS_VERSION`, whose `WorkletsVersion.cpp` then stops with `use of undeclared identifier - 'WORKLETS_VERSION_STRING'`). Without those fixes, Swift code that - imports a scaffolded library (the app, or expo-router importing react-native-screens) can fail with - `'RNSReactBaseView.h' file not found` (a mixed library, such as react-native-screens 4.26) or `'RNSDefines.h' file - not found` (a clang-only one, such as react-native-screens 4.30), and an Objective-C++ file that imports - `` stops with `use of '@import' when modules are disabled`, and an app with react-native-screens - 4.24.0 stops at `build` with [the codegen classes + 'WORKLETS_VERSION_STRING'`), and revision 7 patches were read without React Native's podspec helpers (fix 29: + react-native-gesture-handler 3.3.0 lacks `RNGH_USE_WORKLETS=1` beside react-native-worklets 0.8 or later, and + react-native-webview 14.0.1 has the `-Wno-comma -Wno-shorten-64-to-32` of its old-architecture branch). Without + those fixes, Swift code that imports a scaffolded library (the app, or expo-router importing react-native-screens) + can fail with `'RNSReactBaseView.h' file not found` (a mixed library, such as react-native-screens 4.26) or + `'RNSDefines.h' file not found` (a clang-only one, such as react-native-screens 4.30), and an Objective-C++ file that + imports `` stops with `use of '@import' when modules are disabled`, and an app with + react-native-screens 4.24.0 stops at `build` with [the codegen classes check](#rctthirdpartycomponentsprovider-thirdpartyfabriccomponents). Do what the warning says: delete the patch, remove the library from `node_modules` and reinstall it, then build; rn-xtool scaffolds it again and persists - the new patch. This release's scaffolder is revision 7, so each scaffold patch persisted before it gets the line at + the new patch. This release's scaffolder is revision 8, so each scaffold patch persisted before it gets the line at every build until it is regenerated, for example `⚠ patches/react-native-screens+4.30.0.patch was written by an - older rn-xtool scaffolder (revision 4, now 7); delete it so rn-xtool regenerates it (also remove + older rn-xtool scaffolder (revision 4, now 8); delete it so rn-xtool regenerates it (also remove node_modules/react-native-screens and reinstall: that copy still has the old Package.swift)`. Until then the build goes on with the older manifest. - **"⚠ patches/ was scaffolded for React Native ; delete it so rn-xtool regenerates it for @@ -858,21 +860,21 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin Do the same as for the revision warning above. Both warnings also read patches with the marker's name before the rename, `expo-xtool-scaffold-revision` (apps scaffolded before 0.1.0-alpha.1). - **"ℹ node_modules//Package.swift was scaffolded with revision for React Native , older than - patches/ (revision 7, React Native ): rn-xtool replaced it with the persisted one":** a teammate + patches/ (revision 8, React Native ): rn-xtool replaced it with the persisted one":** a teammate committed a regenerated scaffold patch, and your `node_modules` still had the copy an older patch wrote (patch-package does not replace a file that exists). rn-xtool owns these generated files, so the `patches` step removes the files the current patch creates and patch-package writes them again; the line is printed once patch-package has done so. Nothing to do; files the older scaffold wrote and the current one does not stay in place. This happens only when the patch holds nothing but scaffolded new files. - **"⚠ node_modules//Package.swift was scaffolded with revision for React Native , older than - patches/ (revision 7, React Native ), and that patch also changes the library's own files, so + patches/ (revision 8, React Native ), and that patch also changes the library's own files, so rn-xtool does not replace it: run rm -rf node_modules/ && npm install, then build again":** the same case, but the persisted patch also holds your own fix to the library. rn-xtool persists a scaffold with `patch-package `, which writes everything that differs from the published package into one patch. Removing only the scaffold files would leave a patch that patch-package can apply neither forward nor backward, so rn-xtool changes nothing and the build goes on with the older manifest. Run the command: the reinstall gives the published package, and the next build applies the whole patch. -- **"ℹ node_modules//Package.swift was scaffolded by an older rn-xtool scaffolder (revision , now 7)" (or +- **"ℹ node_modules//Package.swift was scaffolded by an older rn-xtool scaffolder (revision , now 8)" (or "was scaffolded for React Native , not "), followed by "rn-xtool removed it so the rn-spm step scaffolds it again":** a library has no persisted patch, and the manifest rn-xtool generated for it is out of date, for example after you deleted a stale patch but kept the package installed. The `rn-spm` step scaffolds it again @@ -923,7 +925,7 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin `#import` per public header of the pod, which compiles in `.m` and `.mm` files alike, and their scaffolder revision (5 and later) replaces an older scaffold: a copy in `node_modules` without a persisted patch is scaffolded again by itself, and a persisted patch gets the `⚠ patches/ was written by an older rn-xtool scaffolder (revision 4, - now 7)` line + now 8)` line above, whose steps regenerate it. A `forwardHeaders` entry of your config that still lists modules is refused with `… lists the module ; list the pod's public headers instead`: list the headers, as in [Libraries that depend on CocoaPods pods](#libraries-that-depend-on-cocoapods-pods). @@ -982,11 +984,21 @@ with the reduced reader; sudo apt install ruby`). - **"⚠ Ruby was not found, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does.":** `rn-spm` prints this once, after its runs, when the reduced reader read a podspec. The first words say why: `Ruby was not found`, `ruby 2.6.10 is older than - 2.7.0`, `ruby cannot load json`, or `ruby could not run the podspec reader ()`. The build goes on with the - reduced reader. Install Ruby 2.7 or newer (`sudo apt install ruby`), check it with `rn-xtool doctor`, and build again. - A scaffold the reduced reader persisted in `patches/` stays until you delete it: the `patches` step names each one - (`⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool - regenerates it …`), and the next build after you delete it scaffolds that library with Ruby. + 2.7.0`, `ruby cannot load json`, `ruby could not run the podspec reader ()`, or `the podspec reader's Ruby + shim is missing from `. The build goes on with the reduced reader. Install Ruby 2.7 or newer (`sudo apt + install ruby`), check it with `rn-xtool doctor`, and build again. When the shim is missing, reinstall the package + whose folder `` names (rn-xtool, or an installed React Native 0.88), then build again. +- **"⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool + regenerates it (also remove node_modules/ and reinstall: that copy still has the old Package.swift)":** the + `patches` step found a scaffold the reduced reader persisted, for example by a teammate without Ruby, on a machine + where Ruby reads podspecs. It stays until you delete it, and the build goes on with it. Do what the line says, as + for the revision warning in [Build and patches](#build-and-patches): the next build scaffolds that library with + Ruby and persists the new patch. +- **"⚠ patches/ was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one + (): keep the patch, and install Ruby (sudo apt install ruby) before you regenerate it":** the opposite case. + The patch is the better reading, so keep it; a scaffold regenerated here would be the reduced reader's. With + `RN_XTOOL_PODSPEC_READER=reduced` set, the line ends `keep the patch, and unset RN_XTOOL_PODSPEC_READER before you + regenerate it`. - **"⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; unset it to read them as CocoaPods does.":** the variable is set in the environment of the build, so the reduced reader read every podspec, Ruby or not. Unset it (`unset RN_XTOOL_PODSPEC_READER`) once the podspec @@ -994,11 +1006,31 @@ with the reduced reader; sudo apt install ruby`). - **"⚠ RN_XTOOL_PODSPEC_READER= is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby":** the variable is set to another value (`REDUCED`, `1`, `ruby`), which picks nothing. Set it to `reduced` exactly, or unset it. -- **The environment a podspec sees:** rn-xtool reads every podspec with only `RCT_NEW_ARCH_ENABLED` and - `RCT_HERMES_V1_ENABLED` set, both to `1`; every other variable a podspec reads (`USE_FRAMEWORKS`, `USE_HERMES`, a - library's own) is unset, whatever your shell has. The podspec runs in its own folder, with `ios/` as CocoaPods' - installation root and nothing on its standard input. The names each podspec read are in `rn-xtool doctor --report`, - under `podspec ENV:`, one `: NAME, NAME` line per podspec; the build does not print them. +- **The environment a podspec sees:** rn-xtool reads every podspec with `RCT_NEW_ARCH_ENABLED` and + `RCT_HERMES_V1_ENABLED` set, both to `1`, and your `PATH`, `HOME` and `LANG`, so that the `node` it calls is found; + every other variable a podspec reads (`USE_FRAMEWORKS`, `USE_HERMES`, a library's own) is unset, whatever your shell + has. The podspec runs in its own folder, with `ios/` as CocoaPods' installation root and nothing on its standard + input. The names each podspec read are in `rn-xtool doctor --report`, under `podspec ENV:`, one `: NAME, + NAME` line per podspec; the build does not print them. +- **Podfile globals:** a podspec reads as with a Podfile that sets no globals (`$VCEnableLocation`, + `$VCEnableFrameProcessors`, `$RNVideoUseVideoCaching` are undefined), so it takes its default branch: + react-native-vision-camera compiles its location APIs in, and its frame processors only when + react-native-worklets-core is installed. +- **A podspec that reads your project:** some podspecs compute their settings from the project when they run: + react-native-reanimated reads its static feature flags from the app's `package.json`, and + react-native-vision-camera checks whether react-native-worklets-core is installed. A persisted scaffold keeps what + its podspec read the day it was written, and a later build does not read it again. After you change a library's + feature flags or install an optional sibling, delete the library's patch and re-scaffold it as in [Scaffolded + libraries](#scaffolded-libraries). +- **"! : The podspec sets script_phases, which a CocoaPods build applies and rn-xtool's scaffold does + not."** (also `prepare_command`, `info_plist` and `module_map`): the spec, a subspec the scaffold uses, or their + `ios` attributes set a key that changes a CocoaPods build and that the scaffolded `Package.swift` does not carry. + The build goes on without it. If the library needs what that key does (a build script, a generated file, its own + module map), add it to the library's `Package.swift` and persist it in `patches/`. +- **"✖ Scaffolding failed: : uses spm_dependency(url: , products: ), which rn-xtool + does not map yet":** with Ruby, the podspec asks React Native's `spm_dependency` helper for a SwiftPM package, and + the scaffold does not add that package, so the target would not link. Give the library a `Package.swift` of its + own, persisted in `patches/`, and [report it](#reporting-a-problem). - **":: the podspec calls (…), which rn-xtool's podspec reader does not model. Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report.":** the podspec calls a method of CocoaPods or React Native the shim does not provide, and `rn-spm` stops @@ -1010,8 +1042,9 @@ with the reduced reader; sudo apt install ruby`). - `: the podspec does not evaluate to a Pod::Spec`; - ` did not finish in 30 s.` - When the failing line is in another of the library's files, `:` reads ` (:)`. A - podspec that raises an error of its own (`raise`, `abort`) stops with its message after `:: `. + When the failing line is in another of the library's files, `:` reads ` (:)`; + when Ruby keeps no line, it is `` alone. A podspec that raises an error of its own (`raise`, `abort`) stops + with its message after `:: ` (or `: `), without the last sentence. To build for one run, set the escape on the command: `RN_XTOOL_PODSPEC_READER=reduced rn-xtool build`. `rn-spm` then prints the `⚠ RN_XTOOL_PODSPEC_READER=reduced is set` line, and `doctor --report` records the reduced reader. - **To report a podspec the reader cannot read:** run `rn-xtool doctor --report` in the project folder after the @@ -1111,17 +1144,19 @@ module is unavailable.` and conditions, which the podspec reader did not evaluate before scaffolder revision 6, so the scaffolded `RNScreens` target held only the C++ of its `common` subspec ([fix 28](upstream/react-native-scaffolder.md)). The revision warning above names its persisted patch; re-scaffold it as in [Scaffolded libraries](#scaffolded-libraries). -- **A podspec the reader cannot evaluate** stops the scaffold instead of building such a target: ``✖ Scaffolding - failed: : `s.source_files = ` cannot be evaluated: it uses . …``. The reader +- **A podspec the reduced reader cannot evaluate** stops the scaffold instead of building such a target: ``✖ + Scaffolding failed: : `s.source_files = ` cannot be evaluated: it uses . …``. + The reduced reader, used without Ruby or with `RN_XTOOL_PODSPEC_READER=reduced` ([Podspec reader](#podspec-reader)), evaluates locals, string interpolation, arrays, `ENV['…']`, comparisons, ternaries and `if`/`unless` blocks ([how it works](how-it-works.md#cocoapods-only-libraries)); a method call or a value it does not know in a source - glob, `compiler_flags`, `header_dir`, `header_mappings_dir`, `frameworks` or `libraries` is refused. Installing - CocoaPods (`gem install cocoapods`) lets `pod ipc spec` read the podspec instead, or give the library a - `Package.swift` of its own. + glob, `compiler_flags`, `header_dir`, `header_mappings_dir`, `frameworks` or `libraries` is refused. Install Ruby + (`sudo apt install ruby`) so the podspec is read with Ruby instead, or give the library a `Package.swift` of its + own. - **"! : Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value."** (also `GCC_PREPROCESSOR_DEFINITIONS`, `HEADER_SEARCH_PATHS`, - `SWIFT_ACTIVE_COMPILATION_CONDITIONS`): the scaffold left that part of the value out, and the library compiles as if - it were empty. CocoaPods computes it from the app or the Podfile, so these libraries differ from a CocoaPods build: + `SWIFT_ACTIVE_COMPILATION_CONDITIONS`): the reduced reader read the podspec, and the scaffold left that part of the + value out, so the library compiles as if it were empty. CocoaPods computes it from the app or the Podfile, so with + the reduced reader these libraries differ from a CocoaPods build: - react-native-worklets and react-native-reanimated: every static feature flag reads as off, also the ones their `src/featureFlags/staticFlags.json` turns on, such as worklets 0.8's `IOS_DYNAMIC_FRAMERATE_ENABLED` (the worklets display link asks for 120 fps throughout, instead of lowering its frame rate on a ProMotion iPhone when @@ -1132,7 +1167,8 @@ module is unavailable.` (`VISION_CAMERA_ENABLE_FRAME_PROCESSORS` and `VISION_CAMERA_ENABLE_LOCATION` are not set). CocoaPods turns location tagging on by default, and frame processors when react-native-worklets-core is installed. - To set such a value, edit the library's `Package.swift` and persist it in `patches/`. + With Ruby the podspec computes these values itself, as under CocoaPods, and the line does not appear. With the + reduced reader, to set such a value, edit the library's `Package.swift` and persist it in `patches/`. - **A hand-edited `Package.swift`** that leaves out the files defining a class: put them back. - **"ℹ The packed app's binaries list no Objective-C class symbols, so rn-xtool could not check the classes React Native's codegen providers name.":** the binaries have no symbol table, so nothing is checked and the build goes on. diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 347a1f2..cb4a8b8 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -925,8 +925,8 @@ usable Ruby (none, older than 2.7, no `json`, the shim missing), or with `RN_XTO evaluator reads the podspec as before, and `podspecReader()` says why; another value of the variable is named in a warning and ignored. `name`, `module_name` and `version` stay the literal readings under both readers. `readPodspecCached` keys on the reader too. When `RN_SPM_PODSPEC_READS` names a file, each read appends one JSON line -to it: the podspec, the reader and why, whether it was forced, the Ruby, the `ENV` names and helpers the podspec used, -and whether it read, with the error. +to it: the podspec, the reader and why, whether it was forced, the Ruby, the reader choice's warning (an unknown +`RN_XTOOL_PODSPEC_READER` value), the `ENV` names and helpers the podspec used, and whether it read, with the error. `pod ipc spec` is never run (`patchPodspecForPodIpc`, `runPodIpcSpec` and `cleanupPatchedPodspec` are gone), so a machine with CocoaPods reads a podspec as any machine with Ruby. `flattenSubspecs` merges each selected layer's `ios` From 86e75398d610fa24d459000b11d073ff48ceb308 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 16:55:09 -0600 Subject: [PATCH 23/53] docs: true up library and README notes --- README.md | 3 +++ docs/how-it-works.md | 16 ++++++++-------- docs/libraries.md | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6779ac5..3b5ff0d 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,9 @@ does not work yet (a library's own vendored binaries, Xcode-only tools). - FUSE 2 for the xtool AppImage (`sudo apt install libfuse2t64` on Ubuntu 24.04 and newer, `sudo apt install libfuse2` on older releases), `python3`, `iproute2`. `setup` installs Swift and prints the exact `apt-get` line for any missing Swift system packages ([list](docs/how-it-works.md#what-setup-installs)). +- Ruby 2.7+ (`sudo apt install ruby`), which reads podspecs as CocoaPods does. Without it, rn-xtool reads them with a + reduced reader that evaluates a subset of Ruby, and `rn-spm` says so in a `⚠` line + ([details](docs/troubleshooting.md#podspec-reader)). - npm or Yarn classic. patch-package needs a flat `node_modules`; pnpm and Yarn PnP are not supported, and `build` stops on them early ([details](docs/troubleshooting.md#pnpm-and-yarn-pnp)). diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 7ce01b4..abe60d1 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -55,14 +55,14 @@ scaffolded libraries, CocoaPods binaries); [recipe.md](recipe.md) has every step resources only Xcode's tools compile (asset catalogs, storyboards); refuses modules built from vendored C sources such as expo-sqlite ([upstream/expo-spm-plugin-mixed-modules.md](upstream/expo-spm-plugin-mixed-modules.md)). - **React Native** (`patches/react-native+0.88.1.patch`, and its identical copy `react-native+0.88.0.patch` for bare - 0.88.0; about 3.0k lines across 3 files under - `react-native/scripts/spm/`: `read-podspec.js`, `scaffold-package-swift.js`, `spm-utils.js`): 25 generic fixes to - the `spm scaffold` podspec reader and `Package.swift` generator, including mixed Swift + Objective-C/C++ targets, - CocoaPods dependencies mapped to SwiftPM packages through a pod table file (or to the local package of CocoaPods - binaries), the Swift importer paths of mixed - targets, dependencies on - packages that are not installed left out, the Swift 5 language mode and Swift compilation conditions, plus two to - the per-app header farm ([upstream/react-native-scaffolder.md](upstream/react-native-scaffolder.md)). + 0.88.0; about 5.7k lines across 6 files under `react-native/scripts/spm/`: `read-podspec.js` and its Ruby shim + `read-podspec-shim.rb`, `scaffold-package-swift.js`, `spm-utils.js`, `expand-spm-dependencies.js`, + `spm-types.js`): 29 generic fixes to the `spm scaffold` podspec reader, the `Package.swift` generator and (two) + the per-app header farm, including reading podspecs in Ruby, mixed Swift + Objective-C/C++ targets, CocoaPods + dependencies mapped to SwiftPM packages through a pod table file (or to the local package of CocoaPods binaries), + the Swift importer paths of mixed targets, dependencies on packages that are not installed left out, the Swift 5 + language mode and Swift compilation conditions + ([upstream/react-native-scaffolder.md](upstream/react-native-scaffolder.md)). Then, in the same step, rn-xtool makes the libraries' own `Package.swift` files portable to Linux, because SwiftPM compiles them on the host. In each top-level and scoped package of the project's `node_modules`, it rewrites a known diff --git a/docs/libraries.md b/docs/libraries.md index 4d9b3f2..e463257 100644 --- a/docs/libraries.md +++ b/docs/libraries.md @@ -62,7 +62,7 @@ Legend: ✅ works · ⚠️ works with caveats · ❌ fails · ⏳ not tested ye | @react-native-async-storage/async-storage | 3.x | mixed ObjC→Swift (`AsyncStorage.mm` imports `AsyncStorage-Swift.h`) + vendored static xcframework | ❌ not scaffoldable | — | ⏳ | ⏳ | ⏳ | ⏳ | 1.24: linked on a device 2026-11-06 (production app; features ⏳) | The mixed part is now handled by scaffolder fix 10 (one mixed-language target, as for pager-view); the vendored `SharedAsyncStorage.xcframework` still needs a `binaryTarget`, which the scaffolder does not emit yet, so `rn-xtool doctor --project` and `build` refuse it early ([details](troubleshooting.md#libraries-with-prebuilt-binaries)). expo-sqlite is not yet buildable here — vendored C sources; `doctor --project` and `build` refuse it early as well ([details](troubleshooting.md#libraries-that-build-vendored-c-sources)), so `expo-sqlite/kv-store` is not an option yet. Interim: async-storage 2.x, whose iOS side is pure Objective-C (no Swift, no xcframework), should scaffold like the other ObjC libraries (not tested here). Analysis: [docs/upstream/async-storage-analysis.md](upstream/async-storage-analysis.md) | | @react-native-community/datetimepicker | 9.2.1 | CocoaPods-only → auto-scaffold | ✅ 2026-10-23 | ✅ 2026-10-23 | ⏳ | ✅ 2026-10-26 | ⏳ | ⏳ | ⏳ | | | react-native-pager-view | 9.0.7 | CocoaPods-only, mixed Swift + ObjC++ (`RNCPagerViewComponentView.mm` imports `react_native_pager_view-Swift.h`) → auto-scaffold as one mixed-language target | ✅ 2026-10-23 | ✅ 2026-10-23 | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | needed scaffolder fixes 10 (mixed-language target: `swift-tools-version: 6.4;(experimentalMultiLang)`, Swift umbrella, `RN_SPM_SWIFT_HEADERS_DIR`, `-std=c++20`) and 11 (bare `#import "RCTFabricComponentsPlugins.h"`). Its podspec depends on the CocoaPods pod `SwiftUIIntrospect ~> 1.0`: scaffolder fix 13 maps it through the pod table to `.package(url: "https://github.com/siteline/swiftui-introspect", exact: "1.5.0")` + `.product(name: "SwiftUIIntrospect", package: "swiftui-introspect")`, and the manifest records the pin (`// rn-xtool-pods: SwiftUIIntrospect=1.5.0`), so no hand edit is needed (SwiftPM fetches it from GitHub on the first build of a clean `.build`). The scaffold is persisted in the app's `patches/react-native-pager-view+9.0.7.patch` | -| react-native-vision-camera | 4.7.3 | CocoaPods-only, mixed Swift + ObjC++ → auto-scaffold as one mixed-language target | ⏳ | ⏳ | ⏳ | ✅ 2026-11-05 (React Native 0.88.1, on a device) | ⏳ | ⏳ | 4.7: linked on a device 2026-11-06 (production app; features ⏳) | needed scaffolder fixes 20 and 21 (Swift 5 language mode). Without react-native-worklets-core, frame processors are left out: the `FrameProcessors` subspec goes with its sources, headers and settings, as CocoaPods leaves it out, and the scaffold prints `Dependency "react-native-worklets-core" is not installed (or not linked for iOS); left out with the subspec "FrameProcessors" that declares it (its sources, headers, settings and dependencies), as CocoaPods leaves it out.` Location tagging stays compiled out: the podspec switches `VISION_CAMERA_ENABLE_LOCATION` with a Ruby ternary, which the scaffolder does not evaluate (fix 24). `CameraView` is in the binary. On a device the camera permission prompt appears, then the back-camera preview shows | +| react-native-vision-camera | 4.7.3 | CocoaPods-only, mixed Swift + ObjC++ → auto-scaffold as one mixed-language target | ⏳ | ⏳ | ⏳ | ✅ 2026-11-05 (React Native 0.88.1, on a device) | ⏳ | ⏳ | 4.7: linked on a device 2026-11-06 (production app; features ⏳) | needed scaffolder fixes 20 and 21 (Swift 5 language mode). Without react-native-worklets-core, frame processors are left out: the `FrameProcessors` subspec goes with its sources, headers and settings, as CocoaPods leaves it out, and the scaffold prints `Dependency "react-native-worklets-core" is not installed (or not linked for iOS); left out with the subspec "FrameProcessors" that declares it (its sources, headers, settings and dependencies), as CocoaPods leaves it out.` With Ruby the podspec reads as with a Podfile that sets no globals, so its location APIs are compiled in (`VISION_CAMERA_ENABLE_LOCATION`), as under CocoaPods; with the reduced reader they stay compiled out, since that reader does not evaluate the podspec's Ruby ternary (fix 24). `CameraView` is in the binary. On a device (checked before the Ruby reader, location compiled out) the camera permission prompt appears, then the back-camera preview shows | | react-native-video | 6.19.3 | CocoaPods-only, mixed Swift + ObjC++ → auto-scaffold as one mixed-language target | ⏳ | ⏳ | ⏳ | ✅ 2026-11-05 (React Native 0.88.1, on a device) | ⏳ | ⏳ | linked on a device 2026-11-06 (production app; features ⏳) | needed scaffolder fix 21 (Swift 5 language mode; in Swift 6 it failed with strict-concurrency errors). Google IMA ads and video caching, which the podspec adds only when the Podfile sets `$RNVideoUseGoogleIMA` or `$RNVideoUseVideoCaching`, are not wired: their three pods (GoogleAds-IMA-iOS-SDK, SPTPersistentCache, DVAssetLoaderDelegate) have no SwiftPM package, the scaffold prints one "is a CocoaPods pod with no known SwiftPM equivalent" warning for each, and the code behind them is not built. `RCTVideo` is in the binary. On a device a remote MP4 plays with the native controls | | react-native-device-info | 15.0.2 | CocoaPods-only, ObjC → auto-scaffold with the `include/RNDeviceInfo/` shim | build ✅ 2026-11-04 (expo 58.0.23, react-native 0.88.1; device ⏳) | ⏳ | ⏳ | ✅ 2026-11-05 (React Native 0.88.1, on a device) | ⏳ | ⏳ | linked on a device 2026-11-06 (production app; features ⏳) | needed scaffolder fix 22 (its `ios/RNDeviceInfo/RNDeviceInfo.h` umbrella directory sits next to `RNDeviceInfo.xcodeproj/`). Its privacy-manifest resource bundle is built and copied to the app as `RNDeviceInfoPrivacyInfo.bundle` (checked by building, 2026-11-05). On SDK 58 it scaffolds through rn-xtool's driver with Expo's autolinking command, and no other library is re-scaffolded. `RNDeviceInfo` is in the binary. On a device (bare) the model and the iOS version are shown. The real device name needs the restricted `com.apple.developer.device-information.user-assigned-device-name` entitlement, which a free team does not get: without it the name is the generic model name, and with the key in the app's entitlements `build` prints a `⚠` line for it | | @react-native-community/netinfo | 11.5.2 | CocoaPods-only, ObjC++ → auto-scaffold | ⏳ | ⏳ | ⏳ | ✅ 2026-11-05 (React Native 0.88.1, on a device) | ⏳ | ⏳ | linked on a device 2026-11-06 (production app; features ⏳) | needed scaffolder fix 23: `RNCNetInfo.mm` imports its codegen header as `"RNCNetInfoSpec.h"`, which resolves through a forwarder in the per-app header farm. `RNCNetInfo` is in the binary. On a device it reports the type `wifi` and connected `true`. The Wi-Fi network name (SSID) needs the `com.apple.developer.networking.wifi-info` entitlement, which a free team does not get: without it the SSID is empty, and with the key in the app's entitlements `build` prints a `⚠` line for it | From ff9d986d0e21e215f5ec6ed1847c79df5274a75e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Fri, 6 Nov 2026 17:03:44 -0600 Subject: [PATCH 24/53] test: sweep the podspec readers over libraries --- src/pipeline/scaffoldResources.ts | 2 +- .../RNGestureHandler.podspec.json | 77 +++++ .../RNScreens.podspec.json | 93 +++++++ .../RNSVG.podspec.json | 94 +++++++ tests/podspec-sweep.json | 5 + tests/podspecReaderSweep.test.ts | 30 ++ tests/support/podspecSweep.ts | 262 ++++++++++++++++++ 7 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json create mode 100644 tests/podspec-sweep.json create mode 100644 tests/podspecReaderSweep.test.ts create mode 100644 tests/support/podspecSweep.ts diff --git a/src/pipeline/scaffoldResources.ts b/src/pipeline/scaffoldResources.ts index ae243a9..b795f07 100644 --- a/src/pipeline/scaffoldResources.ts +++ b/src/pipeline/scaffoldResources.ts @@ -97,7 +97,7 @@ interface PodspecResources { * are literal strings is a bundle rn-xtool builds (a key given twice, for every platform and for iOS, merges its * globs); any other bundle is named by its key, and a plain resource by its basename. */ -function podspecResources(text: string): PodspecResources { +export function podspecResources(text: string): PodspecResources { const lines = podspecLines(text); const podName = /\.name\s*=\s*(["'])([^"'#]+)\1/.exec(text)?.[2]; const items: string[] = []; diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json new file mode 100644 index 0000000..93cd4b6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json @@ -0,0 +1,77 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "RNWorklets" + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json new file mode 100644 index 0000000..8af6867 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json @@ -0,0 +1,93 @@ +{ + "env": [ + "RNS_DEBUG_LOGGING", + "RNS_GAMMA_ENABLED", + "RNS_USE_CXXBRIDGE" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-RCTImage" + ], + "excludeFiles": [ + "ios/gamma/**/*.{h,m,mm,cpp}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnscreens", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNScreens", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}", + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json new file mode 100644 index 0000000..ab74773 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json @@ -0,0 +1,94 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=88 from the installed React Native version (0.88.1) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "**/*.macos.{h,m,mm}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnsvg", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNSVG", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "88" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/podspec-sweep.json b/tests/podspec-sweep.json new file mode 100644 index 0000000..cda2614 --- /dev/null +++ b/tests/podspec-sweep.json @@ -0,0 +1,5 @@ +[ + { "spec": "react-native-gesture-handler@3.4.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-screens@4.30.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-svg@15.16.0", "rn": "react-native@0.88.1" } +] diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts new file mode 100644 index 0000000..3a53a90 --- /dev/null +++ b/tests/podspecReaderSweep.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from "vitest"; +import { podspecReaderHere } from "../src/tools/podspecReader.js"; +import { SWEEP, golden, nameDifferences, orphanGoldens, podspecsOf, record, type SweepEntry } from "./support/podspecSweep.js"; +import { needsRuby } from "./support/ruby.js"; +import { needsTarball } from "./support/tarballs.js"; + +// The podspec reader sweep: every podspec of the libraries in tests/podspec-sweep.json, read with Ruby and with the +// reduced reader, against its reviewed golden in tests/fixtures/podspec-sweep (RN_XTOOL_SWEEP_WRITE=1 rewrites them). +// Off CI a library whose tarballs are not cached, or a machine without Ruby, skips; on CI both fail. +const CI = process.env.CI === "true"; + +/** `""` when the entry's podspecs can be read here, else a title suffix that says what they need. */ +function skipReason(entry: SweepEntry): string { + if (CI) return ""; + const tarballs = [entry.spec, entry.rn, ...(entry.with ?? [])].map((spec) => needsTarball(spec)).join(""); + return tarballs + needsRuby; +} +const skip = (entry: SweepEntry) => skipReason(entry) !== ""; + +describe("the podspec reader sweep", () => { + for (const entry of SWEEP) + for (const podspec of podspecsOf(entry)) + it.skipIf(skip(entry))(`reads ${entry.spec} ${podspec} as its golden${skipReason(entry)}`, () => { + expect(record(entry, podspec)).toEqual(golden(entry, podspec)); + }); + + it("keeps every library's names under both readers", () => expect(nameDifferences()).toEqual([])); + it("has a golden for every podspec and no other", () => expect(orphanGoldens()).toEqual([])); + it.runIf(CI)("runs with Ruby on CI", () => expect(podspecReaderHere().reader).toBe("ruby")); +}); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts new file mode 100644 index 0000000..9041220 --- /dev/null +++ b/tests/support/podspecSweep.ts @@ -0,0 +1,262 @@ +/** + * The podspec reader sweep (`tests/podspecReaderSweep.test.ts`): each library of `tests/podspec-sweep.json` installed + * in a temp project from its pinned tarball, every podspec of it read with Ruby (the shim) and with the reduced reader, + * and what was read against a reviewed golden in `tests/fixtures/podspec-sweep`. `RN_XTOOL_SWEEP_WRITE=1` writes the + * goldens instead. The temp root is written as ``, so a golden holds no machine's path. + */ +import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { isDeepStrictEqual } from "node:util"; +import { afterAll, vi } from "vitest"; +import { podspecResources } from "../../src/pipeline/scaffoldResources.js"; +import { podDependencies, podspecFiles, podspecLines, unconditionalLineIndexes } from "../../src/project/podspecs.js"; +import { packageRoot } from "../../src/tools/exec.js"; +import { VENDORED_RN_SPM } from "./rnScaffold.js"; +import { needsTarball, tarballPath } from "./tarballs.js"; +import { tool } from "./tools.js"; + +const ROOT = packageRoot(); +export const SWEEP_GOLDENS = path.join(ROOT, "tests", "fixtures", "podspec-sweep"); + +/** An entry of `tests/podspec-sweep.json`: a library, the React Native it is read against, and the packages it needs. */ +export type SweepEntry = { spec: string; rn: string; with?: string[] }; +export const SWEEP = JSON.parse(readFileSync(path.join(ROOT, "tests", "podspec-sweep.json"), "utf8")) as SweepEntry[]; + +const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); +const { readPodspec, runPodspecShim, unresolvedSourcesReason } = req("./read-podspec.js"); +const { defaultReadPodspec } = req("./expand-spm-dependencies.js"); + +const WRITE = process.env.RN_XTOOL_SWEEP_WRITE === "1"; +/** Fields that name the reader rather than what it read: they differ by definition. */ +const READER_FIELDS = new Set(["reader", "partial"]); + +const tmp: string[] = []; +afterAll(() => { + for (const d of tmp) rmSync(d, { recursive: true, force: true }); +}); + +const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); +const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); +const tarballsOf = (entry: SweepEntry) => [entry.spec, entry.rn, ...(entry.with ?? [])]; +const message = (e: unknown) => (e instanceof Error ? e.message : String(e)); + +/** `spec`'s tarball extracted into `dir` (only `members` of it when given). */ +function extract(spec: string, dir: string, members: string[] = []): void { + const file = tarballPath(spec); + if (file === undefined) throw new Error(`${spec}: not cached or not pinned in tests/tarballs.json${needsTarball(spec)}`); + mkdirSync(dir, { recursive: true }); + const r = tool("tar", ["-xzf", file, "-C", dir, "--strip-components=1", ...members.map((m) => `package/${m}`)]); + if (r.status !== 0) throw new Error(`tar failed for ${spec}: ${r.stderr}`); +} + +const projects = new Map(); +/** + * The entry's project, made once per run: a temp `` with `package.json` and `ios/`, the library and each `with` + * package in `/node_modules/`, and React Native's `package.json` and `scripts/` in + * `/node_modules/react-native`. `podspecs` are the library's podspec files that exist, relative to it. + */ +export function sweepProject(entry: SweepEntry): { root: string; podspecs: string[] } { + let project = projects.get(entry.spec); + if (project) return project; + const root = realpathSync(mkdtempSync(path.join(tmpdir(), "rn-xtool-sweep-"))); + tmp.push(root); + const modules = path.join(root, "node_modules"); + for (const spec of [entry.spec, ...(entry.with ?? [])]) extract(spec, path.join(modules, nameOf(spec))); + extract(entry.rn, path.join(modules, "react-native"), ["package.json", "scripts"]); + mkdirSync(path.join(root, "ios")); + const dependencies = Object.fromEntries(tarballsOf(entry).map((spec) => [nameOf(spec), versionOf(spec)])); + writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "sweep-app", version: "1.0.0", dependencies })); + const lib = path.join(modules, nameOf(entry.spec)); + const podspecs = podspecFiles(lib).filter((f) => existsSync(f)).map((f) => path.relative(lib, f)); + projects.set(entry.spec, (project = { root, podspecs })); + return project; +} + +/** The entry's golden folder, and a podspec's golden file in it. */ +const goldenDir = (entry: SweepEntry) => path.join(SWEEP_GOLDENS, entry.spec.replaceAll("/", "+")); +const goldenFile = (entry: SweepEntry, podspec: string) => path.join(goldenDir(entry), `${podspec.replaceAll("/", "__")}.json`); +/** The podspecs the entry's goldens are for. */ +function goldenPodspecs(entry: SweepEntry): string[] { + if (!existsSync(goldenDir(entry))) return []; + return readdirSync(goldenDir(entry)) + .filter((f) => f.endsWith(".json")) + .map((f) => f.slice(0, -".json".length).replaceAll("__", "/")) + .sort(); +} + +/** The entry's podspecs: its project's, or its goldens' when its tarballs are not here (its tests then skip or fail). */ +export function podspecsOf(entry: SweepEntry): string[] { + const here = tarballsOf(entry).every((spec) => needsTarball(spec) === ""); + return here ? sweepProject(entry).podspecs : goldenPodspecs(entry); +} + +/** `value` with its object keys sorted, at every depth; arrays keep their order. */ +function sorted(value: unknown): unknown { + if (Array.isArray(value)) return value.map(sorted); + if (value === null || typeof value !== "object") return value; + return Object.fromEntries( + Object.keys(value) + .sort() + .map((k) => [k, sorted((value as Record)[k])]), + ); +} + +/** Where two lists disagree: what only the TypeScript reader has, and what only the shim has, each sorted. */ +function disagreement(ts: string[], shim: string[]): { onlyTs: string[]; onlyShim: string[] } { + const only = (a: string[], b: string[]) => [...new Set(a.filter((x) => !b.includes(x)))].sort(); + return { onlyTs: only(ts, shim), onlyShim: only(shim, ts) }; +} + +/** ` => ` for each glob of the `resource_bundles` hashes of the shim's spec and the subspecs it selects, for iOS. */ +function shimBundles(raw: any): string[] { + const subspecs: any[] = Array.isArray(raw.subspecs) ? raw.subspecs : []; + const none = raw.default_subspecs === "none" || raw.default_subspec === "none"; + const wanted = Array.isArray(raw.default_subspecs) ? new Set(raw.default_subspecs) : undefined; + const layers = [raw, ...(none ? [] : subspecs.filter((s) => wanted === undefined || wanted.has(s?.name)))]; + return layers.flatMap((layer) => + [layer?.resource_bundles, layer?.ios?.resource_bundles].flatMap((bundles) => + bundles !== null && typeof bundles === "object" + ? Object.entries(bundles).flatMap(([key, globs]) => [globs].flat().map((glob) => `${key} => ${String(glob)}`)) + : [], + ), + ); +} + +/** The TypeScript readers' `resource_bundles`, as ` => `: those rn-xtool builds into the app. */ +function tsBundles(text: string): string[] { + return [...podspecResources(text).bundles].flatMap(([key, globs]) => globs.map((glob) => `${key} => ${glob}`)); +} + +/** The pod dependencies early checks read: on the podspec's unconditional lines. */ +function tsDependencies(text: string): string[] { + const lines = podspecLines(text); + return podDependencies(unconditionalLineIndexes(text).map((i) => lines[i]!)).map((d) => d.name); +} + +type Names = { name: string | null; moduleName: string | null; headerDir: string | null } | null; +/** The names `defaultReadPodspec` gives the library under the reader in effect, or the error it threw. */ +function names(lib: string, podspec: string): Names | { error: string } { + try { + const n = defaultReadPodspec(lib, podspec); + return n == null ? null : { name: n.name ?? null, moduleName: n.moduleName ?? null, headerDir: n.headerDir ?? null }; + } catch (e) { + return { error: message(e) }; + } +} + +/** What one read of a podspec gives: its model or error, its names. */ +function readWith(reader: "ruby" | "reduced", lib: string, podspec: string): { model?: any; error?: string; names: unknown } { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", reader === "reduced" ? "reduced" : undefined); + try { + return { model: readPodspec(podspec), names: names(lib, podspec) }; + } catch (e) { + return { error: message(e), names: names(lib, podspec) }; + } +} + +/** The reduced reader's read, beside the shim's: the fields that differ, its refusal or its error. */ +function reducedAgainst(shim: { model?: any }, reduced: { model?: any; error?: string }, podspec: string): object { + if (reduced.error !== undefined) return { error: reduced.error }; + const refused: string | null = unresolvedSourcesReason(podspec, reduced.model); + if (refused != null) return { refused }; + const fields = new Set([...Object.keys(shim.model ?? {}), ...Object.keys(reduced.model)]); + const differs = Object.fromEntries( + [...fields] + .filter((f) => !READER_FIELDS.has(f) && !isDeepStrictEqual(shim.model?.[f], reduced.model[f])) + .map((f) => [f, reduced.model[f] ?? null]), + ); + return { differs }; +} + +const records = new Map(); +/** + * What the readers read of the entry's `podspec` (relative to the library), in the golden's shape, with the project's + * root written as `` and keys sorted: Ruby's model, where the reduced reader differs from it, both readers' + * names, what the podspec used of its environment and of React Native's helpers, and where the TypeScript readers of + * `src/` (early checks' dependency lines, the scaffold's resource bundles) disagree with the shim. Made once per run; + * every environment stub is undone after it. + */ +export function record(entry: SweepEntry, podspec: string): unknown { + const key = `${entry.spec}\0${podspec}`; + if (records.has(key)) return records.get(key); + const { root } = sweepProject(entry); + const lib = path.join(root, "node_modules", nameOf(entry.spec)); + const file = path.join(lib, podspec); + vi.stubEnv("RN_SPM_RN_ROOT", path.join(root, "node_modules", "react-native")); + vi.stubEnv("RN_SPM_APP_IOS_DIR", path.join(root, "ios")); + vi.stubEnv("RN_SPM_PODSPEC_READS", undefined); + try { + const shim = readWith("ruby", lib, file); + const reduced = readWith("reduced", lib, file); + const raw: any = shim.error === undefined ? runPodspecShim(file).raw : undefined; + const text = readFileSync(file, "utf8"); + const used = (k: "env" | "helpers"): string[] => [...new Set(raw?.__rn_xtool__?.[k] ?? [])].sort(); + const golden = { + shim: shim.error === undefined ? shim.model : { error: shim.error }, + reduced: reducedAgainst(shim, reduced, file), + names: { shim: shim.names, reduced: reduced.names }, + env: used("env"), + helpers: used("helpers"), + tsReaders: + raw === undefined + ? null + : { + dependencies: disagreement(tsDependencies(text), shim.model.dependencies), + resourceBundles: disagreement(tsBundles(text), shimBundles(raw)), + }, + }; + const value = JSON.parse(JSON.stringify(sorted(golden)).replaceAll(root, "")); + records.set(key, value); + return value; + } finally { + vi.unstubAllEnvs(); + } +} + +/** The podspec's golden; with `RN_XTOOL_SWEEP_WRITE=1`, its {@link record} written as the golden first. */ +export function golden(entry: SweepEntry, podspec: string): unknown { + const file = goldenFile(entry, podspec); + if (WRITE) { + mkdirSync(path.dirname(file), { recursive: true }); + writeFileSync(file, `${JSON.stringify(record(entry, podspec), null, 2)}\n`); + } + if (!existsSync(file)) { + throw new Error(`no golden at ${path.relative(ROOT, file)}; write it with RN_XTOOL_SWEEP_WRITE=1 and review it`); + } + return JSON.parse(readFileSync(file, "utf8")); +} + +/** Each golden whose library's names differ between the readers, as ` : ≠ `. */ +export function nameDifferences(): string[] { + return SWEEP.flatMap((entry) => + goldenPodspecs(entry).flatMap((podspec) => { + const { names: n } = JSON.parse(readFileSync(goldenFile(entry, podspec), "utf8")) as { names: { shim: unknown; reduced: unknown } }; + return isDeepStrictEqual(n.shim, n.reduced) ? [] : [`${entry.spec} ${podspec}: ${JSON.stringify(n.shim)} ≠ ${JSON.stringify(n.reduced)}`]; + }), + ); +} + +/** + * What the goldens folder holds that no sweep entry's podspec owns (a folder of no entry, a golden of no podspec), and + * each podspec without a golden, by path under `tests/fixtures/podspec-sweep`. An entry whose tarballs are not here is + * checked for its folder only. + */ +export function orphanGoldens(): string[] { + const dirs = new Set(SWEEP.map((entry) => path.basename(goldenDir(entry)))); + const found = existsSync(SWEEP_GOLDENS) ? readdirSync(SWEEP_GOLDENS).sort() : []; + const strays = found.filter((d) => !dirs.has(d)).map((d) => `${d}/ (no entry)`); + return [ + ...strays, + ...SWEEP.flatMap((entry) => { + const podspecs = podspecsOf(entry); + const goldens = goldenPodspecs(entry); + const rel = (p: string) => path.relative(SWEEP_GOLDENS, goldenFile(entry, p)); + return [ + ...goldens.filter((p) => !podspecs.includes(p)).map((p) => `${rel(p)} (no podspec)`), + ...podspecs.filter((p) => !goldens.includes(p)).map((p) => `${rel(p)} (no golden)`), + ]; + }), + ]; +} From a52cdfc007a7c465020cce43703412709cdb8133 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:29:43 -0600 Subject: [PATCH 25/53] test: guard the sweep against silent gaps --- tests/podspecReaderSweep.test.ts | 31 ++++++++++++++- tests/support/podspecSweep.ts | 67 ++++++++++++++++++++++++-------- 2 files changed, 81 insertions(+), 17 deletions(-) diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index 3a53a90..c5a33d5 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -1,6 +1,9 @@ +import { tmpdir } from "node:os"; +import path from "node:path"; import { describe, expect, it } from "vitest"; import { podspecReaderHere } from "../src/tools/podspecReader.js"; -import { SWEEP, golden, nameDifferences, orphanGoldens, podspecsOf, record, type SweepEntry } from "./support/podspecSweep.js"; +import { packageRoot } from "../src/tools/exec.js"; +import { SWEEP, golden, goldenText, nameDifferences, orphanGoldens, podspecsOf, record, type SweepEntry } from "./support/podspecSweep.js"; import { needsRuby } from "./support/ruby.js"; import { needsTarball } from "./support/tarballs.js"; @@ -28,3 +31,29 @@ describe("the podspec reader sweep", () => { it("has a golden for every podspec and no other", () => expect(orphanGoldens()).toEqual([])); it.runIf(CI)("runs with Ruby on CI", () => expect(podspecReaderHere().reader).toBe("ruby")); }); + +describe("the sweep's guards", () => { + // A library that is pinned nowhere: a mistyped entry of tests/podspec-sweep.json. + const unpinned: SweepEntry = { spec: "react-native-unpinned@0.0.1", rn: "react-native@0.88.1" }; + const needs = " (needs react-native-unpinned@0.0.1 pinned in tests/tarballs.json)"; + + it("reports an entry without goldens, and on CI what it needs", () => { + expect(orphanGoldens([unpinned], false)).toContain("react-native-unpinned@0.0.1/ (no goldens)"); + expect(orphanGoldens([unpinned], false)).not.toContain(`react-native-unpinned@0.0.1${needs}`); + expect(orphanGoldens([unpinned], true)).toContain(`react-native-unpinned@0.0.1${needs}`); + }); + + it("refuses to write a gap of the shim as a golden", () => { + const gap = { shim: { error: "Foo.podspec: undefined method `bar'", kind: "method" } }; + expect(() => goldenText(gap)).toThrow("a gap of the shim (method): Foo.podspec: undefined method `bar'"); + const raised = { shim: { error: "Foo.podspec: the podspec raised", kind: "raised" } }; + expect(goldenText(raised)).toBe(`${JSON.stringify(raised, null, 2)}\n`); + }); + + it("refuses to write an absolute path into a golden", () => { + for (const dir of [tmpdir(), packageRoot(), "/home/me"]) { + expect(() => goldenText({ shim: { warnings: [path.join(dir, "Foo.podspec")] } })).toThrow("the golden would hold the absolute path"); + } + expect(goldenText({ shim: { warnings: ["/node_modules/foo/Foo.podspec"] } })).toContain(""); + }); +}); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index 9041220..4d424ff 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -6,7 +6,7 @@ */ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; -import { tmpdir } from "node:os"; +import { homedir, tmpdir } from "node:os"; import path from "node:path"; import { isDeepStrictEqual } from "node:util"; import { afterAll, vi } from "vitest"; @@ -25,10 +25,20 @@ export type SweepEntry = { spec: string; rn: string; with?: string[] }; export const SWEEP = JSON.parse(readFileSync(path.join(ROOT, "tests", "podspec-sweep.json"), "utf8")) as SweepEntry[]; const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); -const { readPodspec, runPodspecShim, unresolvedSourcesReason } = req("./read-podspec.js"); +const { isPodspecReadError, readPodspec, runPodspecShim, unresolvedSourcesReason } = req("./read-podspec.js"); const { defaultReadPodspec } = req("./expand-spm-dependencies.js"); const WRITE = process.env.RN_XTOOL_SWEEP_WRITE === "1"; +/** + * The error kinds of a read that stopped on a gap of the shim (`SHIM_GAP_KINDS` in the vendored read-podspec.js, read + * from its text so the two never drift): such a read is modelled in the shim first, never written as a golden. + */ +const SHIM_GAP_KINDS: ReadonlySet = (() => { + const source = readFileSync(path.join(VENDORED_RN_SPM, "read-podspec.js"), "utf8"); + const list = /const SHIM_GAP_KINDS = \[([^\]]*)\]/.exec(source)?.[1]; + if (list === undefined) throw new Error("vendor/rn-spm/spm/read-podspec.js: SHIM_GAP_KINDS not found"); + return new Set([...list.matchAll(/'([^']+)'/g)].map((m) => m[1]!)); +})(); /** Fields that name the reader rather than what it read: they differ by definition. */ const READER_FIELDS = new Set(["reader", "partial"]); @@ -146,13 +156,14 @@ function names(lib: string, podspec: string): Names | { error: string } { } } -/** What one read of a podspec gives: its model or error, its names. */ -function readWith(reader: "ruby" | "reduced", lib: string, podspec: string): { model?: any; error?: string; names: unknown } { +type Read = { model?: any; error?: string; kind?: string | null; names: unknown }; +/** What one read of a podspec gives: its model, or its error and the error's kind (`PodspecReadError`'s); its names. */ +function readWith(reader: "ruby" | "reduced", lib: string, podspec: string): Read { vi.stubEnv("RN_XTOOL_PODSPEC_READER", reader === "reduced" ? "reduced" : undefined); try { return { model: readPodspec(podspec), names: names(lib, podspec) }; } catch (e) { - return { error: message(e), names: names(lib, podspec) }; + return { error: message(e), kind: isPodspecReadError(e) ? String((e as { kind: unknown }).kind) : null, names: names(lib, podspec) }; } } @@ -173,7 +184,7 @@ function reducedAgainst(shim: { model?: any }, reduced: { model?: any; error?: s const records = new Map(); /** * What the readers read of the entry's `podspec` (relative to the library), in the golden's shape, with the project's - * root written as `` and keys sorted: Ruby's model, where the reduced reader differs from it, both readers' + * root written as ``, rn-xtool's as ``, and keys sorted: Ruby's model, where the reduced reader differs from it, both readers' * names, what the podspec used of its environment and of React Native's helpers, and where the TypeScript readers of * `src/` (early checks' dependency lines, the scaffold's resource bundles) disagree with the shim. Made once per run; * every environment stub is undone after it. @@ -194,7 +205,7 @@ export function record(entry: SweepEntry, podspec: string): unknown { const text = readFileSync(file, "utf8"); const used = (k: "env" | "helpers"): string[] => [...new Set(raw?.__rn_xtool__?.[k] ?? [])].sort(); const golden = { - shim: shim.error === undefined ? shim.model : { error: shim.error }, + shim: shim.error === undefined ? shim.model : { error: shim.error, kind: shim.kind }, reduced: reducedAgainst(shim, reduced, file), names: { shim: shim.names, reduced: reduced.names }, env: used("env"), @@ -207,7 +218,7 @@ export function record(entry: SweepEntry, podspec: string): unknown { resourceBundles: disagreement(tsBundles(text), shimBundles(raw)), }, }; - const value = JSON.parse(JSON.stringify(sorted(golden)).replaceAll(root, "")); + const value = JSON.parse(JSON.stringify(sorted(golden)).replaceAll(root, "").replaceAll(ROOT, "")); records.set(key, value); return value; } finally { @@ -215,12 +226,31 @@ export function record(entry: SweepEntry, podspec: string): unknown { } } -/** The podspec's golden; with `RN_XTOOL_SWEEP_WRITE=1`, its {@link record} written as the golden first. */ +/** + * A record's text as a golden file. Throws for a record that must not become one: a Ruby read that stopped on a gap of + * the shim (modelled in the shim first), or text that holds an absolute path (a temp folder, rn-xtool's checkout or a + * home folder). + */ +export function goldenText(value: unknown): string { + const text = `${JSON.stringify(value, null, 2)}\n`; + const shim = (value as { shim?: { error?: unknown; kind?: unknown } } | null)?.shim; + if (typeof shim?.kind === "string" && SHIM_GAP_KINDS.has(shim.kind)) { + throw new Error(`a gap of the shim (${shim.kind}): ${String(shim.error)}; model it in the shim before writing the golden`); + } + // The folder that holds the home folders, any user's. + const homes = `${path.dirname(homedir())}${path.sep}`; + const absolute = [tmpdir(), ROOT, homes].find((p) => text.includes(p)); + if (absolute !== undefined) throw new Error(`the golden would hold the absolute path ${absolute}; normalise it in record()`); + return text; +} + +/** The podspec's golden; with `RN_XTOOL_SWEEP_WRITE=1`, its {@link record} written as the golden first ({@link goldenText}). */ export function golden(entry: SweepEntry, podspec: string): unknown { const file = goldenFile(entry, podspec); if (WRITE) { + const text = goldenText(record(entry, podspec)); mkdirSync(path.dirname(file), { recursive: true }); - writeFileSync(file, `${JSON.stringify(record(entry, podspec), null, 2)}\n`); + writeFileSync(file, text); } if (!existsSync(file)) { throw new Error(`no golden at ${path.relative(ROOT, file)}; write it with RN_XTOOL_SWEEP_WRITE=1 and review it`); @@ -239,21 +269,26 @@ export function nameDifferences(): string[] { } /** - * What the goldens folder holds that no sweep entry's podspec owns (a folder of no entry, a golden of no podspec), and - * each podspec without a golden, by path under `tests/fixtures/podspec-sweep`. An entry whose tarballs are not here is - * checked for its folder only. + * What the goldens folder holds that no sweep entry's podspec owns (a folder of no entry, a golden of no podspec), each + * entry without a goldens folder, and each podspec without a golden, by path under `tests/fixtures/podspec-sweep`. An + * entry whose tarballs are not here is checked for its folder only, and on CI (`ci`), which fetched every tarball, it + * is listed with what it needs. */ -export function orphanGoldens(): string[] { - const dirs = new Set(SWEEP.map((entry) => path.basename(goldenDir(entry)))); +export function orphanGoldens(entries: readonly SweepEntry[] = SWEEP, ci = process.env.CI === "true"): string[] { + const dirs = new Set(entries.map((entry) => path.basename(goldenDir(entry)))); const found = existsSync(SWEEP_GOLDENS) ? readdirSync(SWEEP_GOLDENS).sort() : []; const strays = found.filter((d) => !dirs.has(d)).map((d) => `${d}/ (no entry)`); return [ ...strays, - ...SWEEP.flatMap((entry) => { + ...entries.flatMap((entry) => { + const missing = tarballsOf(entry).map((spec) => needsTarball(spec)).join(""); + const needs = ci && missing !== "" ? [`${entry.spec}${missing}`] : []; + if (!existsSync(goldenDir(entry))) return [`${path.basename(goldenDir(entry))}/ (no goldens)`, ...needs]; const podspecs = podspecsOf(entry); const goldens = goldenPodspecs(entry); const rel = (p: string) => path.relative(SWEEP_GOLDENS, goldenFile(entry, p)); return [ + ...needs, ...goldens.filter((p) => !podspecs.includes(p)).map((p) => `${rel(p)} (no podspec)`), ...podspecs.filter((p) => !goldens.includes(p)).map((p) => `${rel(p)} (no golden)`), ]; From 83b48fe9839d98784a6516bcfc2d2e722e80f4f1 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:33:51 -0600 Subject: [PATCH 26/53] test: fail loudly when the gap kinds parse empty --- tests/podspecReaderSweep.test.ts | 18 +++++++++++++++++- tests/support/podspecSweep.ts | 16 ++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index c5a33d5..c3164e0 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -3,7 +3,17 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; import { podspecReaderHere } from "../src/tools/podspecReader.js"; import { packageRoot } from "../src/tools/exec.js"; -import { SWEEP, golden, goldenText, nameDifferences, orphanGoldens, podspecsOf, record, type SweepEntry } from "./support/podspecSweep.js"; +import { + SWEEP, + golden, + goldenText, + nameDifferences, + orphanGoldens, + podspecsOf, + record, + shimGapKinds, + type SweepEntry, +} from "./support/podspecSweep.js"; import { needsRuby } from "./support/ruby.js"; import { needsTarball } from "./support/tarballs.js"; @@ -50,6 +60,12 @@ describe("the sweep's guards", () => { expect(goldenText(raised)).toBe(`${JSON.stringify(raised, null, 2)}\n`); }); + it("fails loudly when the shim's gap kinds parse empty", () => { + expect([...shimGapKinds("const SHIM_GAP_KINDS = [\n 'method',\n 'constant',\n];")]).toEqual(["method", "constant"]); + expect(() => shimGapKinds('const SHIM_GAP_KINDS = ["method", "constant"];')).toThrow("SHIM_GAP_KINDS parsed empty"); + expect(() => shimGapKinds("const GAPS = ['method'];")).toThrow("SHIM_GAP_KINDS not found"); + }); + it("refuses to write an absolute path into a golden", () => { for (const dir of [tmpdir(), packageRoot(), "/home/me"]) { expect(() => goldenText({ shim: { warnings: [path.join(dir, "Foo.podspec")] } })).toThrow("the golden would hold the absolute path"); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index 4d424ff..d9f3d29 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -30,15 +30,19 @@ const { defaultReadPodspec } = req("./expand-spm-dependencies.js"); const WRITE = process.env.RN_XTOOL_SWEEP_WRITE === "1"; /** - * The error kinds of a read that stopped on a gap of the shim (`SHIM_GAP_KINDS` in the vendored read-podspec.js, read - * from its text so the two never drift): such a read is modelled in the shim first, never written as a golden. + * The error kinds of a read that stopped on a gap of the shim, from read-podspec.js's text (`source`): its + * `SHIM_GAP_KINDS`, read so the two never drift. Throws when the list is missing or parses empty, so that no + * reformatting of it can turn the guard off. */ -const SHIM_GAP_KINDS: ReadonlySet = (() => { - const source = readFileSync(path.join(VENDORED_RN_SPM, "read-podspec.js"), "utf8"); +export function shimGapKinds(source: string): ReadonlySet { const list = /const SHIM_GAP_KINDS = \[([^\]]*)\]/.exec(source)?.[1]; if (list === undefined) throw new Error("vendor/rn-spm/spm/read-podspec.js: SHIM_GAP_KINDS not found"); - return new Set([...list.matchAll(/'([^']+)'/g)].map((m) => m[1]!)); -})(); + const set = new Set([...list.matchAll(/'([^']+)'/g)].map((m) => m[1]!)); + if (set.size === 0) throw new Error("vendor/rn-spm/spm/read-podspec.js: SHIM_GAP_KINDS parsed empty"); + return set; +} +/** The vendored read-podspec.js's gap kinds: such a read is modelled in the shim first, never written as a golden. */ +const SHIM_GAP_KINDS = shimGapKinds(readFileSync(path.join(VENDORED_RN_SPM, "read-podspec.js"), "utf8")); /** Fields that name the reader rather than what it read: they differ by definition. */ const READER_FIELDS = new Set(["reader", "partial"]); From 06c806e5339346eb634e4e124c752066035c78ba Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:41:44 -0600 Subject: [PATCH 27/53] feat: model attributes_hash in the podspec shim --- docs/upstream/react-native-scaffolder.md | 7 ++++--- patches/react-native+0.88.0.patch | 10 ++++++++-- patches/react-native+0.88.1.patch | 10 ++++++++-- tests/podspecShim.test.ts | 21 +++++++++++++++++++++ vendor/rn-spm/spm/read-podspec-shim.rb | 6 ++++++ 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index cb4a8b8..31589bd 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -892,9 +892,10 @@ Fix: the podspec runs in real Ruby. `read-podspec-shim.rb`, next to `read-podspe and an environment of `PATH`, `HOME`, `LANG` and fix 19's two variables (`RCT_NEW_ARCH_ENABLED=1`, `RCT_HERMES_V1_ENABLED=1`). It evaluates the podspec inside `module Pod`, as CocoaPods-core does, against a `Pod::Specification` with the attributes of CocoaPods 1.16's DSL (a setter and a getter each, the singular aliases -stored under their plural keys), `dependency`, `subspec`, `test_spec`, `app_spec` and the platform proxies (`s.ios`, -`s.osx`, `s.tvos`, `s.visionos`, `s.watchos`; `s.macos` stores under `osx`). It writes the spec in CocoaPods' JSON -form, what `pod ipc spec` printed, so `flattenSubspecs` reads it unchanged. `ruby --probe` checks the Ruby +stored under their plural keys), `attributes_hash` (the attributes as stored, which Nitro's generated +`add_nitrogen_files` reads and extends), `dependency`, `subspec`, `test_spec`, `app_spec` and the platform proxies +(`s.ios`, `s.osx`, `s.tvos`, `s.visionos`, `s.watchos`; `s.macos` stores under `osx`). It writes the spec in CocoaPods' +JSON form, what `pod ipc spec` printed, so `flattenSubspecs` reads it unchanged. `ruby --probe` checks the Ruby version before anything loads. The shim models what a static scan found called in the podspecs of the reference apps, of the Expo SDK 57 and 58 diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 37ec321..a928c0e 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..1536aa7 +index 0000000..110413b --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,511 @@ +@@ -0,0 +1,517 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -146,6 +146,12 @@ index 0000000..1536aa7 + define_method(proxy) { PlatformProxy.new(@attributes, platform) } + end + ++ # The attributes as stored, as CocoaPods' `attributes_hash` gives them (Nitro's generated `add_nitrogen_files` reads ++ # and extends them). ++ def attributes_hash ++ @attributes ++ end ++ + # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. + def name + @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 37ec321..a928c0e 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..1536aa7 +index 0000000..110413b --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,511 @@ +@@ -0,0 +1,517 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -146,6 +146,12 @@ index 0000000..1536aa7 + define_method(proxy) { PlatformProxy.new(@attributes, platform) } + end + ++ # The attributes as stored, as CocoaPods' `attributes_hash` gives them (Nitro's generated `add_nitrogen_files` reads ++ # and extends them). ++ def attributes_hash ++ @attributes ++ end ++ + # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. + def name + @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index 12f5f55..a6b53fe 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -78,6 +78,27 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { expect(r.json).not.toHaveProperty("author"); }); + it("answers attributes_hash with the attributes as stored", () => { + // Nitro's generated add_nitrogen_files reads the attributes set so far and adds its own to them. + const r = runShim(spec( + ' s.source_files = "ios/**/*.swift"', + ' s.pod_target_xcconfig = { "DEFINES_MODULE" => "NO", "OTHER_CFLAGS" => "-DX=1" }', + ' s.ios.frameworks = "UIKit"', + " s.source_files = Array(s.attributes_hash['source_files']) + ['nitrogen/**/*.swift']", + " s.pod_target_xcconfig = (s.attributes_hash['pod_target_xcconfig'] || {}).merge('DEFINES_MODULE' => 'YES')", + " s.summary = s.attributes_hash['ios']['frameworks']", + " s.description = s.attributes_hash['public_header_files'].nil?.to_s", + ' s.subspec "core" do |ss|', + " ss.summary = ss.attributes_hash.keys.join(',')", + " end", + )); + expect(r.status).toBe(0); + expect(r.json.source_files).toEqual(["ios/**/*.swift", "nitrogen/**/*.swift"]); + expect(r.json.pod_target_xcconfig).toEqual({ DEFINES_MODULE: "YES", OTHER_CFLAGS: "-DX=1" }); + expect([r.json.summary, r.json.description]).toEqual(["UIKit", "true"]); + expect(r.json.subspecs[0].summary).toBe("name"); + }); + it("refuses an attribute CocoaPods does not define", () => { const r = runShim(`Pod::Spec.new do |s|\n s.name = "Foo"\n s.not_an_attribute = 1\nend`); expect([r.status, r.json.error.kind]).toEqual([1, "attribute"]); diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb index 1536aa7..110413b 100644 --- a/vendor/rn-spm/spm/read-podspec-shim.rb +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -89,6 +89,12 @@ def initialize(parent = nil, name = nil) define_method(proxy) { PlatformProxy.new(@attributes, platform) } end + # The attributes as stored, as CocoaPods' `attributes_hash` gives them (Nitro's generated `add_nitrogen_files` reads + # and extends them). + def attributes_hash + @attributes + end + # A subspec's name reads as CocoaPods gives it, `Foo/core`; the model keeps its base name. def name @parent ? "#{@parent.name}/#{@attributes['name']}" : @attributes['name'] From 9ee016669f1c9cc030c3c3526aee9cc5d00354c6 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:47:29 -0600 Subject: [PATCH 28/53] chore: cache the test tarballs in CI --- .github/workflows/ci.yml | 10 +++++++++- tests/ci/workflow.test.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c132881..9a3892a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,6 @@ # CI: on every pull request to main and every push to main, install, fetch the pinned upstream tarballs the tests -# read, type-check, scan the tracked files for private identifiers and run the whole test suite. +# read (restored from the cache while tests/tarballs.json is unchanged), type-check, scan the tracked files for private +# identifiers and run the whole test suite. # A second job runs the podspec reader's Ruby shim tests on the oldest Ruby the shim supports. # # Nothing is compiled for iOS and no device is touched: there is no Swift, no Darwin SDK and no iPhone here. Tests that @@ -27,6 +28,7 @@ concurrency: jobs: test: runs-on: ubuntu-latest + # At least twice a fetch from an empty cache plus the tests (under 2 minutes measured locally), and never under 15. # Also bounds the fetch script's npm pack, which has no timeout of its own. timeout-minutes: 15 steps: @@ -40,6 +42,12 @@ jobs: # npm ci runs the package's prepare script, which builds dist/. - name: Install and build run: npm ci + # Keyed on the manifest: a changed pin starts a new cache, and the fetch below checks every integrity anyway. + - name: Cache the test tarballs + uses: actions/cache@v6 + with: + path: tests/.cache + key: test-tarballs-${{ hashFiles('tests/tarballs.json') }} - name: Fetch the test tarballs run: node scripts/fetch-test-tarballs.mjs - name: Type-check diff --git a/tests/ci/workflow.test.ts b/tests/ci/workflow.test.ts index 6b51e58..5875b49 100644 --- a/tests/ci/workflow.test.ts +++ b/tests/ci/workflow.test.ts @@ -91,7 +91,7 @@ describe("CI workflow", () => { it("uses Node 22 on hosted Ubuntu, and setup-ruby only for the Ruby floor", () => { const uses = (job: string) => jobSteps(job).flatMap((s) => (s.uses ? [s.uses] : [])); - expect(uses("test")).toEqual(["actions/checkout@v7", "actions/setup-node@v7"]); + expect(uses("test")).toEqual(["actions/checkout@v7", "actions/setup-node@v7", "actions/cache@v6"]); expect(uses("shim-ruby-floor")).toEqual(["actions/checkout@v7", "actions/setup-node@v7", "ruby/setup-ruby@v1"]); for (const node of steps().filter((s) => s.uses === "actions/setup-node@v7")) { expect(node.with?.["node-version"]).toBe(22); @@ -107,6 +107,14 @@ describe("CI workflow", () => { expect(ruby.with?.["ruby-version"]).toBe(floor); }); + it("restores the test tarballs from a cache keyed on their manifest, before fetching them", () => { + const all = jobSteps("test"); + const cache = all.findIndex((s) => s.uses?.startsWith("actions/cache")); + expect(all[cache]!.with).toEqual({ path: "tests/.cache", key: "test-tarballs-${{ hashFiles('tests/tarballs.json') }}" }); + expect(cache).toBe(all.findIndex((s) => s.name === "Fetch the test tarballs") - 1); + expect(jobSteps("shim-ruby-floor").some((s) => s.uses?.startsWith("actions/cache"))).toBe(false); + }); + it("stops a stuck job after 15 minutes", () => { // The fetch script's npm pack has no timeout of its own; the job's covers it. expect(Object.keys(doc().jobs)).toEqual(["test", "shim-ruby-floor"]); From 9d67b91fe06903b7573031c68a92064b80b81cb1 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:54:34 -0600 Subject: [PATCH 29/53] feat: load the colored2 stub as CocoaPods does --- docs/upstream/react-native-scaffolder.md | 9 +++++---- patches/react-native+0.88.0.patch | 12 +++++++----- patches/react-native+0.88.1.patch | 12 +++++++----- tests/podspecShim.test.ts | 6 ++++++ vendor/rn-spm/spm/read-podspec-shim.rb | 8 +++++--- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 31589bd..5ec54af 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -910,10 +910,11 @@ React Native's Podfile, and `use_expo_modules!` is not defined. Expo's `Packages `Pod::Config.instance` gives the app's `ios` folder as `installation_root` and `project_root` (`RN_SPM_APP_IOS_DIR` when set, else the podspec's path cut before its first `/node_modules/` plus `/ios`, else the podspec's folder), that folder's `Pods` as `project_pods_root`, and no `@podfile`. `Pod::VERSION` is `1.16.2`. `require` loads a name on -Ruby's own load path, the library's files by path, and a stub of `colored2`; `require_relative`, backticks, `system`, -`raise` and `abort` are real Ruby, so a library's own scripts run as under CocoaPods (worklets finds React Native, and -gesture-handler finds worklets, with `node`). Every `ENV` name the podspec reads is recorded; other environment -variables and globals are unset. React Native's other helpers stay undefined, and a call to one fails as `method`. +Ruby's own load path, the library's files by path, and a stub of `colored2`, loaded before the podspec runs as CocoaPods +has colored2 loaded; `require_relative`, backticks, `system`, `raise` and `abort` are real Ruby, so a library's own +scripts run as under CocoaPods (worklets finds React Native, and gesture-handler finds worklets, with `node`). Every +`ENV` name the podspec reads is recorded; other environment variables and globals are unset. React Native's other +helpers stay undefined, and a call to one fails as `method`. A podspec Ruby cannot read stops the read with a `PodspecReadError`; nothing falls back. A gap of the shim names where it stopped (`:`, or ` (:)` in another of the library's files): `method` (the diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index a928c0e..e9844ba 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..110413b +index 0000000..2bd1819 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,517 @@ +@@ -0,0 +1,519 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -351,9 +351,10 @@ index 0000000..110413b + end +end + -+# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the -+# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files -+# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. ++# `require`: a name on Ruby's own load path loads, `colored2` is the stub (loaded before the podspec runs, as CocoaPods ++# has loaded colored2), a file given by its path (Ruby's own, the library's) loads, any other name fails. ++# `require_relative` of the library's own files is Ruby's. What Ruby's own files read of `ENV` (RubyGems' `GEM_*`) is ++# not the podspec's, so it is not recorded. +module RnXtoolShim + # colored2 (a gem CocoaPods brings): its String colours and effects. + COLORED2 = %w[ @@ -437,6 +438,7 @@ index 0000000..110413b + # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. + def run(podspec, out, root) + Pod::Config.instance = Pod::Config.new(root) ++ load_colored2 + spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) + unless spec.is_a?(Pod::Specification) + write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index a928c0e..e9844ba 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..110413b +index 0000000..2bd1819 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,517 @@ +@@ -0,0 +1,519 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -351,9 +351,10 @@ index 0000000..110413b + end +end + -+# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the -+# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files -+# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. ++# `require`: a name on Ruby's own load path loads, `colored2` is the stub (loaded before the podspec runs, as CocoaPods ++# has loaded colored2), a file given by its path (Ruby's own, the library's) loads, any other name fails. ++# `require_relative` of the library's own files is Ruby's. What Ruby's own files read of `ENV` (RubyGems' `GEM_*`) is ++# not the podspec's, so it is not recorded. +module RnXtoolShim + # colored2 (a gem CocoaPods brings): its String colours and effects. + COLORED2 = %w[ @@ -437,6 +438,7 @@ index 0000000..110413b + # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. + def run(podspec, out, root) + Pod::Config.instance = Pod::Config.new(root) ++ load_colored2 + spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) + unless spec.is_a?(Pod::Specification) + write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index a6b53fe..4ec8978 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -236,6 +236,12 @@ describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { expect(r.json).toMatchObject({ summary: "[]", description: "false" }); }); + it("has colored2 loaded before the podspec runs, as CocoaPods does", () => { + const r = runShim(spec(' s.summary = "x".yellow', " s.description = require('colored2').to_s")); + expect(r.status).toBe(0); + expect([r.json.summary, r.json.description]).toEqual(["x", "false"]); + }); + it("stubs colored2 and refuses other gems", () => { const r = runShim(`require 'json'\nrequire 'rubygems'\nrequire 'colored2'\n${spec(' s.summary = "x".yellow')}`); expect(r.status).toBe(0); diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb index 110413b..2bd1819 100644 --- a/vendor/rn-spm/spm/read-podspec-shim.rb +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -294,9 +294,10 @@ def spm_dependency(spec, url:, requirement:, products:) end end -# `require`: a name on Ruby's own load path loads, `colored2` loads its stub, a file given by its path (Ruby's own, the -# library's) loads, any other name fails. `require_relative` of the library's own files is Ruby's. What Ruby's own files -# read of `ENV` (RubyGems' `GEM_*`) is not the podspec's, so it is not recorded. +# `require`: a name on Ruby's own load path loads, `colored2` is the stub (loaded before the podspec runs, as CocoaPods +# has loaded colored2), a file given by its path (Ruby's own, the library's) loads, any other name fails. +# `require_relative` of the library's own files is Ruby's. What Ruby's own files read of `ENV` (RubyGems' `GEM_*`) is +# not the podspec's, so it is not recorded. module RnXtoolShim # colored2 (a gem CocoaPods brings): its String colours and effects. COLORED2 = %w[ @@ -380,6 +381,7 @@ module RnXtoolShim # Writes the model, or the error, to `out`; whether the podspec read. `root` is the app's `ios/` folder. def run(podspec, out, root) Pod::Config.instance = Pod::Config.new(root) + load_colored2 spec = Pod._eval_podspec(File.read(podspec, encoding: 'UTF-8'), podspec) unless spec.is_a?(Pod::Specification) write(out, 'error' => { 'kind' => 'not-a-spec', 'message' => "#{podspec}: the podspec does not evaluate to a Pod::Spec" }) From 3ab5f07c3e9900e7b761654beb5be7117a0451b0 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 07:56:58 -0600 Subject: [PATCH 30/53] test: key sweep goldens by library and React Native --- .../RNGestureHandler.podspec.json | 0 .../RNScreens.podspec.json | 0 .../RNSVG.podspec.json | 0 tests/podspecReaderSweep.test.ts | 20 +++++++++++--- tests/support/podspecSweep.ts | 27 ++++++++++++------- 5 files changed, 34 insertions(+), 13 deletions(-) rename tests/fixtures/podspec-sweep/{react-native-gesture-handler@3.4.0 => react-native-gesture-handler@3.4.0@rn-0.88.1}/RNGestureHandler.podspec.json (100%) rename tests/fixtures/podspec-sweep/{react-native-screens@4.30.0 => react-native-screens@4.30.0@rn-0.88.1}/RNScreens.podspec.json (100%) rename tests/fixtures/podspec-sweep/{react-native-svg@15.16.0 => react-native-svg@15.16.0@rn-0.88.1}/RNSVG.podspec.json (100%) diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0@rn-0.88.1/RNGestureHandler.podspec.json similarity index 100% rename from tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0/RNGestureHandler.podspec.json rename to tests/fixtures/podspec-sweep/react-native-gesture-handler@3.4.0@rn-0.88.1/RNGestureHandler.podspec.json diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.88.1/RNScreens.podspec.json similarity index 100% rename from tests/fixtures/podspec-sweep/react-native-screens@4.30.0/RNScreens.podspec.json rename to tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.88.1/RNScreens.podspec.json diff --git a/tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.88.1/RNSVG.podspec.json similarity index 100% rename from tests/fixtures/podspec-sweep/react-native-svg@15.16.0/RNSVG.podspec.json rename to tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.88.1/RNSVG.podspec.json diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index c3164e0..9f726a1 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -5,6 +5,7 @@ import { podspecReaderHere } from "../src/tools/podspecReader.js"; import { packageRoot } from "../src/tools/exec.js"; import { SWEEP, + entryName, golden, goldenText, nameDifferences, @@ -33,11 +34,15 @@ const skip = (entry: SweepEntry) => skipReason(entry) !== ""; describe("the podspec reader sweep", () => { for (const entry of SWEEP) for (const podspec of podspecsOf(entry)) - it.skipIf(skip(entry))(`reads ${entry.spec} ${podspec} as its golden${skipReason(entry)}`, () => { + it.skipIf(skip(entry))(`reads ${entryName(entry)} ${podspec} as its golden${skipReason(entry)}`, () => { expect(record(entry, podspec)).toEqual(golden(entry, podspec)); }); it("keeps every library's names under both readers", () => expect(nameDifferences()).toEqual([])); + it("lists each library once per React Native", () => { + const names = SWEEP.map(entryName); + expect(names.filter((name, i) => names.indexOf(name) !== i)).toEqual([]); + }); it("has a golden for every podspec and no other", () => expect(orphanGoldens()).toEqual([])); it.runIf(CI)("runs with Ruby on CI", () => expect(podspecReaderHere().reader).toBe("ruby")); }); @@ -48,9 +53,16 @@ describe("the sweep's guards", () => { const needs = " (needs react-native-unpinned@0.0.1 pinned in tests/tarballs.json)"; it("reports an entry without goldens, and on CI what it needs", () => { - expect(orphanGoldens([unpinned], false)).toContain("react-native-unpinned@0.0.1/ (no goldens)"); - expect(orphanGoldens([unpinned], false)).not.toContain(`react-native-unpinned@0.0.1${needs}`); - expect(orphanGoldens([unpinned], true)).toContain(`react-native-unpinned@0.0.1${needs}`); + expect(orphanGoldens([unpinned], false)).toContain("react-native-unpinned@0.0.1@rn-0.88.1/ (no goldens)"); + expect(orphanGoldens([unpinned], false)).not.toContain(`react-native-unpinned@0.0.1 on react-native@0.88.1${needs}`); + expect(orphanGoldens([unpinned], true)).toContain(`react-native-unpinned@0.0.1 on react-native@0.88.1${needs}`); + }); + + it("gives a library read against two React Natives a golden folder for each", () => { + const older: SweepEntry = { ...unpinned, rn: "react-native@0.86.3" }; + const orphans = orphanGoldens([unpinned, older], false); + expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.88.1/ (no goldens)"); + expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.86.3/ (no goldens)"); }); it("refuses to write a gap of the shim as a golden", () => { diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index d9f3d29..c21d0f3 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -20,7 +20,10 @@ import { tool } from "./tools.js"; const ROOT = packageRoot(); export const SWEEP_GOLDENS = path.join(ROOT, "tests", "fixtures", "podspec-sweep"); -/** An entry of `tests/podspec-sweep.json`: a library, the React Native it is read against, and the packages it needs. */ +/** + * An entry of `tests/podspec-sweep.json`: a library, the React Native it is read against, and the packages it needs. A + * library and a React Native together name the entry: the same library may be read against several React Natives. + */ export type SweepEntry = { spec: string; rn: string; with?: string[] }; export const SWEEP = JSON.parse(readFileSync(path.join(ROOT, "tests", "podspec-sweep.json"), "utf8")) as SweepEntry[]; @@ -54,6 +57,8 @@ afterAll(() => { const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); const tarballsOf = (entry: SweepEntry) => [entry.spec, entry.rn, ...(entry.with ?? [])]; +/** The entry's name in titles and messages: ` on `. */ +export const entryName = (entry: SweepEntry) => `${entry.spec} on ${entry.rn}`; const message = (e: unknown) => (e instanceof Error ? e.message : String(e)); /** `spec`'s tarball extracted into `dir` (only `members` of it when given). */ @@ -72,7 +77,7 @@ const projects = new Map(); * `/node_modules/react-native`. `podspecs` are the library's podspec files that exist, relative to it. */ export function sweepProject(entry: SweepEntry): { root: string; podspecs: string[] } { - let project = projects.get(entry.spec); + let project = projects.get(entryName(entry)); if (project) return project; const root = realpathSync(mkdtempSync(path.join(tmpdir(), "rn-xtool-sweep-"))); tmp.push(root); @@ -84,12 +89,16 @@ export function sweepProject(entry: SweepEntry): { root: string; podspecs: strin writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "sweep-app", version: "1.0.0", dependencies })); const lib = path.join(modules, nameOf(entry.spec)); const podspecs = podspecFiles(lib).filter((f) => existsSync(f)).map((f) => path.relative(lib, f)); - projects.set(entry.spec, (project = { root, podspecs })); + projects.set(entryName(entry), (project = { root, podspecs })); return project; } -/** The entry's golden folder, and a podspec's golden file in it. */ -const goldenDir = (entry: SweepEntry) => path.join(SWEEP_GOLDENS, entry.spec.replaceAll("/", "+")); +/** + * The entry's golden folder, `@rn-` with a scoped name's `/` as `+` (the last `@` starts + * React Native's version), and a podspec's golden file in it. + */ +const goldenDir = (entry: SweepEntry) => + path.join(SWEEP_GOLDENS, `${entry.spec.replaceAll("/", "+")}@rn-${versionOf(entry.rn)}`); const goldenFile = (entry: SweepEntry, podspec: string) => path.join(goldenDir(entry), `${podspec.replaceAll("/", "__")}.json`); /** The podspecs the entry's goldens are for. */ function goldenPodspecs(entry: SweepEntry): string[] { @@ -194,7 +203,7 @@ const records = new Map(); * every environment stub is undone after it. */ export function record(entry: SweepEntry, podspec: string): unknown { - const key = `${entry.spec}\0${podspec}`; + const key = `${entryName(entry)}\0${podspec}`; if (records.has(key)) return records.get(key); const { root } = sweepProject(entry); const lib = path.join(root, "node_modules", nameOf(entry.spec)); @@ -262,12 +271,12 @@ export function golden(entry: SweepEntry, podspec: string): unknown { return JSON.parse(readFileSync(file, "utf8")); } -/** Each golden whose library's names differ between the readers, as ` : ≠ `. */ +/** Each golden whose library's names differ between the readers, as ` on : ≠ `. */ export function nameDifferences(): string[] { return SWEEP.flatMap((entry) => goldenPodspecs(entry).flatMap((podspec) => { const { names: n } = JSON.parse(readFileSync(goldenFile(entry, podspec), "utf8")) as { names: { shim: unknown; reduced: unknown } }; - return isDeepStrictEqual(n.shim, n.reduced) ? [] : [`${entry.spec} ${podspec}: ${JSON.stringify(n.shim)} ≠ ${JSON.stringify(n.reduced)}`]; + return isDeepStrictEqual(n.shim, n.reduced) ? [] : [`${entryName(entry)} ${podspec}: ${JSON.stringify(n.shim)} ≠ ${JSON.stringify(n.reduced)}`]; }), ); } @@ -286,7 +295,7 @@ export function orphanGoldens(entries: readonly SweepEntry[] = SWEEP, ci = proce ...strays, ...entries.flatMap((entry) => { const missing = tarballsOf(entry).map((spec) => needsTarball(spec)).join(""); - const needs = ci && missing !== "" ? [`${entry.spec}${missing}`] : []; + const needs = ci && missing !== "" ? [`${entryName(entry)}${missing}`] : []; if (!existsSync(goldenDir(entry))) return [`${path.basename(goldenDir(entry))}/ (no goldens)`, ...needs]; const podspecs = podspecsOf(entry); const goldens = goldenPodspecs(entry); From c67d0edc5108375fce91c882a9e728698df98772 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 08:03:11 -0600 Subject: [PATCH 31/53] test: sweep R11's library set in CI --- .../ios__ExpoDomWebView.podspec.json | 68 ++++ .../ios__ExpoDomWebView.podspec.json | 68 ++++ .../ExpoLogBox.podspec.json | 70 ++++ .../ExpoLogBox.podspec.json | 70 ++++ .../AsyncStorage.podspec.json | 71 ++++ .../RNCClipboard.podspec.json | 89 +++++ .../RNDateTimePicker.podspec.json | 70 ++++ .../RNDateTimePicker.podspec.json | 70 ++++ .../react-native-netinfo.podspec.json | 74 +++++ .../react-native-slider.podspec.json | 100 ++++++ .../RNFBApp.podspec.json | 101 ++++++ .../RNGoogleSignin.podspec.json | 75 +++++ ..._ios__ExpoAdapterGoogleSignIn.podspec.json | 78 +++++ .../RNCMaskedView.podspec.json | 69 ++++ .../RNCPicker.podspec.json | 73 +++++ .../RNSentry.podspec.json | 112 +++++++ .../react-native-skia.podspec.json | 75 +++++ .../ios__ExpoAsset.podspec.json | 68 ++++ .../ios__ExpoAsset.podspec.json | 68 ++++ .../ios__EXConstants.podspec.json | 79 +++++ .../ios__EXConstants.podspec.json | 79 +++++ .../ios__ExpoFileSystem.podspec.json | 68 ++++ .../ios__ExpoFileSystem.podspec.json | 70 ++++ .../ios__ExpoFont.podspec.json | 68 ++++ .../ios__ExpoFont.podspec.json | 68 ++++ .../ios__ExpoGlassEffect.podspec.json | 66 ++++ .../ios__ExpoHaptics.podspec.json | 68 ++++ .../ios__ExpoKeepAwake.podspec.json | 68 ++++ .../ios__ExpoKeepAwake.podspec.json | 68 ++++ .../ios__ExpoLinking.podspec.json | 66 ++++ .../ExpoModulesCore.podspec.json | 131 ++++++++ .../ExpoModulesWorklets.podspec.json | 79 +++++ .../ExpoModulesWorkletsAdapter.podspec.json | 90 ++++++ .../ExpoModulesCore.podspec.json | 132 ++++++++ .../ExpoModulesWorklets.podspec.json | 79 +++++ .../ExpoModulesWorkletsAdapter.podspec.json | 90 ++++++ .../ios__ExpoRouter.podspec.json | 87 +++++ .../ios__ExpoStatusBar.podspec.json | 68 ++++ .../expo@57.0.31@rn-0.86.3/Expo.podspec.json | 97 ++++++ .../expo@58.0.21@rn-0.88.1/Expo.podspec.json | 97 ++++++ .../lottie-react-native.podspec.json | 99 ++++++ .../react-native-blob-util.podspec.json | 97 ++++++ .../RNDeviceInfo.podspec.json | 66 ++++ .../RNGestureHandler.podspec.json | 77 +++++ .../RNGestureHandler.podspec.json | 77 +++++ .../RNGestureHandler.podspec.json | 77 +++++ .../RNGestureHandler.podspec.json | 77 +++++ ...eact-native-get-random-values.podspec.json | 71 ++++ ...ct-native-keyboard-controller.podspec.json | 118 +++++++ .../react-native-maps.podspec.json | 80 +++++ .../NitroMmkv.podspec.json | 110 +++++++ .../NitroModules.podspec.json | 110 +++++++ .../react-native-pager-view.podspec.json | 74 +++++ .../RNPermissions.podspec.json | 72 +++++ .../RNPurchases.podspec.json | 73 +++++ .../RNReanimated.podspec.json | 158 +++++++++ .../RNReanimated.podspec.json | 158 +++++++++ ...eact-native-safe-area-context.podspec.json | 97 ++++++ ...eact-native-safe-area-context.podspec.json | 97 ++++++ ...eact-native-safe-area-context.podspec.json | 97 ++++++ ...eact-native-safe-area-context.podspec.json | 97 ++++++ .../RNScreens.podspec.json | 93 ++++++ .../RNScreens.podspec.json | 93 ++++++ .../RNScreens.podspec.json | 93 ++++++ .../RNScreens.podspec.json | 93 ++++++ .../RNSVG.podspec.json | 94 ++++++ .../RNSVG.podspec.json | 94 ++++++ .../RNSVG.podspec.json | 94 ++++++ .../react-native-view-shot.podspec.json | 69 ++++ .../VisionCamera.podspec.json | 126 ++++++++ .../react-native-webview.podspec.json | 95 ++++++ .../react-native-webview.podspec.json | 95 ++++++ .../react-native-webview.podspec.json | 95 ++++++ .../RNWorklets.podspec.json | 173 ++++++++++ .../RNWorklets.podspec.json | 173 ++++++++++ .../RNWorklets.podspec.json | 173 ++++++++++ .../RNWorklets.podspec.json | 186 +++++++++++ .../RNWorklets.podspec.json | 186 +++++++++++ tests/podspec-sweep.json | 75 ++++- tests/tarballs.json | 305 ++++++++++++++++++ 80 files changed, 7573 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/podspec-sweep/@expo+dom-webview@57.0.1@rn-0.86.3/ios__ExpoDomWebView.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@expo+dom-webview@58.0.2@rn-0.88.1/ios__ExpoDomWebView.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@expo+log-box@57.0.4@rn-0.86.3/ExpoLogBox.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@expo+log-box@58.0.13@rn-0.88.1/ExpoLogBox.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-async-storage+async-storage@3.1.1@rn-0.88.1/AsyncStorage.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-clipboard+clipboard@1.16.3@rn-0.88.1/RNCClipboard.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.2.1@rn-0.88.1/RNDateTimePicker.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.3.0@rn-0.88.1/RNDateTimePicker.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-community+netinfo@12.0.1@rn-0.88.1/react-native-netinfo.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-community+slider@5.2.2@rn-0.88.1/react-native-slider.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-firebase+app@27.1.0@rn-0.88.1/RNFBApp.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/RNGoogleSignin.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/expo__ios__ExpoAdapterGoogleSignIn.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-masked-view+masked-view@0.3.2@rn-0.88.1/RNCMaskedView.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@react-native-picker+picker@2.11.4@rn-0.88.1/RNCPicker.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@sentry+react-native@8.34.0@rn-0.88.1/RNSentry.podspec.json create mode 100644 tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-asset@57.0.20@rn-0.86.3/ios__ExpoAsset.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-asset@58.0.19@rn-0.88.1/ios__ExpoAsset.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-constants@57.0.22@rn-0.86.3/ios__EXConstants.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-constants@58.0.14@rn-0.88.1/ios__EXConstants.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-file-system@57.0.7@rn-0.86.3/ios__ExpoFileSystem.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-file-system@58.0.13@rn-0.88.1/ios__ExpoFileSystem.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-font@57.0.4@rn-0.86.3/ios__ExpoFont.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-font@58.0.11@rn-0.88.1/ios__ExpoFont.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-glass-effect@58.0.5@rn-0.88.1/ios__ExpoGlassEffect.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-haptics@58.0.7@rn-0.88.1/ios__ExpoHaptics.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-keep-awake@57.0.2@rn-0.86.3/ios__ExpoKeepAwake.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-keep-awake@58.0.3@rn-0.88.1/ios__ExpoKeepAwake.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-linking@58.0.15@rn-0.88.1/ios__ExpoLinking.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesCore.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorkletsAdapter.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesCore.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorkletsAdapter.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-router@58.0.28@rn-0.88.1/ios__ExpoRouter.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo-status-bar@58.0.4@rn-0.88.1/ios__ExpoStatusBar.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo@57.0.31@rn-0.86.3/Expo.podspec.json create mode 100644 tests/fixtures/podspec-sweep/expo@58.0.21@rn-0.88.1/Expo.podspec.json create mode 100644 tests/fixtures/podspec-sweep/lottie-react-native@7.5.0@rn-0.88.1/lottie-react-native.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-blob-util@0.25.1@rn-0.88.1/react-native-blob-util.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-device-info@15.0.2@rn-0.88.1/RNDeviceInfo.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.86.3/RNGestureHandler.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.87.1/RNGestureHandler.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1/RNGestureHandler.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.5.0@rn-0.88.1/RNGestureHandler.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-get-random-values@2.1.0@rn-0.88.1/react-native-get-random-values.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-keyboard-controller@1.23.0@rn-0.88.1/react-native-keyboard-controller.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-maps@1.29.11@rn-0.88.1/react-native-maps.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-mmkv@4.3.2@rn-0.88.1/NitroMmkv.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-nitro-modules@0.37.2@rn-0.88.1/NitroModules.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-pager-view@10.0.0@rn-0.88.1/react-native-pager-view.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-permissions@5.6.3@rn-0.88.1/RNPermissions.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-purchases@11.0.1@rn-0.88.1/RNPurchases.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.86.3/RNReanimated.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.88.1/RNReanimated.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.86.3/react-native-safe-area-context.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.87.1/react-native-safe-area-context.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.88.1/react-native-safe-area-context.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-safe-area-context@5.11.1@rn-0.88.1/react-native-safe-area-context.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-screens@4.24.0@rn-0.85.0/RNScreens.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.86.3/RNScreens.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.87.1/RNScreens.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-screens@4.30.1@rn-0.88.1/RNScreens.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.86.3/RNSVG.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.87.1/RNSVG.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-svg@15.16.1@rn-0.88.1/RNSVG.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-view-shot@6.2.1@rn-0.88.1/react-native-view-shot.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-vision-camera@4.7.3@rn-0.88.1/VisionCamera.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.86.3/react-native-webview.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.87.1/react-native-webview.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.88.1/react-native-webview.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.86.3/RNWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.88.1/RNWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-worklets@0.13.1@rn-0.88.1/RNWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-worklets@0.8.1@rn-0.85.0/RNWorklets.podspec.json create mode 100644 tests/fixtures/podspec-sweep/react-native-worklets@0.8.3@rn-0.85.0/RNWorklets.podspec.json diff --git a/tests/fixtures/podspec-sweep/@expo+dom-webview@57.0.1@rn-0.86.3/ios__ExpoDomWebView.podspec.json b/tests/fixtures/podspec-sweep/@expo+dom-webview@57.0.1@rn-0.86.3/ios__ExpoDomWebView.podspec.json new file mode 100644 index 0000000..b5d3aa0 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@expo+dom-webview@57.0.1@rn-0.86.3/ios__ExpoDomWebView.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoDomWebView" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoDomWebView" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoDomWebView", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@expo+dom-webview@58.0.2@rn-0.88.1/ios__ExpoDomWebView.podspec.json b/tests/fixtures/podspec-sweep/@expo+dom-webview@58.0.2@rn-0.88.1/ios__ExpoDomWebView.podspec.json new file mode 100644 index 0000000..b5d3aa0 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@expo+dom-webview@58.0.2@rn-0.88.1/ios__ExpoDomWebView.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoDomWebView" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoDomWebView" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoDomWebView", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@expo+log-box@57.0.4@rn-0.86.3/ExpoLogBox.podspec.json b/tests/fixtures/podspec-sweep/@expo+log-box@57.0.4@rn-0.86.3/ExpoLogBox.podspec.json new file mode 100644 index 0000000..5fe6c21 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@expo+log-box@57.0.4@rn-0.86.3/ExpoLogBox.podspec.json @@ -0,0 +1,70 @@ +{ + "env": [ + "EXPO_DEBUG_LOG_BOX", + "EXPO_DEVELOP_LOG_BOX", + "EXPO_UNSTABLE_LOG_BOX" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLogBox" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLogBox" + } + }, + "reduced": { + "refused": "/node_modules/@expo/log-box/ExpoLogBox.podspec: `s.compiler_flags = extraCompilerFlags` cannot be evaluated: it uses `extraCompilerFlags`, which is assigned `'$(inherited)' \\\n + (isDevelop ? \" -DEXPO_DEVELOP_LOG_BOX\" : \"\") \\\n + (isDebug ? \" -DEXPO_DEBUG_LOG_BOX\" : \"\") \\\n + (isEnabled ? \" -DEXPO_UNSTABLE_LOG_BOX\" : \"\")`, which the reader cannot evaluate (`\\` where it ends). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "$(inherited)" + ], + "dependencies": [ + "React-Core" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoLogBox", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@expo+log-box@58.0.13@rn-0.88.1/ExpoLogBox.podspec.json b/tests/fixtures/podspec-sweep/@expo+log-box@58.0.13@rn-0.88.1/ExpoLogBox.podspec.json new file mode 100644 index 0000000..5fe6c21 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@expo+log-box@58.0.13@rn-0.88.1/ExpoLogBox.podspec.json @@ -0,0 +1,70 @@ +{ + "env": [ + "EXPO_DEBUG_LOG_BOX", + "EXPO_DEVELOP_LOG_BOX", + "EXPO_UNSTABLE_LOG_BOX" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLogBox" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLogBox" + } + }, + "reduced": { + "refused": "/node_modules/@expo/log-box/ExpoLogBox.podspec: `s.compiler_flags = extraCompilerFlags` cannot be evaluated: it uses `extraCompilerFlags`, which is assigned `'$(inherited)' \\\n + (isDevelop ? \" -DEXPO_DEVELOP_LOG_BOX\" : \"\") \\\n + (isDebug ? \" -DEXPO_DEBUG_LOG_BOX\" : \"\") \\\n + (isEnabled ? \" -DEXPO_UNSTABLE_LOG_BOX\" : \"\")`, which the reader cannot evaluate (`\\` where it ends). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "$(inherited)" + ], + "dependencies": [ + "React-Core" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoLogBox", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-async-storage+async-storage@3.1.1@rn-0.88.1/AsyncStorage.podspec.json b/tests/fixtures/podspec-sweep/@react-native-async-storage+async-storage@3.1.1@rn-0.88.1/AsyncStorage.podspec.json new file mode 100644 index 0000000..7105f2a --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-async-storage+async-storage@3.1.1@rn-0.88.1/AsyncStorage.podspec.json @@ -0,0 +1,71 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "AsyncStorage" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "AsyncStorage" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "AsyncStorage", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm,cpp,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9.2" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-clipboard+clipboard@1.16.3@rn-0.88.1/RNCClipboard.podspec.json b/tests/fixtures/podspec-sweep/@react-native-clipboard+clipboard@1.16.3@rn-0.88.1/RNCClipboard.podspec.json new file mode 100644 index 0000000..f770030 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-clipboard+clipboard@1.16.3@rn-0.88.1/RNCClipboard.podspec.json @@ -0,0 +1,89 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNCClipboard" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNCClipboard" + } + }, + "reduced": { + "differs": { + "headerSearchPaths": [], + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/RCT-Folly" + ], + "libraries": [], + "moduleName": null, + "name": "RNCClipboard", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.2.1@rn-0.88.1/RNDateTimePicker.podspec.json b/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.2.1@rn-0.88.1/RNDateTimePicker.podspec.json new file mode 100644 index 0000000..3627df7 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.2.1@rn-0.88.1/RNDateTimePicker.podspec.json @@ -0,0 +1,70 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNDateTimePicker" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNDateTimePicker" + } + }, + "reduced": { + "differs": { + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNDateTimePicker", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.3.0@rn-0.88.1/RNDateTimePicker.podspec.json b/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.3.0@rn-0.88.1/RNDateTimePicker.podspec.json new file mode 100644 index 0000000..3627df7 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-community+datetimepicker@9.3.0@rn-0.88.1/RNDateTimePicker.podspec.json @@ -0,0 +1,70 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNDateTimePicker" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNDateTimePicker" + } + }, + "reduced": { + "differs": { + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNDateTimePicker", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-community+netinfo@12.0.1@rn-0.88.1/react-native-netinfo.podspec.json b/tests/fixtures/podspec-sweep/@react-native-community+netinfo@12.0.1@rn-0.88.1/react-native-netinfo.podspec.json new file mode 100644 index 0000000..d8cbbff --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-community+netinfo@12.0.1@rn-0.88.1/react-native-netinfo.podspec.json @@ -0,0 +1,74 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-netinfo" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-netinfo" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [ + "NetworkExtension" + ], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "react-native-netinfo", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-community+slider@5.2.2@rn-0.88.1/react-native-slider.podspec.json b/tests/fixtures/podspec-sweep/@react-native-community+slider@5.2.2@rn-0.88.1/react-native-slider.podspec.json new file mode 100644 index 0000000..47c94cb --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-community+slider@5.2.2@rn-0.88.1/react-native-slider.podspec.json @@ -0,0 +1,100 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-slider" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-slider" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-Core", + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost", + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-slider", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-firebase+app@27.1.0@rn-0.88.1/RNFBApp.podspec.json b/tests/fixtures/podspec-sweep/@react-native-firebase+app@27.1.0@rn-0.88.1/RNFBApp.podspec.json new file mode 100644 index 0000000..48ccd09 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-firebase+app@27.1.0@rn-0.88.1/RNFBApp.podspec.json @@ -0,0 +1,101 @@ +{ + "env": [ + "FIREBASE_SDK_VERSION", + "RCT_NEW_ARCH_ENABLED", + "RNFB_TEST_RN_BARE_DYNAMIC_FIREBASE" + ], + "helpers": [ + "install_modules_dependencies", + "spm_dependency" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNFBApp" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNFBApp" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "React-Core" + ], + "requiresArc": false, + "spmDependencies": [], + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "ios/generated/RCTThirdPartyComponentsProvider.*", + "ios/generated/RCTAppDependencyProvider.*", + "ios/generated/RCTModuleProviders.*", + "ios/generated/RCTModulesConformingToProtocolsProvider.*", + "ios/generated/RCTUnstableModulesRequiringMainQueueSetupProvider.*", + "ios/*UnitTests/**/*", + "ios/RNFBFirebase/**/*" + ], + "frameworks": [ + "Photos" + ], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNFBApp", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/**/*.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp,swift}" + ], + "spmDependencies": [ + { + "products": [ + "FirebaseCore", + "FirebaseInstallations" + ], + "url": "https://github.com/firebase/firebase-ios-sdk.git" + } + ], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.10" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/RNGoogleSignin.podspec.json b/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/RNGoogleSignin.podspec.json new file mode 100644 index 0000000..e027d6a --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/RNGoogleSignin.podspec.json @@ -0,0 +1,75 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGoogleSignin" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGoogleSignin" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "GoogleSignIn" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGoogleSignin", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "GoogleSignIn" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/expo__ios__ExpoAdapterGoogleSignIn.podspec.json b/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/expo__ios__ExpoAdapterGoogleSignIn.podspec.json new file mode 100644 index 0000000..becc8d3 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-google-signin+google-signin@17.0.0@rn-0.88.1/expo__ios__ExpoAdapterGoogleSignIn.podspec.json @@ -0,0 +1,78 @@ +{ + "env": [ + "EXPO_USE_SOURCE" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAdapterGoogleSignIn" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAdapterGoogleSignIn" + } + }, + "reduced": { + "refused": "/node_modules/@react-native-google-signin/google-signin/expo/ios/ExpoAdapterGoogleSignIn.podspec: `s.source_files = \"#{s.name}/**/*.h\"` cannot be evaluated: it uses the unknown identifier `s`; `s.source_files = \"#{s.name}/**/*.{h,m,swift}\"` cannot be evaluated: it uses the unknown identifier `s`. The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore", + "React-Core", + "GoogleSignIn", + "GoogleUtilities/Environment", + "GoogleUtilities/UserDefaults", + "RecaptchaInterop" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoAdapterGoogleSignIn", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ExpoAdapterGoogleSignIn/**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.4" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "GoogleSignIn", + "GoogleUtilities/Environment", + "GoogleUtilities/UserDefaults", + "RecaptchaInterop" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-masked-view+masked-view@0.3.2@rn-0.88.1/RNCMaskedView.podspec.json b/tests/fixtures/podspec-sweep/@react-native-masked-view+masked-view@0.3.2@rn-0.88.1/RNCMaskedView.podspec.json new file mode 100644 index 0000000..d0a88cf --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-masked-view+masked-view@0.3.2@rn-0.88.1/RNCMaskedView.podspec.json @@ -0,0 +1,69 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNCMaskedView" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNCMaskedView" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNCMaskedView", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@react-native-picker+picker@2.11.4@rn-0.88.1/RNCPicker.podspec.json b/tests/fixtures/podspec-sweep/@react-native-picker+picker@2.11.4@rn-0.88.1/RNCPicker.podspec.json new file mode 100644 index 0000000..83f975a --- /dev/null +++ b/tests/fixtures/podspec-sweep/@react-native-picker+picker@2.11.4@rn-0.88.1/RNCPicker.podspec.json @@ -0,0 +1,73 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNCPicker" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNCPicker" + } + }, + "reduced": { + "differs": { + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNCPicker", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@sentry+react-native@8.34.0@rn-0.88.1/RNSentry.podspec.json b/tests/fixtures/podspec-sweep/@sentry+react-native@8.34.0@rn-0.88.1/RNSentry.podspec.json new file mode 100644 index 0000000..85946b9 --- /dev/null +++ b/tests/fixtures/podspec-sweep/@sentry+react-native@8.34.0@rn-0.88.1/RNSentry.podspec.json @@ -0,0 +1,112 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED", + "REACT_NATIVE_NODE_MODULES_DIR", + "SENTRY_USE_SPM", + "SENTRY_USE_XCFRAMEWORK", + "SENTRY_XCFRAMEWORK_CACHE_DIR", + "USE_FRAMEWORKS", + "USE_HERMES" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNSentry" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNSentry" + } + }, + "reduced": { + "refused": "/node_modules/@sentry/react-native/RNSentry.podspec: `s.compiler_flags = other_cflags` cannot be evaluated: it uses `other_cflags`, which is assigned `\"$(inherited)\" + new_arch_enabled_flag + sentry_profiling_supported_flag + new_hermes_runtime_flag`, which the reader cannot evaluate (`new_arch_enabled_flag`, which is assigned `(is_new_arch_enabled ? folly_compiler_flags + \" -DRCT_NEW_ARCH_ENABLED\" : \"\")`, which the reader cannot evaluate (`folly_compiler_flags`, which is set under `should_use_folly_flags(rn_version)`, a condition the reader cannot evaluate)). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "$(inherited)" + ], + "dependencies": [ + "React-hermes", + "hermes-engine" + ], + "excludeFiles": [ + "ios/include/**/*" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNSentry", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": null + }, + { + "config": null, + "name": "SENTRY_PROFILING_SUPPORTED", + "value": "1" + }, + { + "config": null, + "name": "NEW_HERMES_RUNTIME", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "ios/RNSentry.h", + "ios/RNSentrySDK.h", + "ios/RNSentryStart.h", + "ios/RNSentryVersion.h", + "ios/RNSentryBreadcrumb.h", + "ios/RNSentryReplay.h", + "ios/RNSentryReplayBreadcrumbConverter.h", + "ios/Replay/RNSentryReplayMask.h", + "ios/Replay/RNSentryReplayUnmask.h", + "ios/RNSentryTimeToDisplay.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}", + "cpp/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.5" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "React-hermes", + "hermes-engine" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json b/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json new file mode 100644 index 0000000..df501cc --- /dev/null +++ b/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json @@ -0,0 +1,75 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-skia" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-skia" + } + }, + "reduced": { + "differs": { + "compilerFlags": [], + "dependencies": [ + "React", + "React-callinvoker", + "React-Core" + ], + "excludeFiles": [ + "cpp/rnskia/RNDawnContext.h", + "cpp/rnskia/RNDawnUtils.h", + "cpp/rnskia/RNMetalLayerColorSpace.h", + "cpp/rnskia/RNDawnWindowContext.h", + "cpp/rnskia/RNDawnWindowContext.cpp", + "cpp/rnskia/RNDawnInterop.cpp", + "cpp/rnskia/RNImageProvider.h" + ], + "frameworks": [ + "MetalKit", + "AVFoundation", + "AVKit", + "CoreMedia" + ], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "react-native-skia", + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,c,cc,cpp,m,mm,swift}", + "cpp/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Left out of s.pod_target_xcconfig GCC_PREPROCESSOR_DEFINITIONS: `preprocessor_defs`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ], + "weakFrameworks": [] + } + }, + "shim": { + "error": "/node_modules/@shopify/react-native-skia/react-native-skia.podspec:125: react-native-skia: Skia prebuilt binaries not found. Run `yarn install` then `pod install` to fix this.", + "kind": "raised" + }, + "tsReaders": null +} diff --git a/tests/fixtures/podspec-sweep/expo-asset@57.0.20@rn-0.86.3/ios__ExpoAsset.podspec.json b/tests/fixtures/podspec-sweep/expo-asset@57.0.20@rn-0.86.3/ios__ExpoAsset.podspec.json new file mode 100644 index 0000000..ed1414f --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-asset@57.0.20@rn-0.86.3/ios__ExpoAsset.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAsset" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAsset" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoAsset", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-asset@58.0.19@rn-0.88.1/ios__ExpoAsset.podspec.json b/tests/fixtures/podspec-sweep/expo-asset@58.0.19@rn-0.88.1/ios__ExpoAsset.podspec.json new file mode 100644 index 0000000..ed1414f --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-asset@58.0.19@rn-0.88.1/ios__ExpoAsset.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAsset" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoAsset" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoAsset", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-constants@57.0.22@rn-0.86.3/ios__EXConstants.podspec.json b/tests/fixtures/podspec-sweep/expo-constants@57.0.22@rn-0.86.3/ios__EXConstants.podspec.json new file mode 100644 index 0000000..12f230e --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-constants@57.0.22@rn-0.86.3/ios__EXConstants.podspec.json @@ -0,0 +1,79 @@ +{ + "env": [ + "EXPO_USE_SOURCE", + "PROJECT_ROOT" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "EXConstants" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "EXConstants" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "sourceFiles": [ + "**/*.h" + ], + "warnings": [ + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "EXConstants", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [ + "The podspec sets script_phases, which a CocoaPods build applies and rn-xtool's scaffold does not." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-constants@58.0.14@rn-0.88.1/ios__EXConstants.podspec.json b/tests/fixtures/podspec-sweep/expo-constants@58.0.14@rn-0.88.1/ios__EXConstants.podspec.json new file mode 100644 index 0000000..12f230e --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-constants@58.0.14@rn-0.88.1/ios__EXConstants.podspec.json @@ -0,0 +1,79 @@ +{ + "env": [ + "EXPO_USE_SOURCE", + "PROJECT_ROOT" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "EXConstants" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "EXConstants" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "sourceFiles": [ + "**/*.h" + ], + "warnings": [ + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "EXConstants", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [ + "The podspec sets script_phases, which a CocoaPods build applies and rn-xtool's scaffold does not." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-file-system@57.0.7@rn-0.86.3/ios__ExpoFileSystem.podspec.json b/tests/fixtures/podspec-sweep/expo-file-system@57.0.7@rn-0.86.3/ios__ExpoFileSystem.podspec.json new file mode 100644 index 0000000..222576d --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-file-system@57.0.7@rn-0.86.3/ios__ExpoFileSystem.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFileSystem" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFileSystem" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoFileSystem", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-file-system@58.0.13@rn-0.88.1/ios__ExpoFileSystem.podspec.json b/tests/fixtures/podspec-sweep/expo-file-system@58.0.13@rn-0.88.1/ios__ExpoFileSystem.podspec.json new file mode 100644 index 0000000..10d0143 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-file-system@58.0.13@rn-0.88.1/ios__ExpoFileSystem.podspec.json @@ -0,0 +1,70 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFileSystem" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFileSystem" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [ + "Tests/" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoFileSystem", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-font@57.0.4@rn-0.86.3/ios__ExpoFont.podspec.json b/tests/fixtures/podspec-sweep/expo-font@57.0.4@rn-0.86.3/ios__ExpoFont.podspec.json new file mode 100644 index 0000000..db40c00 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-font@57.0.4@rn-0.86.3/ios__ExpoFont.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFont" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFont" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoFont", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-font@58.0.11@rn-0.88.1/ios__ExpoFont.podspec.json b/tests/fixtures/podspec-sweep/expo-font@58.0.11@rn-0.88.1/ios__ExpoFont.podspec.json new file mode 100644 index 0000000..db40c00 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-font@58.0.11@rn-0.88.1/ios__ExpoFont.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFont" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoFont" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoFont", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-glass-effect@58.0.5@rn-0.88.1/ios__ExpoGlassEffect.podspec.json b/tests/fixtures/podspec-sweep/expo-glass-effect@58.0.5@rn-0.88.1/ios__ExpoGlassEffect.podspec.json new file mode 100644 index 0000000..fa64cd6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-glass-effect@58.0.5@rn-0.88.1/ios__ExpoGlassEffect.podspec.json @@ -0,0 +1,66 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoGlassEffect" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoGlassEffect" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoGlassEffect", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-haptics@58.0.7@rn-0.88.1/ios__ExpoHaptics.podspec.json b/tests/fixtures/podspec-sweep/expo-haptics@58.0.7@rn-0.88.1/ios__ExpoHaptics.podspec.json new file mode 100644 index 0000000..2bb1df1 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-haptics@58.0.7@rn-0.88.1/ios__ExpoHaptics.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoHaptics" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoHaptics" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoHaptics", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-keep-awake@57.0.2@rn-0.86.3/ios__ExpoKeepAwake.podspec.json b/tests/fixtures/podspec-sweep/expo-keep-awake@57.0.2@rn-0.86.3/ios__ExpoKeepAwake.podspec.json new file mode 100644 index 0000000..31e37c4 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-keep-awake@57.0.2@rn-0.86.3/ios__ExpoKeepAwake.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoKeepAwake" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoKeepAwake" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoKeepAwake", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-keep-awake@58.0.3@rn-0.88.1/ios__ExpoKeepAwake.podspec.json b/tests/fixtures/podspec-sweep/expo-keep-awake@58.0.3@rn-0.88.1/ios__ExpoKeepAwake.podspec.json new file mode 100644 index 0000000..31e37c4 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-keep-awake@58.0.3@rn-0.88.1/ios__ExpoKeepAwake.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoKeepAwake" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoKeepAwake" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoKeepAwake", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-linking@58.0.15@rn-0.88.1/ios__ExpoLinking.podspec.json b/tests/fixtures/podspec-sweep/expo-linking@58.0.15@rn-0.88.1/ios__ExpoLinking.podspec.json new file mode 100644 index 0000000..110b9ef --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-linking@58.0.15@rn-0.88.1/ios__ExpoLinking.podspec.json @@ -0,0 +1,66 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLinking" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoLinking" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoLinking", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,mm,swift,hpp,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesCore.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesCore.podspec.json new file mode 100644 index 0000000..b659a7e --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesCore.podspec.json @@ -0,0 +1,131 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED", + "REACT_NATIVE_PATH", + "USE_FRAMEWORKS", + "USE_HERMES" + ], + "helpers": [ + "add_dependency", + "get_folly_config", + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "ExpoModulesCore", + "moduleName": null, + "name": "ExpoModulesCore" + }, + "shim": { + "headerDir": "ExpoModulesCore", + "moduleName": null, + "name": "ExpoModulesCore" + } + }, + "reduced": { + "refused": "/node_modules/expo-modules-core/ExpoModulesCore.podspec: `s.compiler_flags = compiler_flags` cannot be evaluated: it uses `compiler_flags`, which is changed by `compiler_flags << ' ' << new_arch_compiler_flags`, which the reader cannot evaluate. The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "hermes-engine", + "React-jsinspector", + "React-Core", + "ReactCommon/turbomodule/core", + "React-NativeModulesApple", + "React-RCTFabric", + "ExpoModulesJSI" + ], + "excludeFiles": [ + "ios/Tests", + "ios/Worklets", + "ios/WorkletsTests", + "ios/WorkletsAdapter" + ], + "frameworks": [], + "headerDir": "ExpoModulesCore", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesCore", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift,cpp}", + "common/cpp/**/*.{h,cpp}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header", + "$(PODS_ROOT)/Headers/Private/Yoga" + ], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesCore", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_TARGET_VERSION", + "value": "86" + }, + { + "config": null, + "name": "USE_HERMES", + "value": null + }, + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": null + }, + { + "config": null, + "name": "EXPO_MODULES_CORE_VERSION", + "value": "57.0.24" + } + ], + "privateHeaderFiles": [ + "ios/**/*+Private.h", + "ios/**/Swift.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift,cpp}", + "common/cpp/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1, FOLLY_CFG_NO_COROUTINES=1, FOLLY_HAVE_CLOCK_GETTIME=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "React-jsinspector", + "hermes-engine" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorklets.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorklets.podspec.json new file mode 100644 index 0000000..1c0e7cd --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorklets.podspec.json @@ -0,0 +1,79 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": "ExpoModulesWorklets", + "moduleName": null, + "name": "ExpoModulesWorklets" + }, + "shim": { + "headerDir": "ExpoModulesWorklets", + "moduleName": null, + "name": "ExpoModulesWorklets" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesJSI", + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "ExpoModulesWorklets", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesWorklets", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/Worklets/**/*.{h,m,mm,swift,cpp}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesWorklets", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/Worklets/**/*+Private.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/Worklets/**/*.{h,m,mm,swift,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorkletsAdapter.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorkletsAdapter.podspec.json new file mode 100644 index 0000000..6b82225 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@57.0.24@rn-0.86.3/ExpoModulesWorkletsAdapter.podspec.json @@ -0,0 +1,90 @@ +{ + "env": [ + "PROJECT_ROOT", + "USE_FRAMEWORKS" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": "ExpoModulesWorkletsAdapter", + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter" + }, + "shim": { + "headerDir": "ExpoModulesWorkletsAdapter", + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter" + } + }, + "reduced": { + "differs": { + "headerSearchPaths": [], + "requiresArc": false, + "warnings": [ + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesJSI", + "ExpoModulesCore", + "ExpoModulesWorklets", + "RNWorklets" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "ExpoModulesWorkletsAdapter", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesWorkletsAdapter", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/WorkletsAdapter/**/*.{h,m,mm}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_ROOT)/../../node_modules/react-native-worklets/apple", + "$(PODS_ROOT)/../../node_modules/react-native-worklets/Common/cpp", + "$(PODS_ROOT)/Headers/Private/ExpoModulesWorklets" + ], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/WorkletsAdapter/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesCore.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesCore.podspec.json new file mode 100644 index 0000000..4597f2a --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesCore.podspec.json @@ -0,0 +1,132 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED", + "REACT_NATIVE_PATH", + "USE_FRAMEWORKS", + "USE_HERMES" + ], + "helpers": [ + "add_dependency", + "get_folly_config", + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "ExpoModulesCore", + "moduleName": null, + "name": "ExpoModulesCore" + }, + "shim": { + "headerDir": "ExpoModulesCore", + "moduleName": null, + "name": "ExpoModulesCore" + } + }, + "reduced": { + "refused": "/node_modules/expo-modules-core/ExpoModulesCore.podspec: `s.compiler_flags = compiler_flags` cannot be evaluated: it uses `compiler_flags`, which is changed by `compiler_flags << ' ' << new_arch_compiler_flags`, which the reader cannot evaluate. The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "hermes-engine", + "React-jsinspector", + "React-Core", + "ReactCommon/turbomodule/core", + "React-NativeModulesApple", + "React-RCTFabric", + "ExpoModulesJSI" + ], + "excludeFiles": [ + "ios/Tests", + "ios/Benchmarks", + "ios/Worklets", + "ios/WorkletsTests", + "ios/WorkletsAdapter" + ], + "frameworks": [], + "headerDir": "ExpoModulesCore", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesCore", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift,cpp}", + "common/cpp/**/*.{h,cpp}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header", + "$(PODS_ROOT)/Headers/Private/Yoga" + ], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesCore", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_TARGET_VERSION", + "value": "88" + }, + { + "config": null, + "name": "USE_HERMES", + "value": null + }, + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": null + }, + { + "config": null, + "name": "EXPO_MODULES_CORE_VERSION", + "value": "58.0.28" + } + ], + "privateHeaderFiles": [ + "ios/**/*+Private.h", + "ios/**/Swift.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift,cpp}", + "common/cpp/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1, FOLLY_CFG_NO_COROUTINES=1, FOLLY_HAVE_CLOCK_GETTIME=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "React-jsinspector", + "hermes-engine" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorklets.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorklets.podspec.json new file mode 100644 index 0000000..1c0e7cd --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorklets.podspec.json @@ -0,0 +1,79 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": "ExpoModulesWorklets", + "moduleName": null, + "name": "ExpoModulesWorklets" + }, + "shim": { + "headerDir": "ExpoModulesWorklets", + "moduleName": null, + "name": "ExpoModulesWorklets" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesJSI", + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "ExpoModulesWorklets", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesWorklets", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/Worklets/**/*.{h,m,mm,swift,cpp}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesWorklets", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/Worklets/**/*+Private.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/Worklets/**/*.{h,m,mm,swift,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorkletsAdapter.podspec.json b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorkletsAdapter.podspec.json new file mode 100644 index 0000000..6b82225 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-modules-core@58.0.28@rn-0.88.1/ExpoModulesWorkletsAdapter.podspec.json @@ -0,0 +1,90 @@ +{ + "env": [ + "PROJECT_ROOT", + "USE_FRAMEWORKS" + ], + "helpers": [], + "names": { + "reduced": { + "headerDir": "ExpoModulesWorkletsAdapter", + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter" + }, + "shim": { + "headerDir": "ExpoModulesWorkletsAdapter", + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter" + } + }, + "reduced": { + "differs": { + "headerSearchPaths": [], + "requiresArc": false, + "warnings": [ + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesJSI", + "ExpoModulesCore", + "ExpoModulesWorklets", + "RNWorklets" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "ExpoModulesWorkletsAdapter", + "headerDirScopes": [ + { + "headerDir": "ExpoModulesWorkletsAdapter", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/WorkletsAdapter/**/*.{h,m,mm}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_ROOT)/../../node_modules/react-native-worklets/apple", + "$(PODS_ROOT)/../../node_modules/react-native-worklets/Common/cpp", + "$(PODS_ROOT)/Headers/Private/ExpoModulesWorklets" + ], + "libraries": [], + "moduleName": null, + "name": "ExpoModulesWorkletsAdapter", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/WorkletsAdapter/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-router@58.0.28@rn-0.88.1/ios__ExpoRouter.podspec.json b/tests/fixtures/podspec-sweep/expo-router@58.0.28@rn-0.88.1/ios__ExpoRouter.podspec.json new file mode 100644 index 0000000..8d79c79 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-router@58.0.28@rn-0.88.1/ios__ExpoRouter.podspec.json @@ -0,0 +1,87 @@ +{ + "env": [ + "EXPO_USE_SOURCE", + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "add_dependency" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoRouter" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoRouter" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "ExpoModulesCore" + ], + "requiresArc": false, + "sourceFiles": [ + "**/*.h" + ], + "warnings": [ + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore", + "RNScreens" + ], + "excludeFiles": [ + "Tests/**/*" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoRouter", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift,mm,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "RNScreens" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo-status-bar@58.0.4@rn-0.88.1/ios__ExpoStatusBar.podspec.json b/tests/fixtures/podspec-sweep/expo-status-bar@58.0.4@rn-0.88.1/ios__ExpoStatusBar.podspec.json new file mode 100644 index 0000000..ef26777 --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo-status-bar@58.0.4@rn-0.88.1/ios__ExpoStatusBar.podspec.json @@ -0,0 +1,68 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "ExpoStatusBar" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "ExpoStatusBar" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "ExpoModulesCore" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "ExpoStatusBar", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo@57.0.31@rn-0.86.3/Expo.podspec.json b/tests/fixtures/podspec-sweep/expo@57.0.31@rn-0.86.3/Expo.podspec.json new file mode 100644 index 0000000..692256e --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo@57.0.31@rn-0.86.3/Expo.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "REACT_NATIVE_PATH", + "USE_FRAMEWORKS" + ], + "helpers": [ + "get_folly_config", + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "Expo", + "moduleName": null, + "name": "Expo" + }, + "shim": { + "headerDir": "Expo", + "moduleName": null, + "name": "Expo" + } + }, + "reduced": { + "refused": "/node_modules/expo/Expo.podspec: `s.compiler_flags = compiler_flags` cannot be evaluated: it uses `compiler_flags`, which is assigned `get_folly_config()[:compiler_flags]`, which the reader cannot evaluate (the method call `get_folly_config(...)`). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-RCTAppDelegate", + "React-RCTFabric", + "ReactAppDependencyProvider" + ], + "excludeFiles": [ + "ios/Tests" + ], + "frameworks": [], + "headerDir": "Expo", + "headerDirScopes": [ + { + "headerDir": "Expo", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/DoubleConversion", + "${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header", + "${PODS_CONFIGURATION_BUILD_DIR}/Expo/Swift Compatibility Header", + "$(PODS_ROOT)/Headers/Private/Yoga" + ], + "libraries": [], + "moduleName": null, + "name": "Expo", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/**/Swift.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1, FOLLY_CFG_NO_COROUTINES=1, FOLLY_HAVE_CLOCK_GETTIME=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/expo@58.0.21@rn-0.88.1/Expo.podspec.json b/tests/fixtures/podspec-sweep/expo@58.0.21@rn-0.88.1/Expo.podspec.json new file mode 100644 index 0000000..692256e --- /dev/null +++ b/tests/fixtures/podspec-sweep/expo@58.0.21@rn-0.88.1/Expo.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "REACT_NATIVE_PATH", + "USE_FRAMEWORKS" + ], + "helpers": [ + "get_folly_config", + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "Expo", + "moduleName": null, + "name": "Expo" + }, + "shim": { + "headerDir": "Expo", + "moduleName": null, + "name": "Expo" + } + }, + "reduced": { + "refused": "/node_modules/expo/Expo.podspec: `s.compiler_flags = compiler_flags` cannot be evaluated: it uses `compiler_flags`, which is assigned `get_folly_config()[:compiler_flags]`, which the reader cannot evaluate (the method call `get_folly_config(...)`). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-RCTAppDelegate", + "React-RCTFabric", + "ReactAppDependencyProvider" + ], + "excludeFiles": [ + "ios/Tests" + ], + "frameworks": [], + "headerDir": "Expo", + "headerDirScopes": [ + { + "headerDir": "Expo", + "headerMappingsDirs": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/DoubleConversion", + "${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header", + "${PODS_CONFIGURATION_BUILD_DIR}/Expo/Swift Compatibility Header", + "$(PODS_ROOT)/Headers/Private/Yoga" + ], + "libraries": [], + "moduleName": null, + "name": "Expo", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/**/Swift.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "6.0" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1, FOLLY_CFG_NO_COROUTINES=1, FOLLY_HAVE_CLOCK_GETTIME=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/lottie-react-native@7.5.0@rn-0.88.1/lottie-react-native.podspec.json b/tests/fixtures/podspec-sweep/lottie-react-native@7.5.0@rn-0.88.1/lottie-react-native.podspec.json new file mode 100644 index 0000000..473b83d --- /dev/null +++ b/tests/fixtures/podspec-sweep/lottie-react-native@7.5.0@rn-0.88.1/lottie-react-native.podspec.json @@ -0,0 +1,99 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "lottie-ios", + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "lottie-ios" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-blob-util@0.25.1@rn-0.88.1/react-native-blob-util.podspec.json b/tests/fixtures/podspec-sweep/react-native-blob-util@0.25.1@rn-0.88.1/react-native-blob-util.podspec.json new file mode 100644 index 0000000..2070d4a --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-blob-util@0.25.1@rn-0.88.1/react-native-blob-util.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-Core", + "React-Codegen", + "React-RCTFabric", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [ + "Photos" + ], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-device-info@15.0.2@rn-0.88.1/RNDeviceInfo.podspec.json b/tests/fixtures/podspec-sweep/react-native-device-info@15.0.2@rn-0.88.1/RNDeviceInfo.podspec.json new file mode 100644 index 0000000..069fa9f --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-device-info@15.0.2@rn-0.88.1/RNDeviceInfo.podspec.json @@ -0,0 +1,66 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNDeviceInfo" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNDeviceInfo" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNDeviceInfo", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.86.3/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.86.3/RNGestureHandler.podspec.json new file mode 100644 index 0000000..93cd4b6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.86.3/RNGestureHandler.podspec.json @@ -0,0 +1,77 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "RNWorklets" + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.87.1/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.87.1/RNGestureHandler.podspec.json new file mode 100644 index 0000000..93cd4b6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.87.1/RNGestureHandler.podspec.json @@ -0,0 +1,77 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "RNWorklets" + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1/RNGestureHandler.podspec.json new file mode 100644 index 0000000..93cd4b6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1/RNGestureHandler.podspec.json @@ -0,0 +1,77 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "RNWorklets" + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.5.0@rn-0.88.1/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.5.0@rn-0.88.1/RNGestureHandler.podspec.json new file mode 100644 index 0000000..93cd4b6 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.5.0@rn-0.88.1/RNGestureHandler.podspec.json @@ -0,0 +1,77 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "RNWorklets" + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-get-random-values@2.1.0@rn-0.88.1/react-native-get-random-values.podspec.json b/tests/fixtures/podspec-sweep/react-native-get-random-values@2.1.0@rn-0.88.1/react-native-get-random-values.podspec.json new file mode 100644 index 0000000..0f71b9d --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-get-random-values@2.1.0@rn-0.88.1/react-native-get-random-values.podspec.json @@ -0,0 +1,71 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-get-random-values" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-get-random-values" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "react-native-get-random-values", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "ios/**/*.h" + ], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-keyboard-controller@1.23.0@rn-0.88.1/react-native-keyboard-controller.podspec.json b/tests/fixtures/podspec-sweep/react-native-keyboard-controller@1.23.0@rn-0.88.1/react-native-keyboard-controller.podspec.json new file mode 100644 index 0000000..1c5bf63 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-keyboard-controller@1.23.0@rn-0.88.1/react-native-keyboard-controller.podspec.json @@ -0,0 +1,118 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-keyboard-controller" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-keyboard-controller" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-Core", + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost", + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "Left out s.pod_target_xcconfig = s.pod_target_xcconfig | {\n \"HEADER_SEARCH_PATHS\" => \"\\\"$(PODS_ROOT)/boost\\\"\",\n \"OTHER_CPLUSPLUSFLAGS\" => \"-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1\",\n \"CLANG_CXX_LANGUAGE_STANDARD\" => \"c++17\"\n }: the podspec reader cannot evaluate it (the unknown identifier `s`); CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "ios/KeyboardControllerNative/**/*" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "react/renderer/components/RNKC", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-keyboard-controller", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "common/cpp/**/*.{h}" + ], + "publicHeaderFiles": [ + "ios/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-maps@1.29.11@rn-0.88.1/react-native-maps.podspec.json b/tests/fixtures/podspec-sweep/react-native-maps@1.29.11@rn-0.88.1/react-native-maps.podspec.json new file mode 100644 index 0000000..000e75d --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-maps@1.29.11@rn-0.88.1/react-native-maps.podspec.json @@ -0,0 +1,80 @@ +{ + "env": [], + "helpers": [ + "get_folly_config", + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": "ReactNativeMaps", + "name": "react-native-maps" + }, + "shim": { + "headerDir": null, + "moduleName": "ReactNativeMaps", + "name": "react-native-maps" + } + }, + "reduced": { + "refused": "/node_modules/react-native-maps/react-native-maps.podspec: `ss.compiler_flags = folly_compiler_flags` cannot be evaluated: it uses `folly_compiler_flags`, which is assigned `folly_config[:compiler_flags]`, which the reader cannot evaluate (`folly_config`, which is assigned `get_folly_config()`, which the reader cannot evaluate (the method call `get_folly_config(...)`)); `ss.compiler_flags = folly_compiler_flags` cannot be evaluated: it uses `folly_compiler_flags`, which is assigned `folly_config[:compiler_flags]`, which the reader cannot evaluate (`folly_config`, which is assigned `get_folly_config()`, which the reader cannot evaluate (the method call `get_folly_config(...)`)); `ss.compiler_flags = folly_compiler_flags + ' -DHAVE_GOOGLE_MAPS=1 -DHAVE_GOOGLE_MAPS_UTILS=1'` cannot be evaluated: it uses `folly_compiler_flags`, which is assigned `folly_config[:compiler_flags]`, which the reader cannot evaluate (`folly_config`, which is assigned `get_folly_config()`, which the reader cannot evaluate (the method call `get_folly_config(...)`)). The podspec reader evaluates locals, string interpolation, arrays, ENV['...'], package.json reads, comparisons, ternaries and if/unless blocks; building from the part it could read would leave some of the library's files or settings out of its target. Install Ruby (sudo apt install ruby) so rn-xtool reads the podspec as CocoaPods does, or give the library a Package.swift of its own." + }, + "shim": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "react-native-maps/Generated" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": "ReactNativeMaps", + "name": "react-native-maps", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "ios/AirMaps/UIView+AirMap.h", + "ios/AirMaps/RCTConvert+AirMap.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/AirMaps/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": { + "Maps": [ + "react-native-maps/Generated" + ] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "The podspec sets script_phases, which a CocoaPods build applies and rn-xtool's scaffold does not.", + "Dropped Folly define(s) FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1, FOLLY_CFG_NO_COROUTINES=1, FOLLY_HAVE_CLOCK_GETTIME=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-mmkv@4.3.2@rn-0.88.1/NitroMmkv.podspec.json b/tests/fixtures/podspec-sweep/react-native-mmkv@4.3.2@rn-0.88.1/NitroMmkv.podspec.json new file mode 100644 index 0000000..a3e2661 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-mmkv@4.3.2@rn-0.88.1/NitroMmkv.podspec.json @@ -0,0 +1,110 @@ +{ + "env": [ + "MMKV_LOG_LEVEL" + ], + "helpers": [ + "install_modules_dependencies", + "min_ios_version_supported" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "NitroMmkv" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "NitroMmkv" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "MMKVCore", + "React-jsi", + "React-callinvoker" + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "requiresArc": false, + "sourceFiles": [ + "ios/**/*.{swift}", + "ios/**/*.{m,mm}", + "cpp/**/*.{hpp,cpp}" + ], + "warnings": [ + "Left out of s.pod_target_xcconfig GCC_PREPROCESSOR_DEFINITIONS: `gcc_preprocessor_defs`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [ + "-x", + "objective-c++" + ], + "dependencies": [ + "MMKVCore", + "NitroModules", + "React-jsi", + "React-callinvoker" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "${PODS_ROOT}/RCT-Folly" + ], + "libraries": [], + "moduleName": null, + "name": "NitroMmkv", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [ + "nitrogen/generated/ios/c++/**/*.{h,hpp}", + "nitrogen/generated/shared/**/views/**/*" + ], + "publicHeaderFiles": [ + "nitrogen/generated/shared/**/*.{h,hpp}", + "nitrogen/generated/ios/NitroMmkv-Swift-Cxx-Bridge.hpp" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{swift}", + "ios/**/*.{m,mm}", + "cpp/**/*.{hpp,cpp}", + "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}", + "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [ + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_CFG_NO_COROUTINES — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "NitroModules" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-nitro-modules@0.37.2@rn-0.88.1/NitroModules.podspec.json b/tests/fixtures/podspec-sweep/react-native-nitro-modules@0.37.2@rn-0.88.1/NitroModules.podspec.json new file mode 100644 index 0000000..1f985ad --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-nitro-modules@0.37.2@rn-0.88.1/NitroModules.podspec.json @@ -0,0 +1,110 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies", + "min_ios_version_supported" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "NitroModules" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "NitroModules" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "Left out s.pod_target_xcconfig = xcconfig: the podspec reader cannot evaluate it (`xcconfig`, which is set under `(react_native_version < 80)`, a condition the reader cannot evaluate); CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-callinvoker" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "NitroModules", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "cpp/core/core/AnyMap.hpp", + "cpp/core/core/ArrayBuffer.hpp", + "cpp/core/core/HybridObject.hpp", + "cpp/core/core/Null.hpp", + "cpp/core/core/Promise.hpp", + "cpp/core/entrypoint/HybridNitroModulesProxy.hpp", + "cpp/core/entrypoint/InstallNitro.hpp", + "cpp/core/registry/HybridObjectRegistry.hpp", + "cpp/core/jsi/JSIConverter.hpp", + "cpp/core/jsi/JSIHelpers.hpp", + "cpp/core/platform/NitroLogger.hpp", + "cpp/core/threading/Dispatcher.hpp", + "cpp/core/threading/ThreadPool.hpp", + "cpp/core/utils/JSCallback.hpp", + "cpp/core/utils/FastVectorCopy.hpp", + "cpp/core/utils/NitroHash.hpp", + "cpp/core/utils/NitroDefines.hpp", + "cpp/core/utils/PropNameIDCache.hpp", + "cpp/views/CachedProp.hpp", + "cpp/views/RawPropsCompat.hpp", + "cpp/views/ReactProp.hpp", + "cpp/views/ViewComponentDescriptor.hpp", + "cpp/views/ViewPropsHolderState.hpp", + "apple/core/core/ArrayBufferHolder.hpp", + "apple/core/core/PromiseHolder.hpp", + "apple/core/utils/AnyMapUtils.hpp", + "apple/core/utils/Result.hpp", + "apple/core/utils/DateToChronoDate.hpp", + "apple/core/utils/RuntimeError.hpp", + "apple/core/utils/SwiftClosure.hpp" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "cpp/**/*.{h,hpp}", + "cpp/**/*.{c,cpp}", + "apple/**/*.{h,hpp}", + "apple/**/*.{c,cpp}", + "apple/**/*.{m,mm}", + "apple/**/*.swift" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-pager-view@10.0.0@rn-0.88.1/react-native-pager-view.podspec.json b/tests/fixtures/podspec-sweep/react-native-pager-view@10.0.0@rn-0.88.1/react-native-pager-view.podspec.json new file mode 100644 index 0000000..53f201a --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-pager-view@10.0.0@rn-0.88.1/react-native-pager-view.podspec.json @@ -0,0 +1,74 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies", + "min_ios_version_supported" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-pager-view" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-pager-view" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "SwiftUIIntrospect" + ], + "excludeFiles": [ + "ios/Package.swift" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "react-native-pager-view", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-permissions@5.6.3@rn-0.88.1/RNPermissions.podspec.json b/tests/fixtures/podspec-sweep/react-native-permissions@5.6.3@rn-0.88.1/RNPermissions.podspec.json new file mode 100644 index 0000000..56c4af3 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-permissions@5.6.3@rn-0.88.1/RNPermissions.podspec.json @@ -0,0 +1,72 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNPermissions" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNPermissions" + } + }, + "reduced": { + "differs": { + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNPermissions", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/*.{h,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.9" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-purchases@11.0.1@rn-0.88.1/RNPurchases.podspec.json b/tests/fixtures/podspec-sweep/react-native-purchases@11.0.1@rn-0.88.1/RNPurchases.podspec.json new file mode 100644 index 0000000..ee9035e --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-purchases@11.0.1@rn-0.88.1/RNPurchases.podspec.json @@ -0,0 +1,73 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNPurchases" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNPurchases" + } + }, + "reduced": { + "differs": { + "requiresArc": false + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core", + "PurchasesHybridCommon" + ], + "excludeFiles": [ + "ios/Purchases.framework", + "ios/PurchasesHybridCommon.framework", + "ios/PurchasesHybridCommonUI.framework" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNPurchases", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [ + "5.7" + ], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.86.3/RNReanimated.podspec.json b/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.86.3/RNReanimated.podspec.json new file mode 100644 index 0000000..2cc8919 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.86.3/RNReanimated.podspec.json @@ -0,0 +1,158 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_REANIMATED_PROFILING" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "reanimated", + "moduleName": null, + "name": "RNReanimated" + }, + "shim": { + "headerDir": "reanimated", + "moduleName": null, + "name": "RNReanimated" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/reanimated" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/Headers/Public/RNWorklets", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "REANIMATED_VERSION", + "value": "4.7.1" + } + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{example_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.xcconfig OTHER_CFLAGS: `#{compilation_metadata_generation_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.xcconfig OTHER_CFLAGS: `#{ReanimatedUtils.get_static_feature_flags()}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [ + "-Wno-documentation" + ], + "dependencies": [ + "RNWorklets", + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "reanimated", + "headerDirScopes": [ + { + "headerDir": "reanimated", + "headerMappingsDirs": [ + "Common/cpp/reanimated", + "apple/reanimated" + ], + "sourceFiles": [ + "Common/cpp/reanimated/**/*.{cpp,h}", + "apple/reanimated/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/reanimated", + "headerMappingsDirs": [ + "Common/cpp/reanimated", + "apple/reanimated", + "Common/NativeView" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/Headers/Public/RNWorklets", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNReanimated", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REANIMATED_VERSION", + "value": "4.7.1" + }, + { + "config": null, + "name": "REANIMATED_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][DISABLE_COMMIT_PAUSING_MECHANISM:false][ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS:false][IOS_SYNCHRONOUSLY_UPDATE_UI_PROPS:false][EXPERIMENTAL_CSS_ANIMATIONS_FOR_SVG_COMPONENTS:true][IOS_CSS_CORE_ANIMATION:false][ANDROID_CSS_PLATFORM_TRANSITIONS:false][USE_COMMIT_HOOK_ONLY_FOR_REACT_COMMITS:true][ENABLE_SHARED_ELEMENT_TRANSITIONS:false][USE_LEGACY_LAYOUT_ANIMATIONS_PROXY:false][FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS:true][USE_ANIMATION_BACKEND:false]\"" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/reanimated/**/*.h", + "apple/reanimated/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/reanimated/**/*.{cpp,h}", + "apple/reanimated/**/*.{mm,h,m}", + "Common/NativeView/**/*.{mm,h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [], + "view": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.88.1/RNReanimated.podspec.json b/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.88.1/RNReanimated.podspec.json new file mode 100644 index 0000000..2cc8919 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-reanimated@4.7.1@rn-0.88.1/RNReanimated.podspec.json @@ -0,0 +1,158 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_REANIMATED_PROFILING" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "reanimated", + "moduleName": null, + "name": "RNReanimated" + }, + "shim": { + "headerDir": "reanimated", + "moduleName": null, + "name": "RNReanimated" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/reanimated" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/Headers/Public/RNWorklets", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "REANIMATED_VERSION", + "value": "4.7.1" + } + ], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{example_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.xcconfig OTHER_CFLAGS: `#{compilation_metadata_generation_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.xcconfig OTHER_CFLAGS: `#{ReanimatedUtils.get_static_feature_flags()}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [ + "-Wno-documentation" + ], + "dependencies": [ + "RNWorklets", + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "reanimated", + "headerDirScopes": [ + { + "headerDir": "reanimated", + "headerMappingsDirs": [ + "Common/cpp/reanimated", + "apple/reanimated" + ], + "sourceFiles": [ + "Common/cpp/reanimated/**/*.{cpp,h}", + "apple/reanimated/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/reanimated", + "headerMappingsDirs": [ + "Common/cpp/reanimated", + "apple/reanimated", + "Common/NativeView" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/Headers/Public/RNWorklets", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNReanimated", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REANIMATED_VERSION", + "value": "4.7.1" + }, + { + "config": null, + "name": "REANIMATED_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][DISABLE_COMMIT_PAUSING_MECHANISM:false][ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS:false][IOS_SYNCHRONOUSLY_UPDATE_UI_PROPS:false][EXPERIMENTAL_CSS_ANIMATIONS_FOR_SVG_COMPONENTS:true][IOS_CSS_CORE_ANIMATION:false][ANDROID_CSS_PLATFORM_TRANSITIONS:false][USE_COMMIT_HOOK_ONLY_FOR_REACT_COMMITS:true][ENABLE_SHARED_ELEMENT_TRANSITIONS:false][USE_LEGACY_LAYOUT_ANIMATIONS_PROXY:false][FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS:true][USE_ANIMATION_BACKEND:false]\"" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/reanimated/**/*.h", + "apple/reanimated/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/reanimated/**/*.{cpp,h}", + "apple/reanimated/**/*.{mm,h,m}", + "Common/NativeView/**/*.{mm,h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [], + "view": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.86.3/react-native-safe-area-context.podspec.json b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.86.3/react-native-safe-area-context.podspec.json new file mode 100644 index 0000000..1cc8669 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.86.3/react-native-safe-area-context.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core", + "react-native-safe-area-context/common" + ], + "excludeFiles": [ + "ios/Fabric" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "react/renderer/components/safeareacontext", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-safe-area-context", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}", + "ios/Fabric/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [], + "fabric": [ + "react-native-safe-area-context/common" + ] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "react-native-safe-area-context/common" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.87.1/react-native-safe-area-context.podspec.json b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.87.1/react-native-safe-area-context.podspec.json new file mode 100644 index 0000000..1cc8669 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.87.1/react-native-safe-area-context.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core", + "react-native-safe-area-context/common" + ], + "excludeFiles": [ + "ios/Fabric" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "react/renderer/components/safeareacontext", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-safe-area-context", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}", + "ios/Fabric/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [], + "fabric": [ + "react-native-safe-area-context/common" + ] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "react-native-safe-area-context/common" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.88.1/react-native-safe-area-context.podspec.json b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.88.1/react-native-safe-area-context.podspec.json new file mode 100644 index 0000000..1cc8669 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.10.1@rn-0.88.1/react-native-safe-area-context.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core", + "react-native-safe-area-context/common" + ], + "excludeFiles": [ + "ios/Fabric" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "react/renderer/components/safeareacontext", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-safe-area-context", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}", + "ios/Fabric/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [], + "fabric": [ + "react-native-safe-area-context/common" + ] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "react-native-safe-area-context/common" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.11.1@rn-0.88.1/react-native-safe-area-context.podspec.json b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.11.1@rn-0.88.1/react-native-safe-area-context.podspec.json new file mode 100644 index 0000000..1cc8669 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-safe-area-context@5.11.1@rn-0.88.1/react-native-safe-area-context.podspec.json @@ -0,0 +1,97 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "react-native-safe-area-context" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core", + "react-native-safe-area-context/common" + ], + "excludeFiles": [ + "ios/Fabric" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "react/renderer/components/safeareacontext", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-safe-area-context", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}", + "ios/Fabric/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [], + "fabric": [ + "react-native-safe-area-context/common" + ] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "react-native-safe-area-context/common" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.24.0@rn-0.85.0/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.24.0@rn-0.85.0/RNScreens.podspec.json new file mode 100644 index 0000000..2e6056a --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-screens@4.24.0@rn-0.85.0/RNScreens.podspec.json @@ -0,0 +1,93 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED", + "RNS_DEBUG_LOGGING", + "RNS_GAMMA_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-RCTImage" + ], + "excludeFiles": [ + "ios/gamma/**/*.{h,m,mm,cpp,swift}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnscreens", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNScreens", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp,swift}", + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.86.3/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.86.3/RNScreens.podspec.json new file mode 100644 index 0000000..8af6867 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.86.3/RNScreens.podspec.json @@ -0,0 +1,93 @@ +{ + "env": [ + "RNS_DEBUG_LOGGING", + "RNS_GAMMA_ENABLED", + "RNS_USE_CXXBRIDGE" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-RCTImage" + ], + "excludeFiles": [ + "ios/gamma/**/*.{h,m,mm,cpp}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnscreens", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNScreens", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}", + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.87.1/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.87.1/RNScreens.podspec.json new file mode 100644 index 0000000..8af6867 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-screens@4.30.0@rn-0.87.1/RNScreens.podspec.json @@ -0,0 +1,93 @@ +{ + "env": [ + "RNS_DEBUG_LOGGING", + "RNS_GAMMA_ENABLED", + "RNS_USE_CXXBRIDGE" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-RCTImage" + ], + "excludeFiles": [ + "ios/gamma/**/*.{h,m,mm,cpp}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnscreens", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNScreens", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}", + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-screens@4.30.1@rn-0.88.1/RNScreens.podspec.json b/tests/fixtures/podspec-sweep/react-native-screens@4.30.1@rn-0.88.1/RNScreens.podspec.json new file mode 100644 index 0000000..8af6867 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-screens@4.30.1@rn-0.88.1/RNScreens.podspec.json @@ -0,0 +1,93 @@ +{ + "env": [ + "RNS_DEBUG_LOGGING", + "RNS_GAMMA_ENABLED", + "RNS_USE_CXXBRIDGE" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNScreens" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-RCTImage" + ], + "excludeFiles": [ + "ios/gamma/**/*.{h,m,mm,cpp}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnscreens", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNScreens", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm,cpp}", + "common/cpp/**/*.{cpp,h}", + "cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.86.3/RNSVG.podspec.json b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.86.3/RNSVG.podspec.json new file mode 100644 index 0000000..9075d81 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.86.3/RNSVG.podspec.json @@ -0,0 +1,94 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=86 from the installed React Native version (0.86.3) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "**/*.macos.{h,m,mm}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnsvg", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNSVG", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "86" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.87.1/RNSVG.podspec.json b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.87.1/RNSVG.podspec.json new file mode 100644 index 0000000..d443a46 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-svg@15.16.0@rn-0.87.1/RNSVG.podspec.json @@ -0,0 +1,94 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=87 from the installed React Native version (0.87.1) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "**/*.macos.{h,m,mm}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnsvg", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNSVG", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "87" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-svg@15.16.1@rn-0.88.1/RNSVG.podspec.json b/tests/fixtures/podspec-sweep/react-native-svg@15.16.1@rn-0.88.1/RNSVG.podspec.json new file mode 100644 index 0000000..ab74773 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-svg@15.16.1@rn-0.88.1/RNSVG.podspec.json @@ -0,0 +1,94 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNSVG" + } + }, + "reduced": { + "differs": { + "warnings": [ + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=88 from the installed React Native version (0.88.1) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [ + "**/*.macos.{h,m,mm}" + ], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [ + { + "headerDir": "rnsvg", + "headerMappingsDirs": [], + "sourceFiles": [ + "common/cpp/**/*.{cpp,h}" + ] + } + ], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/common/cpp" + ], + "libraries": [], + "moduleName": null, + "name": "RNSVG", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "88" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "common/cpp/**/*.{cpp,h}" + ], + "spmDependencies": [], + "subspecDependencies": { + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-view-shot@6.2.1@rn-0.88.1/react-native-view-shot.podspec.json b/tests/fixtures/podspec-sweep/react-native-view-shot@6.2.1@rn-0.88.1/react-native-view-shot.podspec.json new file mode 100644 index 0000000..6906d0d --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-view-shot@6.2.1@rn-0.88.1/react-native-view-shot.podspec.json @@ -0,0 +1,69 @@ +{ + "env": [], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/**/*.{h,m,mm}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-vision-camera@4.7.3@rn-0.88.1/VisionCamera.podspec.json b/tests/fixtures/podspec-sweep/react-native-vision-camera@4.7.3@rn-0.88.1/VisionCamera.podspec.json new file mode 100644 index 0000000..d33e007 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-vision-camera@4.7.3@rn-0.88.1/VisionCamera.podspec.json @@ -0,0 +1,126 @@ +{ + "env": [], + "helpers": [], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "VisionCamera" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "VisionCamera" + } + }, + "reduced": { + "differs": { + "dependencies": [ + "React-Core", + "VisionCamera/FrameProcessors", + "React", + "React-callinvoker", + "react-native-worklets-core" + ], + "preprocessorDefines": [], + "publicHeaderFiles": [ + "ios/React/CameraBridge.h", + "ios/FrameProcessors/Frame.h", + "ios/FrameProcessors/FrameProcessor.h", + "ios/FrameProcessors/FrameProcessorPlugin.h", + "ios/FrameProcessors/FrameProcessorPluginRegistry.h", + "ios/FrameProcessors/SharedArray.h", + "ios/FrameProcessors/VisionCameraProxyDelegate.h", + "ios/FrameProcessors/VisionCameraProxyHolder.h", + "ios/FrameProcessors/VisionCameraInstaller.h" + ], + "sourceFiles": [ + "ios/Core/**/*.swift", + "ios/React/**/*.swift", + "ios/React/**/*.{h,m}", + "ios/FrameProcessors/**/*.{h,m,mm}" + ], + "subspecDependencies": { + "Core": [], + "FrameProcessors": [ + "React", + "React-callinvoker", + "react-native-worklets-core" + ], + "React": [ + "React-Core", + "VisionCamera/FrameProcessors" + ] + }, + "swiftConditions": [], + "warnings": [ + "Left out of s.pod_target_xcconfig GCC_PREPROCESSOR_DEFINITIONS: `#{enableFrameProcessors}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig SWIFT_ACTIVE_COMPILATION_CONDITIONS: `#{enableFrameProcessors ? \"VISION_CAMERA_ENABLE_FRAME_PROCESSORS\" : \"\"}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of core.pod_target_xcconfig SWIFT_ACTIVE_COMPILATION_CONDITIONS: `#{enableLocation ? \"VISION_CAMERA_ENABLE_LOCATION\" : \"\"}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-Core" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "VisionCamera", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "VISION_CAMERA_ENABLE_FRAME_PROCESSORS", + "value": "false" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "ios/React/CameraBridge.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "ios/Core/**/*.swift", + "ios/React/**/*.swift", + "ios/React/**/*.{h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "Core": [], + "React": [ + "React-Core" + ] + }, + "swiftConditions": [ + "VISION_CAMERA_ENABLE_LOCATION" + ], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": false, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.86.3/react-native-webview.podspec.json b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.86.3/react-native-webview.podspec.json new file mode 100644 index 0000000..29304e4 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.86.3/react-native-webview.podspec.json @@ -0,0 +1,95 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.87.1/react-native-webview.podspec.json b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.87.1/react-native-webview.podspec.json new file mode 100644 index 0000000..29304e4 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.87.1/react-native-webview.podspec.json @@ -0,0 +1,95 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.88.1/react-native-webview.podspec.json b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.88.1/react-native-webview.podspec.json new file mode 100644 index 0000000..29304e4 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-webview@14.0.1@rn-0.88.1/react-native-webview.podspec.json @@ -0,0 +1,95 @@ +{ + "env": [ + "RCT_NEW_ARCH_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "" + } + }, + "reduced": { + "differs": { + "compilerFlags": [ + "-Wno-comma", + "-Wno-shorten-64-to-32" + ], + "dependencies": [ + "React-RCTFabric", + "React-Codegen", + "RCT-Folly", + "RCTRequired", + "RCTTypeSafety", + "ReactCommon/turbomodule/core" + ], + "headerSearchPaths": [ + "$(PODS_ROOT)/boost" + ], + "preprocessorDefines": [ + { + "config": null, + "name": "RCT_NEW_ARCH_ENABLED", + "value": "1" + } + ], + "requiresArc": false, + "warnings": [ + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Dropped Folly define(s) FOLLY_NO_CONFIG, FOLLY_MOBILE=1, FOLLY_USE_LIBCPP=1 — the prebuilt React Native headers ship folly-config.h, and defining them without the full CocoaPods set breaks the build." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "", + "partial": false, + "preprocessorDefines": [], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm,swift}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.86.3/RNWorklets.podspec.json b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.86.3/RNWorklets.podspec.json new file mode 100644 index 0000000..c99b614 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.86.3/RNWorklets.podspec.json @@ -0,0 +1,173 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_WORKLETS_PROFILING", + "RCT_HERMES_V1_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + }, + "shim": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.0" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "requiresArc": false, + "warnings": [ + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{compilation_metadata_generation_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "worklets", + "headerDirScopes": [ + { + "headerDir": "worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNWorklets", + "partial": false, + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][IOS_DYNAMIC_FRAMERATE_ENABLED:true][ENABLE_CROSS_RUNTIME_STACK_TRACES:true]\"" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.0" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/worklets/**/*.h", + "apple/worklets/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.88.1/RNWorklets.podspec.json b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.88.1/RNWorklets.podspec.json new file mode 100644 index 0000000..c99b614 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.0@rn-0.88.1/RNWorklets.podspec.json @@ -0,0 +1,173 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_WORKLETS_PROFILING", + "RCT_HERMES_V1_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + }, + "shim": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.0" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "requiresArc": false, + "warnings": [ + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{compilation_metadata_generation_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "worklets", + "headerDirScopes": [ + { + "headerDir": "worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNWorklets", + "partial": false, + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][IOS_DYNAMIC_FRAMERATE_ENABLED:true][ENABLE_CROSS_RUNTIME_STACK_TRACES:true]\"" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.0" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/worklets/**/*.h", + "apple/worklets/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-worklets@0.13.1@rn-0.88.1/RNWorklets.podspec.json b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.1@rn-0.88.1/RNWorklets.podspec.json new file mode 100644 index 0000000..e42015d --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-worklets@0.13.1@rn-0.88.1/RNWorklets.podspec.json @@ -0,0 +1,173 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_WORKLETS_PROFILING", + "RCT_HERMES_V1_ENABLED" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + }, + "shim": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.1" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "requiresArc": false, + "warnings": [ + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{compilation_metadata_generation_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "worklets", + "headerDirScopes": [ + { + "headerDir": "worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNWorklets", + "partial": false, + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][IOS_DYNAMIC_FRAMERATE_ENABLED:true][ENABLE_CROSS_RUNTIME_STACK_TRACES:true]\"" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.13.1" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/worklets/**/*.h", + "apple/worklets/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-worklets@0.8.1@rn-0.85.0/RNWorklets.podspec.json b/tests/fixtures/podspec-sweep/react-native-worklets@0.8.1@rn-0.85.0/RNWorklets.podspec.json new file mode 100644 index 0000000..f8e49be --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-worklets@0.8.1@rn-0.85.0/RNWorklets.podspec.json @@ -0,0 +1,186 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_WORKLETS_PROFILING", + "RCT_HERMES_V1_ENABLED", + "RCT_NEW_ARCH_ENABLED", + "USE_HERMES" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + }, + "shim": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.8.1" + }, + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "85" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "requiresArc": false, + "warnings": [ + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{fetch_preview_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=85 from the installed React Native version (0.85.0) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "worklets", + "headerDirScopes": [ + { + "headerDir": "worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNWorklets", + "partial": false, + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][FETCH_PREVIEW_ENABLED:false][IOS_DYNAMIC_FRAMERATE_ENABLED:true]\"" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.8.1" + }, + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "85" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/worklets/**/*.h", + "apple/worklets/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "React-hermes" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/fixtures/podspec-sweep/react-native-worklets@0.8.3@rn-0.85.0/RNWorklets.podspec.json b/tests/fixtures/podspec-sweep/react-native-worklets@0.8.3@rn-0.85.0/RNWorklets.podspec.json new file mode 100644 index 0000000..3b2aaf1 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-worklets@0.8.3@rn-0.85.0/RNWorklets.podspec.json @@ -0,0 +1,186 @@ +{ + "env": [ + "IS_REANIMATED_EXAMPLE_APP", + "IS_WORKLETS_PROFILING", + "RCT_HERMES_V1_ENABLED", + "RCT_NEW_ARCH_ENABLED", + "USE_HERMES" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + }, + "shim": { + "headerDir": "worklets", + "moduleName": null, + "name": "RNWorklets" + } + }, + "reduced": { + "differs": { + "headerMappingsDirs": [ + "Common/cpp/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + ",", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine" + ], + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.8.3" + }, + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "85" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "requiresArc": false, + "warnings": [ + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{feature_flags}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Left out of s.pod_target_xcconfig OTHER_CFLAGS: `#{fetch_preview_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "Subspecs detected — regex parser merges their source/exclude/header, framework, dependency and define fields (default_subspecs honoured); nested subspecs, `{ }` brace blocks and heredocs are not understood. Install Ruby (`sudo apt install ruby`) so rn-xtool reads the podspec as CocoaPods does.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby.", + "Resolved interpolated define(s) REACT_NATIVE_MINOR_VERSION=85 from the installed React Native version (0.85.0) — the regex parser cannot evaluate the Ruby expression." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "React-jsi", + "React-hermes" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": "worklets", + "headerDirScopes": [ + { + "headerDir": "worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ] + } + ], + "headerMappingsDir": "Common/cpp/worklets", + "headerMappingsDirs": [ + "Common/cpp/worklets", + "apple/worklets" + ], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/ReactCommon", + "$(PODS_TARGET_SRCROOT)", + "$(PODS_ROOT)/RCT-Folly", + "$(PODS_ROOT)/boost", + "$(PODS_ROOT)/boost-for-react-native", + "$(PODS_ROOT)/DoubleConversion", + "$(PODS_ROOT)/Headers/Private/React-Core", + "$(PODS_ROOT)/Headers/Private/Yoga", + "$(PODS_ROOT)/glog", + "$(PODS_ROOT)/Headers/Public/React-hermes", + "$(PODS_ROOT)/Headers/Public/hermes-engine", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon", + "$(PODS_ROOT)/../../node_modules/react-native/ReactCommon/jsitooling" + ], + "libraries": [], + "moduleName": null, + "name": "RNWorklets", + "partial": false, + "preprocessorDefines": [ + { + "config": "debug", + "name": "HERMES_ENABLE_DEBUGGER", + "value": "1" + }, + { + "config": null, + "name": "WORKLETS_FEATURE_FLAGS", + "value": "\"[RUNTIME_TEST_FLAG:false][FETCH_PREVIEW_ENABLED:false][IOS_DYNAMIC_FRAMERATE_ENABLED:true]\"" + }, + { + "config": null, + "name": "WORKLETS_VERSION", + "value": "0.8.3" + }, + { + "config": null, + "name": "REACT_NATIVE_MINOR_VERSION", + "value": "85" + }, + { + "config": null, + "name": "HERMES_V1_ENABLED", + "value": null + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [ + "Common/cpp/worklets/**/*.h", + "apple/worklets/**/*.h" + ], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "Common/cpp/worklets/**/*.{cpp,h}", + "apple/worklets/**/*.{mm,h,m}" + ], + "spmDependencies": [], + "subspecDependencies": { + "apple": [], + "common": [] + }, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "React-hermes" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/podspec-sweep.json b/tests/podspec-sweep.json index cda2614..708641a 100644 --- a/tests/podspec-sweep.json +++ b/tests/podspec-sweep.json @@ -1,5 +1,78 @@ [ + { "spec": "@expo/dom-webview@57.0.1", "rn": "react-native@0.86.3" }, + { "spec": "@expo/dom-webview@58.0.2", "rn": "react-native@0.88.1" }, + { "spec": "@expo/log-box@57.0.4", "rn": "react-native@0.86.3" }, + { "spec": "@expo/log-box@58.0.13", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-async-storage/async-storage@3.1.1", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-clipboard/clipboard@1.16.3", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-community/datetimepicker@9.2.1", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-community/datetimepicker@9.3.0", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-community/netinfo@12.0.1", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-community/slider@5.2.2", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-firebase/app@27.1.0", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-google-signin/google-signin@17.0.0", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-masked-view/masked-view@0.3.2", "rn": "react-native@0.88.1" }, + { "spec": "@react-native-picker/picker@2.11.4", "rn": "react-native@0.88.1" }, + { "spec": "@sentry/react-native@8.34.0", "rn": "react-native@0.88.1" }, + { "spec": "@shopify/react-native-skia@2.14.0", "rn": "react-native@0.88.1" }, + { "spec": "expo-asset@57.0.20", "rn": "react-native@0.86.3" }, + { "spec": "expo-asset@58.0.19", "rn": "react-native@0.88.1" }, + { "spec": "expo-constants@57.0.22", "rn": "react-native@0.86.3" }, + { "spec": "expo-constants@58.0.14", "rn": "react-native@0.88.1" }, + { "spec": "expo-file-system@57.0.7", "rn": "react-native@0.86.3" }, + { "spec": "expo-file-system@58.0.13", "rn": "react-native@0.88.1" }, + { "spec": "expo-font@57.0.4", "rn": "react-native@0.86.3" }, + { "spec": "expo-font@58.0.11", "rn": "react-native@0.88.1" }, + { "spec": "expo-glass-effect@58.0.5", "rn": "react-native@0.88.1" }, + { "spec": "expo-haptics@58.0.7", "rn": "react-native@0.88.1" }, + { "spec": "expo-keep-awake@57.0.2", "rn": "react-native@0.86.3" }, + { "spec": "expo-keep-awake@58.0.3", "rn": "react-native@0.88.1" }, + { "spec": "expo-linking@58.0.15", "rn": "react-native@0.88.1" }, + { "spec": "expo-modules-core@57.0.24", "rn": "react-native@0.86.3", "with": ["react-native-worklets@0.13.0"] }, + { "spec": "expo-modules-core@58.0.28", "rn": "react-native@0.88.1", "with": ["react-native-worklets@0.13.1"] }, + { "spec": "expo-router@58.0.28", "rn": "react-native@0.88.1" }, + { "spec": "expo-status-bar@58.0.4", "rn": "react-native@0.88.1" }, + { "spec": "expo@57.0.31", "rn": "react-native@0.86.3" }, + { "spec": "expo@58.0.21", "rn": "react-native@0.88.1" }, + { "spec": "lottie-react-native@7.5.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-blob-util@0.25.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-device-info@15.0.2", "rn": "react-native@0.88.1" }, + { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.86.3" }, + { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.87.1" }, + { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.88.1" }, { "spec": "react-native-gesture-handler@3.4.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-gesture-handler@3.5.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-get-random-values@2.1.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-keyboard-controller@1.23.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-maps@1.29.11", "rn": "react-native@0.88.1" }, + { "spec": "react-native-mmkv@4.3.2", "rn": "react-native@0.88.1" }, + { "spec": "react-native-nitro-modules@0.37.2", "rn": "react-native@0.88.1" }, + { "spec": "react-native-pager-view@10.0.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-permissions@5.6.3", "rn": "react-native@0.88.1" }, + { "spec": "react-native-purchases@11.0.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-reanimated@4.7.1", "rn": "react-native@0.86.3", "with": ["react-native-worklets@0.13.0", "semver@7.8.5"] }, + { "spec": "react-native-reanimated@4.7.1", "rn": "react-native@0.88.1", "with": ["react-native-worklets@0.13.1", "semver@7.8.5"] }, + { "spec": "react-native-safe-area-context@5.10.1", "rn": "react-native@0.86.3" }, + { "spec": "react-native-safe-area-context@5.10.1", "rn": "react-native@0.87.1" }, + { "spec": "react-native-safe-area-context@5.10.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-safe-area-context@5.11.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-screens@4.24.0", "rn": "react-native@0.85.0" }, + { "spec": "react-native-screens@4.30.0", "rn": "react-native@0.86.3" }, + { "spec": "react-native-screens@4.30.0", "rn": "react-native@0.87.1" }, { "spec": "react-native-screens@4.30.0", "rn": "react-native@0.88.1" }, - { "spec": "react-native-svg@15.16.0", "rn": "react-native@0.88.1" } + { "spec": "react-native-screens@4.30.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-svg@15.16.0", "rn": "react-native@0.86.3" }, + { "spec": "react-native-svg@15.16.0", "rn": "react-native@0.87.1" }, + { "spec": "react-native-svg@15.16.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-svg@15.16.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-view-shot@6.2.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-vision-camera@4.7.3", "rn": "react-native@0.88.1" }, + { "spec": "react-native-webview@14.0.1", "rn": "react-native@0.86.3" }, + { "spec": "react-native-webview@14.0.1", "rn": "react-native@0.87.1" }, + { "spec": "react-native-webview@14.0.1", "rn": "react-native@0.88.1" }, + { "spec": "react-native-worklets@0.13.0", "rn": "react-native@0.86.3", "with": ["semver@7.8.5"] }, + { "spec": "react-native-worklets@0.13.0", "rn": "react-native@0.88.1", "with": ["semver@7.8.5"] }, + { "spec": "react-native-worklets@0.13.1", "rn": "react-native@0.88.1", "with": ["semver@7.8.5"] }, + { "spec": "react-native-worklets@0.8.1", "rn": "react-native@0.85.0", "with": ["semver@7.8.5"] }, + { "spec": "react-native-worklets@0.8.3", "rn": "react-native@0.85.0", "with": ["semver@7.8.5"] } ] diff --git a/tests/tarballs.json b/tests/tarballs.json index 4c49fa3..3c9e258 100644 --- a/tests/tarballs.json +++ b/tests/tarballs.json @@ -78,5 +78,310 @@ "spec": "react-native-gesture-handler@2.32.0", "file": "react-native-gesture-handler-2.32.0.tgz", "integrity": "sha512-uYIMOKlKENORq2SABE+jIjbPU+h5I/sQKcq2v16zRq848nwEp1fWRVwML4QWqijc8UcXJC25o54S8GQd4Mf2OA==" + }, + { + "spec": "react-native-safe-area-context@5.11.1", + "file": "react-native-safe-area-context-5.11.1.tgz", + "integrity": "sha512-yCltXXwhwp42vMqfhAsH5BWgAysbLNgwfn3PDwNpOn/CgwfM+eMWgScZIbHbMzJYNLi5bKJEOIUEG4RwKNiECA==" + }, + { + "spec": "react-native-screens@4.30.1", + "file": "react-native-screens-4.30.1.tgz", + "integrity": "sha512-wLzZSQpvMx3FxIlDnb6raDJjsv2x45tFLGFz8RFUvxHzsKU9dWOkZYv9fy2siWtFf3eWGcRh66hL+o+dHhRJLQ==" + }, + { + "spec": "react-native-reanimated@4.7.1", + "file": "react-native-reanimated-4.7.1.tgz", + "integrity": "sha512-HviDFSZ6V4KTRsrLS6hRbBJ4j63l/L8a5az0EoWdJwaMLYnBNyYISTDxwXpEYkMbAbLzCMCviIdiOxXHYQWcNA==" + }, + { + "spec": "react-native-gesture-handler@3.5.0", + "file": "react-native-gesture-handler-3.5.0.tgz", + "integrity": "sha512-bm8yepwMBUhEOSeU7WQbNNrstD0Hbv6i+XsApARBJSlb+WlRvyaQsobi+tZ5Uyr5kDVgXzg6kPb+CWY9zvyfEw==" + }, + { + "spec": "react-native-worklets@0.13.1", + "file": "react-native-worklets-0.13.1.tgz", + "integrity": "sha512-sX55Vx89/Y9uJmvAbAGoHXBZvCWXtYPGWPJ9Z9yl0h76mP9A10ULlSrixzGqBFLXeQMBpIpyJEhWpzXP7GG6YA==" + }, + { + "spec": "react-native-svg@15.16.1", + "file": "react-native-svg-15.16.1.tgz", + "integrity": "sha512-Y4hCfg0o9ovGJYnNIySph5xWGqzawhW7MB2AjMUTpqJkrtPAx5XCeSk+jRMux2hanUvi9KvdVf2aZu0OFWtjgw==" + }, + { + "spec": "@react-native-async-storage/async-storage@3.1.1", + "file": "react-native-async-storage-async-storage-3.1.1.tgz", + "integrity": "sha512-z+PnLz1n6ECKhgoHZHkfc+dijXZEyZnNFSajbtE0NEbsJhmX8x9GlOeiMQIKX2E4DUqPSgfIh4FYBv1M49KgPQ==" + }, + { + "spec": "@react-native-masked-view/masked-view@0.3.2", + "file": "react-native-masked-view-masked-view-0.3.2.tgz", + "integrity": "sha512-XwuQoW7/GEgWRMovOQtX3A4PrXhyaZm0lVUiY8qJDvdngjLms9Cpdck6SmGAUNqQwcj2EadHC1HwL0bEyoa/SQ==" + }, + { + "spec": "react-native-webview@14.0.1", + "file": "react-native-webview-14.0.1.tgz", + "integrity": "sha512-lBUuvFk459Mo+5vUNqwzGvn+I8rDJE6zvOulG2hWWudeEOJfWTsQwOfuYnRu+27djUIXrESFfC+EQE3PGu+FWA==" + }, + { + "spec": "@sentry/react-native@8.34.0", + "file": "sentry-react-native-8.34.0.tgz", + "integrity": "sha512-BqBRS7qbg7qUlVwQqGoIfIy1vrU2J27uUSmhLhA7pYgMThx8+3mla2EKmUABtLo7nLYxQpp/kg5DQ+hWKVwO+A==" + }, + { + "spec": "@react-native-community/netinfo@12.0.1", + "file": "react-native-community-netinfo-12.0.1.tgz", + "integrity": "sha512-P/3caXIvfYSJG8AWJVefukg+ZGRPs+M4Lp3pNJtgcTYoJxCjWrKQGNnCkj/Cz//zWa/avGed0i/wzm0T8vV2IQ==" + }, + { + "spec": "react-native-keyboard-controller@1.23.0", + "file": "react-native-keyboard-controller-1.23.0.tgz", + "integrity": "sha512-UqHOiGeVQnUj1NBggzQ9LD9rqHf7k4u81hqDpIyS2k3r1noOp9w5/lLiSajipH88BsMO7J43E3N/L+bfKEiuZA==" + }, + { + "spec": "@react-native-community/datetimepicker@9.3.0", + "file": "react-native-community-datetimepicker-9.3.0.tgz", + "integrity": "sha512-4M87hB1xbqxzwOAt0P5GZyXf7wXjspRplIwctYHH5w4nDX4E0rWIPdJkZ4S69z0J5slwSIdXpHo+tDWMCvhNSg==" + }, + { + "spec": "react-native-get-random-values@2.1.0", + "file": "react-native-get-random-values-2.1.0.tgz", + "integrity": "sha512-ooSUj9zTICGZ/eDFzNCnC+Pyb0SxE6y2QtC8S8z/BBJY+9dUjjNWD0DgRCSfXuC/c2k9V03xLMF6y/yUYEk4ew==" + }, + { + "spec": "react-native-nitro-modules@0.37.2", + "file": "react-native-nitro-modules-0.37.2.tgz", + "integrity": "sha512-Odnrq/p6/q0R01qZlkqeXu9VHHMuGEnZZmyxMvehEu6QiACNHhBCmAHgyBDqOSo9Lb3G0TscFAT+HG0uxsR/GA==" + }, + { + "spec": "react-native-mmkv@4.3.2", + "file": "react-native-mmkv-4.3.2.tgz", + "integrity": "sha512-49OAyfkg0/TMWiWELZN6VuVQPZPhizwL4DTmp8b7B1md3dB/s3LH3mGfC3T+lp9W0y/rqxZMEnotLFTIbOAenQ==" + }, + { + "spec": "@react-native-firebase/app@27.1.0", + "file": "react-native-firebase-app-27.1.0.tgz", + "integrity": "sha512-VeGUvSBDq0NNIfHPF0h+bPiUoWK6szUxwwlCCZDKMZrMMcbLYeNmBZaqKV1tj86KfZxfvLyD8iBoCVOE6QXvdw==" + }, + { + "spec": "@shopify/react-native-skia@2.14.0", + "file": "shopify-react-native-skia-2.14.0.tgz", + "integrity": "sha512-mzizcTeUAgvam+m1BsxTs+K8ujUXkzoCmwumUhV5NWcoImmKJiWUMfQYgw2OOt1p6qpr7+G5pPOELAmNzZRvlw==" + }, + { + "spec": "lottie-react-native@7.5.0", + "file": "lottie-react-native-7.5.0.tgz", + "integrity": "sha512-pT9JdskrRpsdBWGUTdPIQfdY+AoJHvp9F392kfNW4ucjoTfa7Y46iv0wQ/AXmzVN+4SzXjwtXeQM/nMKNd2+jg==" + }, + { + "spec": "react-native-view-shot@6.2.1", + "file": "react-native-view-shot-6.2.1.tgz", + "integrity": "sha512-gsvR347Rr1avrF5Gki14VQPn7jJBbaEp2ast8EWAWnJvfTSQWoR/ZrQ3cksACNpwGRjC5ysQKxyj0Zrnid6WMg==" + }, + { + "spec": "@react-native-community/slider@5.2.2", + "file": "react-native-community-slider-5.2.2.tgz", + "integrity": "sha512-KdWURcFqHZ/nvQwt9S7P2PHBREl83GZeflWZU1VpR/qJ+lF/mdiOBZshJQztE2hBDgW5iBIrRb3RY9uAie5k/w==" + }, + { + "spec": "react-native-pager-view@10.0.0", + "file": "react-native-pager-view-10.0.0.tgz", + "integrity": "sha512-MVZI0BO/giG23pETmpxpiv6dP2tnoE/NFWFo+OH8MJR/yeoWQxca9ymgbGIkZVmUHnyjyzoSST0l+mdKLTs4dw==" + }, + { + "spec": "react-native-maps@1.29.11", + "file": "react-native-maps-1.29.11.tgz", + "integrity": "sha512-fZNc6AINuPdHS2puudanNPd9ZMPPuerTHfy9HU6LbpOD+kB03SuOZRbOEYIOE2eSuUPYwLHvU8ys1RcSIxLYhA==" + }, + { + "spec": "react-native-device-info@15.0.2", + "file": "react-native-device-info-15.0.2.tgz", + "integrity": "sha512-dd71eXG2l3Cwp66IvKNadMTB8fhU3PEjyVddI97sYan+D4bgIAUmgGDhbSOFvHcGavksb2U17kiQYaDiK2WK2g==" + }, + { + "spec": "@react-native-google-signin/google-signin@17.0.0", + "file": "react-native-google-signin-google-signin-17.0.0.tgz", + "integrity": "sha512-FAnq5tkoq01np7jCzGjBYK1QPS61hJxjLJHJyJjQN3gaTwAZiGll18Xn3nygITMsZ/WoJ0jmskuHSG/oknUskQ==" + }, + { + "spec": "react-native-blob-util@0.25.1", + "file": "react-native-blob-util-0.25.1.tgz", + "integrity": "sha512-HMzab2SL8h48pvfufji0TKdet/jnNvamxYmYyNqTV5YOge00V28ycdc3S4leHjGXMJ1+fS2j2SrQ3aG5pzbx1w==" + }, + { + "spec": "react-native-purchases@11.0.1", + "file": "react-native-purchases-11.0.1.tgz", + "integrity": "sha512-j3bzkFrS0nwGNCfOCEKqfnOuGJipc12y9z7bYW7Tqcho02N6IMphDxqbM/PUsoaXeXnU6VbjzbXEw7V22FpJIA==" + }, + { + "spec": "@react-native-picker/picker@2.11.4", + "file": "react-native-picker-picker-2.11.4.tgz", + "integrity": "sha512-Kf8h1AMnBo54b1fdiVylP2P/iFcZqzpMYcglC28EEFB1DEnOjsNr6Ucqc+3R9e91vHxEDnhZFbYDmAe79P2gjA==" + }, + { + "spec": "@react-native-clipboard/clipboard@1.16.3", + "file": "react-native-clipboard-clipboard-1.16.3.tgz", + "integrity": "sha512-cMIcvoZKIrShzJHEaHbTAp458R9WOv0fB6UyC7Ek4Qk561Ow/DrzmmJmH/rAZg21Z6ixJ4YSdFDC14crqIBmCQ==" + }, + { + "spec": "react-native-permissions@5.6.3", + "file": "react-native-permissions-5.6.3.tgz", + "integrity": "sha512-jCl5TCbRsgBr3kgJdLmdyLa+QMW/jiTjKdQqXGrm7x1XMUwKlumnQWx1BRRcIv7eclnLN1NZud3KVaCkp8+wHA==" + }, + { + "spec": "react-native-screens@4.24.0", + "file": "react-native-screens-4.24.0.tgz", + "integrity": "sha512-SyoiGaDofiyGPFrUkn1oGsAzkRuX1JUvTD9YQQK3G1JGQ5VWkvHgYSsc1K9OrLsDQxN7NmV71O0sHCAh8cBetA==" + }, + { + "spec": "react-native-worklets@0.8.1", + "file": "react-native-worklets-0.8.1.tgz", + "integrity": "sha512-oWP/lStsAHU6oYCaWDXrda/wOHVdhusQJz1e6x9gPnXdFf4ndNDAOtWCmk2zGrAnlapfyA3rM6PCQq94mPg9cw==" + }, + { + "spec": "react-native-worklets@0.8.3", + "file": "react-native-worklets-0.8.3.tgz", + "integrity": "sha512-oCBJROyLU7yG/1R8s0INMflygTH71bx+5XcYkH0CM938TlhSoVbiunE1WVW5FZa51vwYqfLie/IXMX2s1Kh3eg==" + }, + { + "spec": "react-native-vision-camera@4.7.3", + "file": "react-native-vision-camera-4.7.3.tgz", + "integrity": "sha512-g1/neOyjSqn1kaAa2FxI/qp5KzNvPcF0bnQw6NntfbxH6tm0+8WFZszlgb5OV+iYlB6lFUztCbDtyz5IpL47OA==" + }, + { + "spec": "@react-native-community/datetimepicker@9.2.1", + "file": "react-native-community-datetimepicker-9.2.1.tgz", + "integrity": "sha512-P2dir8EcPYuS6g7N/E4jImugB99h2+e1kzNX6Ihg+2T2v5IZ5dB+4afLisG6rdua4YZ1mADYCZ2iqI34sPjIKA==" + }, + { + "spec": "react-native-gesture-handler@3.3.0", + "file": "react-native-gesture-handler-3.3.0.tgz", + "integrity": "sha512-ZCTlJ09nE3GPbm7J74lvwpxmx1TQ/7MDlHZNLARVYTN82k21mJUJ7BmI9eWjEi8eevHiAudI5O1Cpnt0rJfoJA==" + }, + { + "spec": "react-native-safe-area-context@5.10.1", + "file": "react-native-safe-area-context-5.10.1.tgz", + "integrity": "sha512-ax0T3cAHQIhuAjDQpJ9C1Le96aRiM9PF+Kmgg7Y8+mD7QJMEIx04cG0eG3EGUTdvymgOkCrkakgZFwuOIuNQGw==" + }, + { + "spec": "react-native-worklets@0.13.0", + "file": "react-native-worklets-0.13.0.tgz", + "integrity": "sha512-1OrhAeAKaZF4XrBa4YbPQbKzNOpjh52HDlId8e6ete1OCHNdAlrQHzG4gznJ225EAj3dgQXHViJvK51M9B52jQ==" + }, + { + "spec": "expo@57.0.31", + "file": "expo-57.0.31.tgz", + "integrity": "sha512-+9AJvHZMLIY/Tv6r5Tpu84vWfI75FBTnineYqjjlHAU138IPg2gYQKn9FQFetCB9YScwyc7STk7WGHSCHAdTiQ==" + }, + { + "spec": "expo-modules-core@57.0.24", + "file": "expo-modules-core-57.0.24.tgz", + "integrity": "sha512-2AY+JgjZiWXIx1zXVhx2JaLEsZOH2NDAqJCSnPQyoCcUa9QEHAzpn2++omq+OvrsmsQCJcVrHe6cKz8FSnpLLQ==" + }, + { + "spec": "@expo/dom-webview@57.0.1", + "file": "expo-dom-webview-57.0.1.tgz", + "integrity": "sha512-lAKsME4SAq+8sf56oN0DX5TBYyruupoRxbWbD2xf9RnKY8y6x8eb9LCE5pxSN0qyWdqnp+0wmyWzDkKboThKAw==" + }, + { + "spec": "@expo/log-box@57.0.4", + "file": "expo-log-box-57.0.4.tgz", + "integrity": "sha512-IxwS9s1L2muj8mj8AQSuiy7u8OFJdc02NRFo2me/Tj6DiaeG5SREqmpBE4rQpR2cadqSg5jl8Qab8Cjie616dg==" + }, + { + "spec": "expo-asset@57.0.20", + "file": "expo-asset-57.0.20.tgz", + "integrity": "sha512-xm1p3Squ/dCzipISO1TE5+kDsIFEUc6DxEtRe2rRgPMDLPi6AumLlrNorFxetiP6zrvxK23xzVlNng/g7o/+aA==" + }, + { + "spec": "expo-constants@57.0.22", + "file": "expo-constants-57.0.22.tgz", + "integrity": "sha512-+mBjnzMWMKIrQa7BP7LTDRC0W7cI+q12/sZns4HzVQJGzgGoAdRJSTEKiObxIw/3EswKXlESkRob8upiL95Q4A==" + }, + { + "spec": "expo-file-system@57.0.7", + "file": "expo-file-system-57.0.7.tgz", + "integrity": "sha512-1vkZRadOsIputFDBcclqBa1pO3iXOO6iIsdqJipQWw4V5TSnWgmRTuOF7ro8IzrVue+PHbum++KCG3Tawem4cg==" + }, + { + "spec": "expo-font@57.0.4", + "file": "expo-font-57.0.4.tgz", + "integrity": "sha512-7WOMC2oA6xCfOm8bbofqWn2bIqyWFm7YLEnpc/gA1MJH0Ll0TfT/3+CqRkoW2eNRWMS8sxrz5WukUmSvmNquHA==" + }, + { + "spec": "expo-keep-awake@57.0.2", + "file": "expo-keep-awake-57.0.2.tgz", + "integrity": "sha512-GqgH746wtJImmsbyHmCQoi7cOslKuWQBbJHXr53S35Bpf5UvxCAztvnitUEd7D0QvFN2rvkOhylbZpgZZfBLlQ==" + }, + { + "spec": "expo-modules-core@58.0.28", + "file": "expo-modules-core-58.0.28.tgz", + "integrity": "sha512-2FCnT8mIubdQAHVtX9fVMN9qajF7hGDC3CjxxBG0HlyK7NEsxUDKkukiNVzqQpwiI+jJx7ysG0YvATwKKlu1sw==" + }, + { + "spec": "@expo/dom-webview@58.0.2", + "file": "expo-dom-webview-58.0.2.tgz", + "integrity": "sha512-bLkREoP7qL3rEuzxP60xG+TjdPoGjbnZfxkvYo5imJxGWfKMOf7x962W06Pu+WWAr4gcDRk16iA+Clg8D0zjCg==" + }, + { + "spec": "@expo/log-box@58.0.13", + "file": "expo-log-box-58.0.13.tgz", + "integrity": "sha512-Cl9qc77nWjQVivUI5/OCPSEP8s20EtbK3Ivy5ayy+uHO0Cf+XatatWfTvKiHO38VOpT2ywlROzZb4XZyxZUZ1Q==" + }, + { + "spec": "expo-asset@58.0.19", + "file": "expo-asset-58.0.19.tgz", + "integrity": "sha512-9tYdhiPUJKA3OjnQQJtcP4Yrdc9TPR1JQXTomcLdDSV4XgHSXRpsnp5zsIfM6S/y30QsBFHS6G3WIBaocCiPtA==" + }, + { + "spec": "expo-constants@58.0.14", + "file": "expo-constants-58.0.14.tgz", + "integrity": "sha512-ogn/7xLmvkEVYX6SimDkcNDn/d8qZpCTQdBWPnMI+Ry7Sfch0Dz2GIcweqddK4hrkvrSY01TS20BZfMlCpJ75g==" + }, + { + "spec": "expo-file-system@58.0.13", + "file": "expo-file-system-58.0.13.tgz", + "integrity": "sha512-+/1aFErkawyky5UdWI06zYeO2DeHUnfaWnYHeiI8M8Z/sB6L66gI3WUxqtvUvKJoaM0Ti1CximD3x3JwteLYIg==" + }, + { + "spec": "expo-font@58.0.11", + "file": "expo-font-58.0.11.tgz", + "integrity": "sha512-6r7s6xk2L2orvum+x+TY1fzEcMtuCBRQTLgC/Su2uLzNPpT4L+E+S4IAGy8ZIjeVvwk2j2pj+HiZ23O7eh1PGQ==" + }, + { + "spec": "expo-keep-awake@58.0.3", + "file": "expo-keep-awake-58.0.3.tgz", + "integrity": "sha512-wLRF+XeVsD/Rt/ZyX+A0mk1brdf8vefWizNAPzqV5eOCgkj23LCRZdN8gUi5X8UwyR8UJ7Y7Dzdz4YDGB/4c9Q==" + }, + { + "spec": "expo-glass-effect@58.0.5", + "file": "expo-glass-effect-58.0.5.tgz", + "integrity": "sha512-PkL1X/r0cTs6NG47Xp3TxRvtqSeRmPYhPOHp3GDmZB2oOxpjXge6qLi/bSSv0asFWqf+MLOlXZ+hq2Imuh0Z1g==" + }, + { + "spec": "expo-haptics@58.0.7", + "file": "expo-haptics-58.0.7.tgz", + "integrity": "sha512-mAY3rbng6EuYysq9wnJKhKwYYlDjqnPYcS5OXe3zj4TlAaOFMl/EfiSOuAMawc2nsXCAnwJ5U0E11nq5zQO0mg==" + }, + { + "spec": "expo-linking@58.0.15", + "file": "expo-linking-58.0.15.tgz", + "integrity": "sha512-N6jmeKRsMO+DXmAH1AnStVEXK4FpL3fMzam9dJWIhd/FlMt/DCNRGUn2cqM7kNsDPSHGYGBIOCGsrW+Akp0xwA==" + }, + { + "spec": "expo-router@58.0.28", + "file": "expo-router-58.0.28.tgz", + "integrity": "sha512-figS9IpRn1h3iYUii1PY7ka/6XSIQ0EBKR5HqKcDl8gadN4hGfS90WFU9gjpquIdM72lS3Dxm6CT2vGQmsiQSg==" + }, + { + "spec": "expo-status-bar@58.0.4", + "file": "expo-status-bar-58.0.4.tgz", + "integrity": "sha512-e6JJHziSSNb1v1VSzmDrAPf6GFoPRdVOIDrTCcK3bHfbJEAZGZ3YZXfqlorZtUFDT0z6NcjaZf0mPWifJZcqew==" + }, + { + "spec": "semver@7.8.5", + "file": "semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==" } ] From 3d7c9dd3e6559244562593c88f43a9d9841f6c15 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 08:15:44 -0600 Subject: [PATCH 32/53] test: give the sweep's cleanup time to finish --- tests/support/podspecSweep.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index c21d0f3..d4685fd 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -50,9 +50,10 @@ const SHIM_GAP_KINDS = shimGapKinds(readFileSync(path.join(VENDORED_RN_SPM, "rea const READER_FIELDS = new Set(["reader", "partial"]); const tmp: string[] = []; +// Tens of thousands of files: seconds alone, and past vitest's 10 s hook timeout beside the rest of the suite. afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); -}); +}, 120_000); const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); From bc5d600b22e8c1fe0b64e650006ce5b45787d9e3 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 08:16:20 -0600 Subject: [PATCH 33/53] test: add an optional heavy tier to the sweep --- scripts/fetch-test-tarballs.mjs | 21 ++++++++++++++----- tests/podspecReaderSweep.test.ts | 36 +++++++++++++++++++++++--------- tests/support/podspecSweep.ts | 35 +++++++++++++++++++++++-------- tests/support/tarballs.ts | 13 +++++++++--- tests/tarballs.json | 18 ++++++++++++++++ tests/tarballs.test.ts | 31 +++++++++++++++++++++++++-- 6 files changed, 125 insertions(+), 29 deletions(-) diff --git a/scripts/fetch-test-tarballs.mjs b/scripts/fetch-test-tarballs.mjs index e81c123..df3af68 100644 --- a/scripts/fetch-test-tarballs.mjs +++ b/scripts/fetch-test-tarballs.mjs @@ -3,6 +3,9 @@ // package. // node scripts/fetch-test-tarballs.mjs → packs each tarball that is missing or has another integrity, once more if // npm pack fails; exits 1 with the reason when a tarball cannot be had +// RN_XTOOL_FETCH_HEAVY=1 (or --heavy) → also the `heavy` ones (hundreds of MB, such as skia's prebuilt binaries), +// which are otherwise skipped with a line each; CI does not fetch them, so +// the sweep entries that need them skip there import { execFile } from "node:child_process"; import { createHash } from "node:crypto"; import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync } from "node:fs"; @@ -18,19 +21,26 @@ export function integrityOf(bytes) { const integrityAt = (file) => (existsSync(file) ? integrityOf(readFileSync(file)) : "missing"); const messageOf = (err) => (err instanceof Error ? err.message : String(err)).trim(); +export const HEAVY_FETCH = "RN_XTOOL_FETCH_HEAVY=1 node scripts/fetch-test-tarballs.mjs"; + /** * Makes `dir` hold each entry's `file` with its `integrity`. A file already there with that integrity is kept; - * otherwise `pack(spec, dir)` writes it, and runs once more when it fails. Throws when both runs fail or the file - * it wrote has another integrity (that file is removed). + * otherwise `pack(spec, dir)` writes it, and runs once more when it fails. An entry marked `heavy` is packed only with + * `heavy`; without it, a missing one is skipped with a line that says how to fetch it. Throws when both runs fail or + * the file it wrote has another integrity (that file is removed). */ -export async function fetchAll(entries, { dir, pack, log }) { +export async function fetchAll(entries, { dir, pack, log, heavy = false }) { mkdirSync(dir, { recursive: true }); - for (const { spec, file, integrity } of entries) { + for (const { spec, file, integrity, heavy: isHeavy } of entries) { const at = path.join(dir, file); if (integrityAt(at) === integrity) { log(`${file}: cached`); continue; } + if (isHeavy && !heavy) { + log(`${file}: skipped (heavy; fetch it with ${HEAVY_FETCH})`); + continue; + } try { await pack(spec, dir); } catch (first) { @@ -70,7 +80,8 @@ if (isMain()) { const tests = path.join(path.dirname(self), "..", "tests"); const entries = JSON.parse(readFileSync(path.join(tests, "tarballs.json"), "utf8")); try { - await fetchAll(entries, { dir: path.join(tests, ".cache"), pack: npmPack, log: (s) => console.log(s) }); + const heavy = process.env.RN_XTOOL_FETCH_HEAVY === "1" || process.argv.slice(2).includes("--heavy"); + await fetchAll(entries, { dir: path.join(tests, ".cache"), pack: npmPack, log: (s) => console.log(s), heavy }); } catch (err) { console.error(messageOf(err)); process.exit(1); diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index 9f726a1..4aba15d 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -13,22 +13,18 @@ import { podspecsOf, record, shimGapKinds, + sweepSkipReason, type SweepEntry, } from "./support/podspecSweep.js"; -import { needsRuby } from "./support/ruby.js"; -import { needsTarball } from "./support/tarballs.js"; +import { HEAVY_FETCH_HINT, MANIFEST } from "./support/tarballs.js"; +import { mkTmp } from "./support/expoSpm.js"; // The podspec reader sweep: every podspec of the libraries in tests/podspec-sweep.json, read with Ruby and with the // reduced reader, against its reviewed golden in tests/fixtures/podspec-sweep (RN_XTOOL_SWEEP_WRITE=1 rewrites them). -// Off CI a library whose tarballs are not cached, or a machine without Ruby, skips; on CI both fail. +// Off CI a library whose tarballs are not cached, or a machine without Ruby, skips; on CI both fail, except a heavy +// tarball (tests/tarballs.json), which CI does not fetch: the libraries that need one skip there. const CI = process.env.CI === "true"; - -/** `""` when the entry's podspecs can be read here, else a title suffix that says what they need. */ -function skipReason(entry: SweepEntry): string { - if (CI) return ""; - const tarballs = [entry.spec, entry.rn, ...(entry.with ?? [])].map((spec) => needsTarball(spec)).join(""); - return tarballs + needsRuby; -} +const skipReason = (entry: SweepEntry) => sweepSkipReason(entry, CI); const skip = (entry: SweepEntry) => skipReason(entry) !== ""; describe("the podspec reader sweep", () => { @@ -65,6 +61,26 @@ describe("the sweep's guards", () => { expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.86.3/ (no goldens)"); }); + // A library that needs a heavy tarball, with a cache folder that holds nothing. + const heavy = MANIFEST.find((e) => e.heavy)!; + const needsHeavy: SweepEntry = { spec: "react-native-unpinned@0.0.1", rn: "react-native@0.88.1", with: [heavy.spec] }; + const heavyNeeds = ` (needs tests/.cache/${heavy.file}; ${HEAVY_FETCH_HINT})`; + + it("skips a library whose heavy tarball is missing, on CI too, and only for it there", () => { + const empty = mkTmp("sweep-empty-cache-"); + expect(sweepSkipReason(needsHeavy, true, empty)).toBe(heavyNeeds); + expect(sweepSkipReason(needsHeavy, false, empty)).toContain(heavyNeeds); + expect(sweepSkipReason(needsHeavy, false, empty)).toContain(needs); + expect(sweepSkipReason(unpinned, true, empty)).toBe(""); + }); + + it("does not report a heavy tarball as missing on CI", () => { + const empty = mkTmp("sweep-empty-cache-"); + const orphans = orphanGoldens([needsHeavy], true, empty).join("\n"); + expect(orphans).toContain(needs); + expect(orphans).not.toContain(heavy.file); + }); + it("refuses to write a gap of the shim as a golden", () => { const gap = { shim: { error: "Foo.podspec: undefined method `bar'", kind: "method" } }; expect(() => goldenText(gap)).toThrow("a gap of the shim (method): Foo.podspec: undefined method `bar'"); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index d4685fd..fa25bf0 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -14,7 +14,8 @@ import { podspecResources } from "../../src/pipeline/scaffoldResources.js"; import { podDependencies, podspecFiles, podspecLines, unconditionalLineIndexes } from "../../src/project/podspecs.js"; import { packageRoot } from "../../src/tools/exec.js"; import { VENDORED_RN_SPM } from "./rnScaffold.js"; -import { needsTarball, tarballPath } from "./tarballs.js"; +import { needsRuby } from "./ruby.js"; +import { isHeavy, needsTarball, tarballPath } from "./tarballs.js"; import { tool } from "./tools.js"; const ROOT = packageRoot(); @@ -110,12 +111,25 @@ function goldenPodspecs(entry: SweepEntry): string[] { .sort(); } -/** The entry's podspecs: its project's, or its goldens' when its tarballs are not here (its tests then skip or fail). */ -export function podspecsOf(entry: SweepEntry): string[] { - const here = tarballsOf(entry).every((spec) => needsTarball(spec) === ""); +/** + * The entry's podspecs: its project's, or its goldens' when its tarballs are not in `dir` (`tests/.cache` by default; + * its tests then skip or fail). + */ +export function podspecsOf(entry: SweepEntry, dir?: string): string[] { + const here = tarballsOf(entry).every((spec) => needsTarball(spec, dir) === ""); return here ? sweepProject(entry).podspecs : goldenPodspecs(entry); } +/** + * `""` when the entry's podspecs can be read here, else a title suffix that says what they need. Off CI: each tarball + * not in `dir` (`tests/.cache` by default), and Ruby. On CI (`ci`), which fetches every tarball but the heavy ones, + * only a heavy tarball that is not there: anything else missing fails there instead. + */ +export function sweepSkipReason(entry: SweepEntry, ci = process.env.CI === "true", dir?: string): string { + const needs = (specs: string[]) => specs.map((spec) => needsTarball(spec, dir)).join(""); + return ci ? needs(tarballsOf(entry).filter(isHeavy)) : needs(tarballsOf(entry)) + needsRuby; +} + /** `value` with its object keys sorted, at every depth; arrays keep their order. */ function sorted(value: unknown): unknown { if (Array.isArray(value)) return value.map(sorted); @@ -285,20 +299,23 @@ export function nameDifferences(): string[] { /** * What the goldens folder holds that no sweep entry's podspec owns (a folder of no entry, a golden of no podspec), each * entry without a goldens folder, and each podspec without a golden, by path under `tests/fixtures/podspec-sweep`. An - * entry whose tarballs are not here is checked for its folder only, and on CI (`ci`), which fetched every tarball, it - * is listed with what it needs. + * entry whose tarballs are not in `dir` (`tests/.cache` by default) is checked for its folder only, and on CI (`ci`), + * which fetched every tarball but the heavy ones, it is listed with the others it needs. */ -export function orphanGoldens(entries: readonly SweepEntry[] = SWEEP, ci = process.env.CI === "true"): string[] { +export function orphanGoldens(entries: readonly SweepEntry[] = SWEEP, ci = process.env.CI === "true", dir?: string): string[] { const dirs = new Set(entries.map((entry) => path.basename(goldenDir(entry)))); const found = existsSync(SWEEP_GOLDENS) ? readdirSync(SWEEP_GOLDENS).sort() : []; const strays = found.filter((d) => !dirs.has(d)).map((d) => `${d}/ (no entry)`); return [ ...strays, ...entries.flatMap((entry) => { - const missing = tarballsOf(entry).map((spec) => needsTarball(spec)).join(""); + const missing = tarballsOf(entry) + .filter((spec) => !isHeavy(spec)) + .map((spec) => needsTarball(spec, dir)) + .join(""); const needs = ci && missing !== "" ? [`${entryName(entry)}${missing}`] : []; if (!existsSync(goldenDir(entry))) return [`${path.basename(goldenDir(entry))}/ (no goldens)`, ...needs]; - const podspecs = podspecsOf(entry); + const podspecs = podspecsOf(entry, dir); const goldens = goldenPodspecs(entry); const rel = (p: string) => path.relative(SWEEP_GOLDENS, goldenFile(entry, p)); return [ diff --git a/tests/support/tarballs.ts b/tests/support/tarballs.ts index 2c4cd7b..04c3b2b 100644 --- a/tests/support/tarballs.ts +++ b/tests/support/tarballs.ts @@ -15,9 +15,11 @@ import { hasTool, patchTool, tool } from "./tools.js"; const ROOT = packageRoot(); const CACHE = path.join(ROOT, "tests", ".cache"); -export type TarballEntry = { spec: string; file: string; integrity: string }; +/** A pinned tarball; a `heavy` one is fetched only on request ({@link HEAVY_FETCH_HINT}). */ +export type TarballEntry = { spec: string; file: string; integrity: string; heavy?: true }; export const MANIFEST = JSON.parse(readFileSync(path.join(ROOT, "tests", "tarballs.json"), "utf8")) as TarballEntry[]; export const FETCH_HINT = "run: node scripts/fetch-test-tarballs.mjs"; +export const HEAVY_FETCH_HINT = "run: RN_XTOOL_FETCH_HEAVY=1 node scripts/fetch-test-tarballs.mjs"; const tmp: string[] = []; afterAll(() => { @@ -25,6 +27,8 @@ afterAll(() => { }); const entryOf = (spec: string) => MANIFEST.find((e) => e.spec === spec); +/** Whether `spec` is pinned as heavy: fetched only on request, and on CI never (its tests skip there). */ +export const isHeavy = (spec: string): boolean => entryOf(spec)?.heavy === true; const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); const integrityOf = (file: string) => "sha512-" + createHash("sha512").update(readFileSync(file)).digest("base64"); @@ -53,13 +57,16 @@ const hasTools = () => /** * `""` when the tests of `spec` can run here, else a title suffix that says what they need: the spec in the manifest, - * its tarball in `tests/.cache` (with {@link FETCH_HINT}), or `tar` and `patch`. A cached tarball counts whatever its + * its tarball in `tests/.cache` (with {@link FETCH_HINT}, or {@link HEAVY_FETCH_HINT} for a heavy one), or `tar` and + * `patch`. A cached tarball counts whatever its * integrity, so that a mismatch fails the tests ({@link tarballPath}) instead of skipping them. */ export function needsTarball(spec: string, dir = CACHE): string { const entry = entryOf(spec); if (!entry) return ` (needs ${spec} pinned in tests/tarballs.json)`; - if (!existsSync(path.join(dir, entry.file))) return ` (needs tests/.cache/${entry.file}; ${FETCH_HINT})`; + if (!existsSync(path.join(dir, entry.file))) { + return ` (needs tests/.cache/${entry.file}; ${entry.heavy ? HEAVY_FETCH_HINT : FETCH_HINT})`; + } if (!hasTools()) return " (needs tar and patch)"; return ""; } diff --git a/tests/tarballs.json b/tests/tarballs.json index 3c9e258..0935e6e 100644 --- a/tests/tarballs.json +++ b/tests/tarballs.json @@ -383,5 +383,23 @@ "spec": "semver@7.8.5", "file": "semver-7.8.5.tgz", "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==" + }, + { + "spec": "react-native-skia-apple-ios@154.0.0", + "file": "react-native-skia-apple-ios-154.0.0.tgz", + "integrity": "sha512-7xq2XYEbcfQYcqyXEnTDXF9GjQzKHuDiUep6wOvOXzoK62108DR8dM3VYgOqJqCTqspPHC9fEJeT52fK3UU5Qg==", + "heavy": true + }, + { + "spec": "react-native-skia-apple-macos@154.0.0", + "file": "react-native-skia-apple-macos-154.0.0.tgz", + "integrity": "sha512-0BE6/oVMXYOKsxI4JJP1MwwrgmaDnZAl9l6N+7q434MFiT+w0z96a0gTilZukzo1y+35sDi/sA+iAdTz16ElYA==", + "heavy": true + }, + { + "spec": "react-native-skia-apple-tvos@154.0.0", + "file": "react-native-skia-apple-tvos-154.0.0.tgz", + "integrity": "sha512-W06tUa+O3TJTYg5G+Lly/pwxE+2zKsmwJ/23yeR+25zSu7VmfdSz3VqFN3BM0jEioN4ASMm/0cMECocV7vxbMQ==", + "heavy": true } ] diff --git a/tests/tarballs.test.ts b/tests/tarballs.test.ts index 311a8f1..bb640c4 100644 --- a/tests/tarballs.test.ts +++ b/tests/tarballs.test.ts @@ -6,9 +6,9 @@ import { packageRoot } from "../src/tools/exec.js"; import { fetchAll, integrityOf } from "../scripts/fetch-test-tarballs.mjs"; import { EXPO_INTEGRITY, mkTmp } from "./support/expoSpm.js"; import { RN_INTEGRITY } from "./support/rnScaffold.js"; -import { FETCH_HINT, needsTarball, packageFromTarball, patchedSpm, tarballPath } from "./support/tarballs.js"; +import { FETCH_HINT, HEAVY_FETCH_HINT, isHeavy, needsTarball, packageFromTarball, patchedSpm, tarballPath } from "./support/tarballs.js"; -type Entry = { spec: string; file: string; integrity: string }; +type Entry = { spec: string; file: string; integrity: string; heavy?: true }; const MANIFEST = JSON.parse(readFileSync(path.join(packageRoot(), "tests", "tarballs.json"), "utf8")) as Entry[]; const BYTES = new TextEncoder().encode("a pinned tarball\n"); @@ -82,6 +82,24 @@ describe("fetchAll", () => { expect(existsSync(path.join(dir, GOOD.file))).toBe(true); }); + it("skips a heavy tarball unless asked, and says how to fetch it", async () => { + const dir = mkTmp("tarballs-heavy-"); + const heavy: Entry = { ...GOOD, heavy: true }; + const lines: string[] = []; + const pack = packer(0); + await fetchAll([heavy], { dir, pack, log: (s) => lines.push(s) }); + expect(pack).not.toHaveBeenCalled(); + expect(existsSync(path.join(dir, GOOD.file))).toBe(false); + await fetchAll([heavy], { dir, pack, log: (s) => lines.push(s), heavy: true }); + await fetchAll([heavy], { dir, pack, log: (s) => lines.push(s) }); + expect(pack).toHaveBeenCalledTimes(1); + expect(lines).toEqual([ + "expo-58.0.21.tgz: skipped (heavy; fetch it with RN_XTOOL_FETCH_HEAVY=1 node scripts/fetch-test-tarballs.mjs)", + "expo-58.0.21.tgz: fetched", + "expo-58.0.21.tgz: cached", + ]); + }); + it("says what it fetched and what it kept", async () => { const dir = mkTmp("tarballs-log-"); mkdirSync(dir, { recursive: true }); @@ -101,6 +119,8 @@ describe("tests/tarballs.json", () => { expect(file, spec).toBe(`${name}-${spec.slice(at + 1)}.tgz`); expect(integrity, spec).toMatch(/^sha512-[A-Za-z0-9+/]{86}==$/); } + // `heavy` is set to true or left out. + for (const entry of MANIFEST) expect([undefined, true], entry.spec).toContain(entry.heavy); }); it("matches the provenance tests", () => { @@ -136,6 +156,13 @@ describe("tests/support/tarballs", () => { ); }); + it("gives a heavy tarball that is not cached the heavy fetch command", () => { + const heavy = MANIFEST.find((e) => e.heavy)!; + expect(HEAVY_FETCH_HINT).toBe("run: RN_XTOOL_FETCH_HEAVY=1 node scripts/fetch-test-tarballs.mjs"); + expect([isHeavy(heavy.spec), isHeavy(pinned.spec), isHeavy("left-pad@0.0.0")]).toEqual([true, false, false]); + expect(needsTarball(heavy.spec, mkTmp("tarballs-heavy-absent-"))).toBe(` (needs tests/.cache/${heavy.file}; ${HEAVY_FETCH_HINT})`); + }); + const rn = "react-native@0.88.1"; it.skipIf(needsTarball(rn) !== "")(`patches its own copy, once, and leaves the pristine one alone${needsTarball(rn)}`, () => { const pristine = packageFromTarball(rn)!; From db4988e7ab918033a378c73b0e7bb828f7c932c9 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 08:16:26 -0600 Subject: [PATCH 34/53] test: sweep skia with its prebuilt binaries --- .../react-native-skia.podspec.json | 138 +++++++++++------- tests/podspec-sweep.json | 2 +- 2 files changed, 90 insertions(+), 50 deletions(-) diff --git a/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json b/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json index df501cc..90e0a2c 100644 --- a/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json +++ b/tests/fixtures/podspec-sweep/@shopify+react-native-skia@2.14.0@rn-0.88.1/react-native-skia.podspec.json @@ -1,6 +1,8 @@ { "env": [], - "helpers": [], + "helpers": [ + "install_modules_dependencies" + ], "names": { "reduced": { "headerDir": null, @@ -15,61 +17,99 @@ }, "reduced": { "differs": { - "compilerFlags": [], - "dependencies": [ - "React", - "React-callinvoker", - "React-Core" - ], - "excludeFiles": [ - "cpp/rnskia/RNDawnContext.h", - "cpp/rnskia/RNDawnUtils.h", - "cpp/rnskia/RNMetalLayerColorSpace.h", - "cpp/rnskia/RNDawnWindowContext.h", - "cpp/rnskia/RNDawnWindowContext.cpp", - "cpp/rnskia/RNDawnInterop.cpp", - "cpp/rnskia/RNImageProvider.h" - ], - "frameworks": [ - "MetalKit", - "AVFoundation", - "AVKit", - "CoreMedia" - ], - "headerDir": null, - "headerDirScopes": [], - "headerMappingsDir": null, - "headerMappingsDirs": [], "headerSearchPaths": [], - "libraries": [], - "moduleName": null, - "name": "react-native-skia", "preprocessorDefines": [], - "privateHeaderFiles": [], - "publicHeaderFiles": [], - "requiresArc": true, - "resources": [], - "sourceFiles": [ - "apple/**/*.{h,c,cc,cpp,m,mm,swift}", - "cpp/**/*.{h,cpp}" - ], - "spmDependencies": [], - "subspecDependencies": {}, - "swiftConditions": [], - "swiftVersions": [], - "unresolvedSources": [], - "usesInstallModulesDependencies": true, - "version": "", "warnings": [ "Left out of s.pod_target_xcconfig GCC_PREPROCESSOR_DEFINITIONS: `preprocessor_defs`, which the podspec reader cannot evaluate; CocoaPods passes its value.", "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby." - ], - "weakFrameworks": [] + ] } }, "shim": { - "error": "/node_modules/@shopify/react-native-skia/react-native-skia.podspec:125: react-native-skia: Skia prebuilt binaries not found. Run `yarn install` then `pod install` to fix this.", - "kind": "raised" + "compilerFlags": [], + "dependencies": [ + "React", + "React-callinvoker", + "React-Core" + ], + "excludeFiles": [ + "cpp/rnskia/RNDawnContext.h", + "cpp/rnskia/RNDawnUtils.h", + "cpp/rnskia/RNMetalLayerColorSpace.h", + "cpp/rnskia/RNDawnWindowContext.h", + "cpp/rnskia/RNDawnWindowContext.cpp", + "cpp/rnskia/RNDawnInterop.cpp", + "cpp/rnskia/RNImageProvider.h" + ], + "frameworks": [ + "MetalKit", + "AVFoundation", + "AVKit", + "CoreMedia" + ], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [ + "$(PODS_TARGET_SRCROOT)/cpp/**", + "$(PODS_TARGET_SRCROOT)/cpp", + "$(PODS_TARGET_SRCROOT)/cpp/skia", + "$(PODS_TARGET_SRCROOT)/cpp/dawn/include" + ], + "libraries": [], + "moduleName": null, + "name": "react-native-skia", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "SK_METAL", + "value": "1" + }, + { + "config": null, + "name": "SK_GANESH", + "value": "1" + }, + { + "config": null, + "name": "SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API", + "value": "1" + }, + { + "config": null, + "name": "SK_DISABLE_LEGACY_SHAPER_FACTORY", + "value": "1" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,c,cc,cpp,m,mm,swift}", + "cpp/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] }, - "tsReaders": null + "tsReaders": { + "dependencies": { + "onlyShim": [], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } } diff --git a/tests/podspec-sweep.json b/tests/podspec-sweep.json index 708641a..624f428 100644 --- a/tests/podspec-sweep.json +++ b/tests/podspec-sweep.json @@ -14,7 +14,7 @@ { "spec": "@react-native-masked-view/masked-view@0.3.2", "rn": "react-native@0.88.1" }, { "spec": "@react-native-picker/picker@2.11.4", "rn": "react-native@0.88.1" }, { "spec": "@sentry/react-native@8.34.0", "rn": "react-native@0.88.1" }, - { "spec": "@shopify/react-native-skia@2.14.0", "rn": "react-native@0.88.1" }, + { "spec": "@shopify/react-native-skia@2.14.0", "rn": "react-native@0.88.1", "with": ["react-native-skia-apple-ios@154.0.0", "react-native-skia-apple-macos@154.0.0", "react-native-skia-apple-tvos@154.0.0"] }, { "spec": "expo-asset@57.0.20", "rn": "react-native@0.86.3" }, { "spec": "expo-asset@58.0.19", "rn": "react-native@0.88.1" }, { "spec": "expo-constants@57.0.22", "rn": "react-native@0.86.3" }, From 6d4ee1513668fc425fb43285213f296bb1d67db7 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 08:34:32 -0600 Subject: [PATCH 35/53] feat: refuse bare mentions in markdown --- .github/workflows/mentions.yml | 33 ++++++ CHANGELOG.md | 2 +- docs/RELEASING.md | 18 ++- .../specs/2026-11-04-library-compat-design.md | 2 +- docs/research/compat-suite-proposal.md | 2 +- docs/research/rn-087-recon.md | 6 +- docs/troubleshooting.md | 2 +- package.json | 3 +- scripts/check-mentions.mjs | 103 ++++++++++++++++++ tests/ci/workflow.test.ts | 42 +++++++ tests/mentions.test.ts | 59 ++++++++++ tests/packageFiles.test.ts | 10 ++ 12 files changed, 273 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/mentions.yml create mode 100644 scripts/check-mentions.mjs create mode 100644 tests/mentions.test.ts diff --git a/.github/workflows/mentions.yml b/.github/workflows/mentions.yml new file mode 100644 index 0000000..b28dd4d --- /dev/null +++ b/.github/workflows/mentions.yml @@ -0,0 +1,33 @@ +# Mentions: on every pull request that is opened, edited, reopened or pushed to, check its description for bare GitHub +# mentions (`@name` outside a code span), which notify that user. The Markdown files in the repo are checked by +# tests/mentions.test.ts in CI. +# +# The description reaches the shell through an environment variable and is written to a file, never put into the +# script text: an expression inside run text would let a description run commands. + +name: Mentions + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +permissions: + contents: read + +jobs: + description: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-node@v7 + with: + node-version: 22 + - name: Write the description to a file + env: + BODY: ${{ github.event.pull_request.body }} + run: printf '%s' "$BODY" > "$RUNNER_TEMP/body.md" + - name: Check the description for bare mentions + run: node scripts/check-mentions.mjs "$RUNNER_TEMP/body.md" diff --git a/CHANGELOG.md b/CHANGELOG.md index c7c754d..6dfa0fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,7 @@ versions follow [Semantic Versioning](https://semver.org/) with `alpha` prerelea the project's `CLANG_CXX_LANGUAGE_STANDARD` (C++20 when unset), instead of clang's default, which stopped on React Native's C++20 headers with "unknown type name 'Hashable'" in `react/utils/hash_combine.h`. - An Objective-C++ file that imports a pod table forward (a bare app's `AppDelegate.mm` with - `#import `) compiles, instead of stopping with "use of '@import' when modules are disabled": the + `#import `) compiles, instead of stopping with "use of '`@import`' when modules are disabled": the scaffold's forwarder `#import`s the pod's public headers instead of `@import`ing its modules. - A library that was also built for Android gets its scaffold persisted, instead of "⚠ Did not persist 's scaffold: the patch would contain a binary file (node_modules//android/build/…/BuildConfig.dex)" and a new diff --git a/docs/RELEASING.md b/docs/RELEASING.md index a7ae999..477a1c3 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -41,7 +41,23 @@ git push --follow-tags ``` Then create a GitHub release from the tag with the notes (what changed, known limits, tested xtool/Swift/Expo -versions). Check the result: `npm view react-native-xtool dist-tags` and `npx react-native-xtool@alpha doctor`. +versions), from a checked file as below. Check the result: `npm view react-native-xtool dist-tags` and +`npx react-native-xtool@alpha doctor`. + +**Pull requests and release notes.** A bare `@name` outside a code span notifies that GitHub user, and in release +notes lists them as a contributor. Write the text of a pull request and the release notes into files, check each one, +and give GitHub the checked file: + +```sh +npm run check:mentions -- # names each bare mention and fails; put it in a code span or drop the @ +gh pr create --body-file +gh release create --notes-file +``` + +Publish release notes from the checked file only, never typed or pasted into GitHub's release page. CI checks the +Markdown files in the repo (`tests/mentions.test.ts`), and the Mentions workflow +(`.github/workflows/mentions.yml`) checks a pull request's description again each time it is opened, edited or +pushed to. ## Scaffolder changes diff --git a/docs/design/specs/2026-11-04-library-compat-design.md b/docs/design/specs/2026-11-04-library-compat-design.md index 2cc4d91..fe496ee 100644 --- a/docs/design/specs/2026-11-04-library-compat-design.md +++ b/docs/design/specs/2026-11-04-library-compat-design.md @@ -41,7 +41,7 @@ header layout, an entitlement key), never a library name or a version number. reported none. - These build as they are, together: @aws-amplify/react-native 1.3.3, async-storage 1.24.0, keychain 10.0.0, localize 3.7.2, linear-gradient 2.8.3, wifi-reborn 4.13.6, webview 13.17.0, svg 15.16.0, screens 4.30.1, - safe-area-context 5.11.1, reanimated 4.7.1 + worklets 0.13.0, and @react-navigation 6 (JS only). + safe-area-context 5.11.1, reanimated 4.7.1 + worklets 0.13.0, and `@react-navigation` 6 (JS only). - These do not: vision-camera 4.7.3, device-info 15.0.2, netinfo 11.5.2 and video 6.19.3. - With the four hand fixes below, every library builds together. The final build produced `App.app`, and `llvm-nm` shows each library's classes in the binary. No device was used. diff --git a/docs/research/compat-suite-proposal.md b/docs/research/compat-suite-proposal.md index c8136bd..bb60841 100644 --- a/docs/research/compat-suite-proposal.md +++ b/docs/research/compat-suite-proposal.md @@ -261,7 +261,7 @@ risk flag nothing else covers. Until they pass, they need the same isolation as | google-signin, react-native-purchases | Each needs one pod-map entry, same mechanism as 12/13. Runtime needs an OAuth client / RevenueCat key + StoreKit. Hard cases | | react-native-permissions, react-native-config | RUBY/SP gaps that fail at runtime more than at build. Hard cases | | react-native-quick-crypto | Nitro (12) plus an OpenSSL download at podspec time. Hard case | -| react-native-fast-image / @d11 | Low downloads. SDWebImage already covered by 9. Would conflict with expo-image's SDWebImage pin if both were in one app | +| react-native-fast-image / `@d11` | Low downloads. SDWebImage already covered by 9. Would conflict with expo-image's SDWebImage pin if both were in one app | | netinfo, device-info, share, linear-gradient, localize, keychain, fs, image-picker, blur, sound | Plain SC-objc/objcxx, duplicates of 6. device-info/linear-gradient/fs would add LEG (legacy bridge) coverage if wanted | | react-native-track-player, @react-native-documents/picker | SW-ish / MX2, covered by 13. track-player adds POD SwiftAudioEx (one map entry) | | expo-av | Not part of SDK 58 (16.x line). Superseded by expo-audio/expo-video | diff --git a/docs/research/rn-087-recon.md b/docs/research/rn-087-recon.md index 8504925..d657ae6 100644 --- a/docs/research/rn-087-recon.md +++ b/docs/research/rn-087-recon.md @@ -38,12 +38,12 @@ Control: 0.88.0 -> `patch --dry-run` and `git apply --check` both clean. | Tool | 0.87.1 | 0.87.0 | |---|---|---| -| GNU `patch --dry-run -p1` | read-podspec 7/19 FAILED (#1 @170, #7, #8, #11, #17, #18, #19), scaffold 1/23 FAILED (#1 @54, imports), spm-utils OK (offset) | read-podspec 7/19 FAILED (same), scaffold 5/23 FAILED (#1,#5,#10,#11,#21), spm-utils OK | -| `git apply --check` (strict, what patch-package uses; fuzz not allowed) | read-podspec FAILS 8 hunks (@170, 332, 354, 482, 677, 693, 746, 794); scaffold FAILS 5 hunks (@54, 113, 768, 844, 1099); spm-utils OK. Rejected = 532 + 178 lines of .rej | read-podspec 8 hunks; scaffold 9 hunks (@54,113,248,518,526,768,844,1014,1099); spm-utils OK | +| GNU `patch --dry-run -p1` | read-podspec 7/19 FAILED (#1 line 170, #7, #8, #11, #17, #18, #19), scaffold 1/23 FAILED (#1 line 54, imports), spm-utils OK (offset) | read-podspec 7/19 FAILED (same), scaffold 5/23 FAILED (#1,#5,#10,#11,#21), spm-utils OK | +| `git apply --check` (strict, what patch-package uses; fuzz not allowed) | read-podspec FAILS 8 hunks (line 170, 332, 354, 482, 677, 693, 746, 794); scaffold FAILS 5 hunks (line 54, 113, 768, 844, 1099); spm-utils OK. Rejected = 532 + 178 lines of .rej | read-podspec 8 hunks; scaffold 9 hunks (line 54,113,248,518,526,768,844,1014,1099); spm-utils OK | Why the hunks fail (0.87.1): the patch is built against a 0.88.0 file that contains 0.88-only code the hunks use as context or extend: - read-podspec.js: 0.88 `readPodspecSource` (comment-line stripping), `SHADOWING_SUBSPEC_RE`/`hasShadowingSubspec`, `getSpecStringField`/`getIdentityField`/`shadowedIdentity`, `specStringField`, `module_name`/`moduleName` field, `podspecModels`/`readPodspecCached`, `readPodspecNames`, `findPodspecs` all exist only in 0.88. 0.87 read-podspec.js is 0.87.0 == 0.87.1 (unchanged between them). -- scaffold-package-swift.js: context anchored on `require('./swiftpm-config')` (@54), `warn` logger and `SCAFFOLDER_VERSION = 20` (@113), the `reportSwiftName` function (@844), `readPodspecCached`/`findPodspecs` call sites and `refreshScaffoldedPlatformFloors` (@1099); 0.87 has `readPodspec` only, SCAFFOLDER_VERSION 19, no swiftpm-config. +- scaffold-package-swift.js: context anchored on `require('./swiftpm-config')` (line 54), `warn` logger and `SCAFFOLDER_VERSION = 20` (line 113), the `reportSwiftName` function (line 844), `readPodspecCached`/`findPodspecs` call sites and `refreshScaffoldedPlatformFloors` (line 1099); 0.87 has `readPodspec` only, SCAFFOLDER_VERSION 19, no swiftpm-config. - spm-utils.js hunk (header-farm, patch #12) applies cleanly to 0.87.0 and 0.87.1 (offsets only; `buildPerAppHeaderTree` is the same shape). - The patch also references `swiftpmConfig`/`readSwiftpmConfig/writeSwiftpmName`, `findPodspecs`, `model.moduleName` in its added code (patch lines ~841, 1384-1398), i.e. even the hunks that apply with fuzz contain code calling 0.88-only helpers: applying with fuzz would leave `require('./swiftpm-config')` (file absent in 0.87) -> module-not-found. Patch numbers by doc (docs/upstream/react-native-scaffolder.md): fixes 1 (bare lists), 3 (Ruby locals), 4 (subspec blocks), 6 (platform fields), 8 (REACT_NATIVE_*_VERSION defines) live in read-podspec.js; 2, 5, 7, 9, 10, 11, 13 in scaffold-package-swift.js; 12 in spm-utils.js. Not checked: which of the 13 fixes the unpatched 0.87 code already contains. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 395ae18..5f62162 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -917,7 +917,7 @@ an `ios/build/pod-binaries` from an earlier build stays on disk, unused ([Leavin releases also search each autolinked library's `rn-spm-pod-headers`, where the scaffold writes the pod table's `forwardHeaders`. See [Mixed Swift + Objective-C/C++ app target](bare-react-native.md#mixed-swift--objective-cc-app-target). -- **"use of '@import' when modules are disabled"** (in `rn-spm-pod-headers/AppAuth/AppAuth.h`, compiling an +- **"use of '`@import`' when modules are disabled"** (in `rn-spm-pod-headers/AppAuth/AppAuth.h`, compiling an Objective-C++ file that imports ``, such as a bare app's `AppDelegate.mm`): the scaffold of rn-xtool 0.1.0-alpha.6 (scaffolder revision 4) wrote the pod table's `forwardHeaders` as `@import` lines. Objective-C++ compiles with `-fmodules -fno-cxx-modules`, Xcode's default, so `@import` is an error there; diff --git a/package.json b/package.json index dc97b23..74fc9ad 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,8 @@ "prepare": "npm run build", "test": "vitest run", "lint": "tsc --noEmit", - "scan:private": "bash scripts/scan-private.sh" + "scan:private": "bash scripts/scan-private.sh", + "check:mentions": "node scripts/check-mentions.mjs" }, "dependencies": { "@expo/config": "^58.0.7", diff --git a/scripts/check-mentions.mjs b/scripts/check-mentions.mjs new file mode 100644 index 0000000..e97d3bd --- /dev/null +++ b/scripts/check-mentions.mjs @@ -0,0 +1,103 @@ +#!/usr/bin/env node +// Finds bare GitHub mentions in Markdown: a `@name` in prose notifies that GitHub user (and a release note that holds +// one lists them as a contributor). Not shipped in the npm package. +// node scripts/check-mentions.mjs [file…] → one line per bare mention and exit 1; nothing and exit 0 when clean. +// With no file it checks every tracked Markdown file (`git ls-files '*.md'`). Run it from the repo root. +import { execFileSync } from "node:child_process"; +import { readFileSync, realpathSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +/** The opening line of a fenced block: its marker (three or more backticks or tildes) and the rest of the line. */ +const FENCE = /^\s*(`{3,}|~{3,})(.*)$/; + +/** + * A bare mention: a `@` not preceded by a letter, digit, `_`, `` ` ``, `/`, `.`, `-` or `@`, followed by a GitHub login + * (a letter or digit, then up to 38 more, single hyphens between them) that is not followed by `/` or a login + * character. So `@scope/name` and `a@b.c` pass, and `@54` (a hunk number) is a mention, as GitHub treats it. + * Fenced blocks and code spans are left out before this runs. + */ +const MENTION = /(? { + const masked = blankCodeSpans(para.join("\n")); + for (const m of masked.matchAll(MENTION)) { + found.push({ line: first + masked.slice(0, m.index).split("\n").length, word: m[1] }); + } + para = []; + }; + lines.forEach((l, i) => { + const f = FENCE.exec(l); + if (fence !== undefined) { + // A fence closes on a run of its own character at least as long, with nothing after it. + if (f && f[1][0] === fence[0] && f[1].length >= fence.length && f[2].trim() === "") fence = undefined; + return; + } + if (f) { + flush(); + fence = f[1]; + } else if (l.trim() === "") { + flush(); + } else { + if (para.length === 0) first = i; + para.push(l); + } + }); + flush(); + return found; +} + +const self = fileURLToPath(import.meta.url); +const isMain = () => { + try { + return realpathSync(path.resolve(process.argv[1] ?? "")) === realpathSync(self); + } catch { + return false; + } +}; +if (isMain()) { + const args = process.argv.slice(2); + const files = + args.length > 0 ? args : execFileSync("git", ["ls-files", "*.md"], { encoding: "utf8" }).split("\n").filter(Boolean); + let failed = false; + for (const file of files) { + for (const { line, word } of mentions(readFileSync(file, "utf8"))) { + process.stderr.write(`${file}:${line}: @${word} notifies a GitHub user; put it in a code span or drop the @\n`); + failed = true; + } + } + process.exitCode = failed ? 1 : 0; +} diff --git a/tests/ci/workflow.test.ts b/tests/ci/workflow.test.ts index 5875b49..234eb62 100644 --- a/tests/ci/workflow.test.ts +++ b/tests/ci/workflow.test.ts @@ -173,6 +173,48 @@ describe("CI workflow", () => { }); }); +describe("Mentions workflow", () => { + const FILE = path.join(root, ".github", "workflows", "mentions.yml"); + const raw = (): string => readFileSync(FILE, "utf8"); + const wf = (): Workflow => parse(raw()) as Workflow; + const all = (): Step[] => Object.values(wf().jobs).flatMap((j) => j.steps); + + it("runs on every change to a pull request's description or commits", () => { + expect(wf().on).toEqual({ pull_request: { types: ["opened", "edited", "reopened", "synchronize"] } }); + expect(raw()).not.toMatch(/schedule|pull_request_target|workflow_run|workflow_dispatch|push:/); + }); + + it("reads the repository only", () => { + expect(wf().permissions).toEqual({ contents: "read" }); + expect(raw().match(/permissions:/g)).toHaveLength(1); + const checkouts = all().filter((s) => s.uses?.startsWith("actions/checkout")); + expect(checkouts.map((c) => c.with?.["persist-credentials"])).toEqual([false]); + expect(raw()).not.toMatch(/secrets\.|GH_TOKEN|\btoken\b/i); + }); + + it("passes the description through an environment variable, never as an expression in run text", () => { + // An expression in run text is pasted into the script before the shell runs it: a description could run commands. + expect(raw().split("\n").filter((l) => l.includes("${{")).map((l) => l.trim())).toEqual([ + "BODY: ${{ github.event.pull_request.body }}", + ]); + const write = all().find((s) => s.run?.includes("$BODY")) as Step & { env?: Record }; + expect(write.env).toEqual({ BODY: "${{ github.event.pull_request.body }}" }); + }); + + it("writes the description to a file and checks it, in that order, and lets no failure pass", () => { + const [job, ...more] = Object.values(wf().jobs) as (Job & { "continue-on-error"?: unknown })[]; + expect(more).toEqual([]); + expect(job!["runs-on"]).toBe("ubuntu-latest"); + expect(job!["timeout-minutes"]).toBe(5); + expect(job!.steps.flatMap((s) => (s.uses ? [s.uses] : []))).toEqual(["actions/checkout@v7", "actions/setup-node@v7"]); + expect(job!.steps.flatMap((s) => (s.run !== undefined ? [s.run.trim()] : []))).toEqual([ + `printf '%s' "$BODY" > "$RUNNER_TEMP/body.md"`, + 'node scripts/check-mentions.mjs "$RUNNER_TEMP/body.md"', + ]); + expect(raw()).not.toMatch(/continue-on-error/); + }); +}); + describe("the private scan in CI (no .scan-private.local)", () => { /** A git repo holding the scan script and one tracked file, with no local patterns file. */ function repo(content: string): string { diff --git a/tests/mentions.test.ts b/tests/mentions.test.ts new file mode 100644 index 0000000..6d6a096 --- /dev/null +++ b/tests/mentions.test.ts @@ -0,0 +1,59 @@ +import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; +import { mentions } from "../scripts/check-mentions.mjs"; +import { mkTmp } from "./support/expoSpm.js"; +import { tool } from "./support/tools.js"; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const SCRIPT = path.join(ROOT, "scripts", "check-mentions.mjs"); + +/** Every tracked Markdown file, and the local PR and notes files under `.superpowers/` when that folder exists. */ +function markdownFiles(): string[] { + const r = tool("git", ["ls-files", "*.md"], { cwd: ROOT }); + expect(r.status, r.stderr).toBe(0); + const tracked = r.stdout.split("\n").filter((f) => f !== ""); + const local = path.join(ROOT, ".superpowers"); + const notes = existsSync(local) + ? readdirSync(local).filter((f) => f.endsWith(".md")).map((f) => path.join(".superpowers", f)) + : []; + return [...tracked, ...notes]; +} + +describe("mentions", () => { + it("finds a bare user mention", () => expect(mentions("use @import here\n")).toEqual([{ line: 1, word: "import" }])); + + it("passes code spans, fences, scoped names and e-mail addresses", () => + expect(mentions("`@import` and ``a `@x` b``\n```\n@y\n```\n@scope/name a@b.c\n")).toEqual([])); + + it("refuses hunk numbers written as mentions", () => + expect(mentions("at @54 and @d11")).toEqual([{ line: 1, word: "54" }, { line: 1, word: "d11" }])); + + it("passes a code span across a line break and a ~~~ fence with an info string, and counts lines past them", () => + expect(mentions("a `x\n@y` b\n~~~ sh\n@z\n```\n@w\n~~~\n\n`open\n\nthen @v\n")).toEqual([{ line: 11, word: "v" }])); + + it("reads CRLF line ends, as GitHub sends a PR description", () => + expect(mentions("```\r\n@x\r\n```\r\n\r\n`a\r\n@b`\r\nthanks @c\r\n")).toEqual([{ line: 7, word: "c" }])); + + it("finds none in the tracked markdown or the local PR and notes files", () => { + const hits = markdownFiles().flatMap((f) => + mentions(readFileSync(path.join(ROOT, f), "utf8")).map((m) => `${f}:${m.line}: @${m.word}`), + ); + expect(hits).toEqual([]); + }); +}); + +describe("node scripts/check-mentions.mjs", () => { + it("names each bare mention of the files and fails, and passes a clean file silently", () => { + const dir = mkTmp("mentions-"); + writeFileSync(path.join(dir, "bad.md"), "ok\nthanks @someone\n"); + writeFileSync(path.join(dir, "good.md"), "`@someone` a@b.c\n"); + const bad = tool("node", [SCRIPT, "bad.md", "good.md"], { cwd: dir }); + expect(bad.stderr).toBe("bad.md:2: @someone notifies a GitHub user; put it in a code span or drop the @\n"); + expect(bad.stdout).toBe(""); + expect(bad.status).toBe(1); + const good = tool("node", [SCRIPT, "good.md"], { cwd: dir }); + expect([good.stdout, good.stderr, good.status]).toEqual(["", "", 0]); + }); +}); diff --git a/tests/packageFiles.test.ts b/tests/packageFiles.test.ts index 074143e..5458137 100644 --- a/tests/packageFiles.test.ts +++ b/tests/packageFiles.test.ts @@ -49,4 +49,14 @@ describe("the npm package", () => { it("ships the podspec reader's shim", () => { expect(listed()).toContain("vendor/rn-spm/spm/read-podspec-shim.rb"); }); + + it("ships the scripts the CLI runs and none of the repo's own (the mention check, CI's and the release's)", () => { + expect(listed().filter((f) => f.startsWith("scripts/"))).toEqual([ + "scripts/build-expo-modules-jsi.sh", + "scripts/exclude-config-command.js", + "scripts/package.json", + "scripts/rn-spm-generate.js", + "scripts/stage-frameworks.sh", + ]); + }); }); From d137b885458e9f51bb14f1436f8ce14c6f9f0d74 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 09:36:18 -0600 Subject: [PATCH 36/53] fix: see fences in CRLF markdown --- scripts/check-mentions.mjs | 9 ++++++--- tests/mentions.test.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/check-mentions.mjs b/scripts/check-mentions.mjs index e97d3bd..90cb8f4 100644 --- a/scripts/check-mentions.mjs +++ b/scripts/check-mentions.mjs @@ -8,8 +8,11 @@ import { readFileSync, realpathSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -/** The opening line of a fenced block: its marker (three or more backticks or tildes) and the rest of the line. */ -const FENCE = /^\s*(`{3,}|~{3,})(.*)$/; +/** + * The opening line of a fenced block: its marker (three or more backticks or tildes) and the rest of the line. After + * backticks the rest holds none (CommonMark): "```a``` then" opens a code span, not a fence. + */ +const FENCE = /^\s*(`{3,}(?=[^`]*$)|~{3,})(.*)$/; /** * A bare mention: a `@` not preceded by a letter, digit, `_`, `` ` ``, `/`, `.`, `-` or `@`, followed by a GitHub login @@ -48,7 +51,7 @@ function blankCodeSpans(text) { */ export function mentions(text) { const found = []; - const lines = text.split("\n"); + const lines = text.split(/\r?\n/); // a PR description comes with CRLF line ends let fence; // the open fence's marker let para = []; // the current paragraph's lines let first = 0; // the index of its first line diff --git a/tests/mentions.test.ts b/tests/mentions.test.ts index 6d6a096..1c7e754 100644 --- a/tests/mentions.test.ts +++ b/tests/mentions.test.ts @@ -36,6 +36,16 @@ describe("mentions", () => { it("reads CRLF line ends, as GitHub sends a PR description", () => expect(mentions("```\r\n@x\r\n```\r\n\r\n`a\r\n@b`\r\nthanks @c\r\n")).toEqual([{ line: 7, word: "c" }])); + it("skips CRLF fences, a blank line inside included", () => + expect( + mentions("```swift\r\n@objc func a() {}\r\n\r\n@MainActor\r\n```\r\n~~~\r\n@objc\r\n~~~\r\nthanks @c\r\n"), + ).toEqual([{ line: 9, word: "c" }])); + + it("reads a line that opens with a triple-backtick code span as prose, and lets a ~~~ info string hold backticks", () => { + expect(mentions("```a``` then @foo\n\nmore @bar\n")).toEqual([{ line: 1, word: "foo" }, { line: 3, word: "bar" }]); + expect(mentions("~~~ `x`\n@y\n~~~\n")).toEqual([]); + }); + it("finds none in the tracked markdown or the local PR and notes files", () => { const hits = markdownFiles().flatMap((f) => mentions(readFileSync(path.join(ROOT, f), "utf8")).map((m) => `${f}:${m.line}: @${m.word}`), From 602cab084bc18a40ad4596b432894a4301394549 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 10:24:15 -0600 Subject: [PATCH 37/53] test: give heavy sweep entries a longer timeout --- tests/podspecReaderSweep.test.ts | 16 +++++++++++++--- tests/support/podspecSweep.ts | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index 4aba15d..6545e3d 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -8,6 +8,7 @@ import { entryName, golden, goldenText, + isHeavyEntry, nameDifferences, orphanGoldens, podspecsOf, @@ -26,13 +27,18 @@ import { mkTmp } from "./support/expoSpm.js"; const CI = process.env.CI === "true"; const skipReason = (entry: SweepEntry) => sweepSkipReason(entry, CI); const skip = (entry: SweepEntry) => skipReason(entry) !== ""; +// A heavy library's read can copy hundreds of MB (skia's podspec copies its prebuilt frameworks into the library): +// tens of seconds on a slow or busy disk, past the suite's 20 s. +const timeout = (entry: SweepEntry) => (isHeavyEntry(entry) ? 120_000 : undefined); describe("the podspec reader sweep", () => { for (const entry of SWEEP) for (const podspec of podspecsOf(entry)) - it.skipIf(skip(entry))(`reads ${entryName(entry)} ${podspec} as its golden${skipReason(entry)}`, () => { - expect(record(entry, podspec)).toEqual(golden(entry, podspec)); - }); + it.skipIf(skip(entry))( + `reads ${entryName(entry)} ${podspec} as its golden${skipReason(entry)}`, + () => expect(record(entry, podspec)).toEqual(golden(entry, podspec)), + timeout(entry), + ); it("keeps every library's names under both readers", () => expect(nameDifferences()).toEqual([])); it("lists each library once per React Native", () => { @@ -74,6 +80,10 @@ describe("the sweep's guards", () => { expect(sweepSkipReason(unpinned, true, empty)).toBe(""); }); + it("knows a library that needs a heavy tarball", () => { + expect([isHeavyEntry(needsHeavy), isHeavyEntry(unpinned)]).toEqual([true, false]); + }); + it("does not report a heavy tarball as missing on CI", () => { const empty = mkTmp("sweep-empty-cache-"); const orphans = orphanGoldens([needsHeavy], true, empty).join("\n"); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index fa25bf0..20431bf 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -61,6 +61,8 @@ const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); const tarballsOf = (entry: SweepEntry) => [entry.spec, entry.rn, ...(entry.with ?? [])]; /** The entry's name in titles and messages: ` on `. */ export const entryName = (entry: SweepEntry) => `${entry.spec} on ${entry.rn}`; +/** Whether the entry needs a heavy tarball (`tests/tarballs.json`): fetched on request, and slow to read. */ +export const isHeavyEntry = (entry: SweepEntry): boolean => tarballsOf(entry).some(isHeavy); const message = (e: unknown) => (e instanceof Error ? e.message : String(e)); /** `spec`'s tarball extracted into `dir` (only `members` of it when given). */ From af940cf8a0e69c3a767fcd45ea1fde1c93b77f1e Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:23:18 -0600 Subject: [PATCH 38/53] docs: skip backups in the patch recipe --- docs/RELEASING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 477a1c3..f802a63 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -77,7 +77,8 @@ and `vendor/rn-spm/rn-xtool-edits.patch` (E1–E6) applied, for 0.85–0.87 and cp -a "$T/x/package/scripts" "$T/a/node_modules/react-native/scripts" cp -a vendor/rn-spm/setup-apple-spm.js vendor/rn-spm/spm vendor/rn-spm/codegen \ "$T/b/node_modules/react-native/scripts/" - patch -R -p1 -F0 -d "$T/b/node_modules/react-native/scripts" -i "$PWD/vendor/rn-spm/rn-xtool-edits.patch" + patch -R -p1 -F0 --no-backup-if-mismatch -d "$T/b/node_modules/react-native/scripts" \ + -i "$PWD/vendor/rn-spm/rn-xtool-edits.patch" (cd "$T" && git diff --no-index --no-color --src-prefix= --dst-prefix= \ a/node_modules/react-native/scripts b/node_modules/react-native/scripts) \ | sed -E 's#^diff --git [ab]/([^ ]+) [ab]/#diff --git a/\1 b/#' > "$T/rn.patch" From b59874787008df00959246053474df130835fb63 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:26:47 -0600 Subject: [PATCH 39/53] fix: run podspecs with the probed Ruby --- docs/upstream/react-native-scaffolder.md | 4 +- patches/react-native+0.88.0.patch | 126 +++++++++++++++-------- patches/react-native+0.88.1.patch | 126 +++++++++++++++-------- src/tools/podspecReader.ts | 2 +- tests/podspecReader.test.ts | 41 +++++++- tests/podspecShim.test.ts | 18 +++- vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec-shim.rb | 14 ++- vendor/rn-spm/spm/read-podspec.js | 50 +++++++-- 9 files changed, 275 insertions(+), 108 deletions(-) diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 5ec54af..5c62b6a 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -896,7 +896,9 @@ stored under their plural keys), `attributes_hash` (the attributes as stored, wh `add_nitrogen_files` reads and extends), `dependency`, `subspec`, `test_spec`, `app_spec` and the platform proxies (`s.ios`, `s.osx`, `s.tvos`, `s.visionos`, `s.watchos`; `s.macos` stores under `osx`). It writes the spec in CocoaPods' JSON form, what `pod ipc spec` printed, so `flattenSubspecs` reads it unchanged. `ruby --probe` checks the Ruby -version before anything loads. +version before anything loads and names the interpreter that answered (`RbConfig.ruby`, an absolute path). Each read +runs that path, not `ruby` from `PATH`, so a version manager's `ruby` shim (rbenv, asdf, mise) cannot pick another +Ruby from a `.ruby-version` in the podspec's folder. The shim models what a static scan found called in the podspecs of the reference apps, of the Expo SDK 57 and 58 references and of the podspec fixtures, and in the scripts they load. React Native's helpers: diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index e9844ba..f9cfffb 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..2bd1819 +index 0000000..8fb9e73 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,519 @@ +@@ -0,0 +1,527 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -62,18 +62,25 @@ index 0000000..2bd1819 +# DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). +# +# ruby read-podspec-shim.rb --probe -+# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. ++# prints {"ruby":"","floor":"","usable":true,"interpreter":""}, or "usable":false with a ++# "why", and exits 0. The interpreter is the absolute path of the Ruby that ran (RbConfig.ruby): reads run it, not ++# whatever `ruby` a version manager's shim picks in the podspec's folder. +# ruby read-podspec-shim.rb +# run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. +# Nothing of the shim's own goes to stdout; the podspec's prints do. +# +# Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. + ++require 'rbconfig' ++ +RN_XTOOL_RUBY_FLOOR = '2.7.0' +if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 + why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" + abort why unless ARGV == ['--probe'] -+ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) ++ # Without `json`, which this Ruby may not load: the path escaped as a JSON string by hand. ++ interpreter = RbConfig.ruby.gsub(/[\\"]/) { |c| "\\#{c}" }.gsub(/[\x00-\x1f]/) { |c| format('\\u%04x', c.ord) } ++ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}",) + ++ %("interpreter":"#{interpreter}"}) + exit 0 +end + @@ -85,7 +92,8 @@ index 0000000..2bd1819 +require 'json' + +if ARGV == ['--probe'] -+ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) ++ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true, ++ 'interpreter' => RbConfig.ruby) + exit 0 +end + @@ -575,7 +583,7 @@ index 0000000..2bd1819 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..032bc7c 100644 +index 8fcf04b..87225cc 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -604,7 +612,7 @@ index 8fcf04b..032bc7c 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1681 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1709 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -659,9 +667,17 @@ index 8fcf04b..032bc7c 100644 + +/*:: +type PodspecReaderChoice = -+ | {reader: 'ruby', ruby: string, forced: false, warning: ?string} ++ | { ++ reader: 'ruby', ++ ruby: string, ++ interpreter?: string, ++ forced: false, ++ warning: ?string, ++ } + | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; -+type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; ++type RubyProbe = ++ | {usable: true, ruby: string, interpreter?: string} ++ | {usable: false, why: string}; +*/ + +const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); @@ -766,16 +782,21 @@ index 8fcf04b..032bc7c 100644 + answer = null; + } + if (answer?.usable === true && typeof answer.ruby === 'string') { -+ return {usable: true, ruby: answer.ruby}; ++ // The absolute path of the Ruby that answered: a version manager's ++ // `ruby` shim on PATH may pick another one in the podspec's folder. ++ return typeof answer.interpreter === 'string' && ++ path.isAbsolute(answer.interpreter) ++ ? {usable: true, ruby: answer.ruby, interpreter: answer.interpreter} ++ : {usable: true, ruby: answer.ruby}; + } + if (answer?.usable === false && typeof answer.why === 'string') { + return {usable: false, why: answer.why}; + } -+ } + } + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; - } ++ } + let detail; + if (stderr.length > 0) { + detail = stderr[0]; @@ -830,9 +851,18 @@ index 8fcf04b..032bc7c 100644 + probe = probeRuby(shim, env); + rubyProbes.set(key, probe); + } -+ return probe.usable -+ ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} -+ : {reader: 'reduced', why: probe.why, forced: false, warning}; ++ if (!probe.usable) { ++ return {reader: 'reduced', why: probe.why, forced: false, warning}; ++ } ++ return probe.interpreter != null ++ ? { ++ reader: 'ruby', ++ ruby: probe.ruby, ++ interpreter: probe.interpreter, ++ forced: false, ++ warning, ++ } ++ : {reader: 'ruby', ruby: probe.ruby, forced: false, warning}; +} + +// The app's `ios/` folder, CocoaPods' installation root for the podspec: @@ -849,12 +879,18 @@ index 8fcf04b..032bc7c 100644 +} + +// Runs the podspec with Ruby through the shim, in the podspec's folder, with -+// an empty stdin and `podspecChildEnv`: its model, and what it printed. ++// an empty stdin and `podspecChildEnv`: its model, and what it printed. The ++// Ruby is `opts.interpreter`, the one the probe found, else `ruby` on PATH. +function runPodspecShim( + podspecPath /*: string */, -+ opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, ++ opts /*: { ++ timeoutMs?: number, ++ installationRoot?: string, ++ interpreter?: ?string, ++ } */ = {}, +) /*: {raw: RawSpec, output: string} */ { + const podspec = path.resolve(podspecPath); ++ const ruby = opts.interpreter ?? 'ruby'; + const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; + const root = opts.installationRoot ?? installationRootFor(podspec); + const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); @@ -863,7 +899,7 @@ index 8fcf04b..032bc7c 100644 + let written = null; try { - result = spawnSync('pod', ['ipc', 'spec', patchedPath], { -+ result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { ++ result = spawnSync(ruby, [PODSPEC_SHIM, podspec, out, root], { + cwd: path.dirname(podspec), encoding: 'utf8', - timeout: 30000, @@ -1094,8 +1130,10 @@ index 8fcf04b..032bc7c 100644 + return h; + } + return v; -+} -+ + } + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1174,7 +1212,7 @@ index 8fcf04b..032bc7c 100644 + } + } + return null; - } ++} +const PLATFORM_SCOPES /*: Set */ = new Set([ + 'ios', + 'osx', @@ -1183,9 +1221,7 @@ index 8fcf04b..032bc7c 100644 + 'visionos', + 'watchos', +]); - --function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { -- if (patchedPath == null) return; ++ +// Tokens of one Ruby expression. A double-quoted string keeps its parts: +// literal text and the source of each `#{...}`. +function tokenizeRubyExpr(src /*: string */) /*: Array */ { @@ -2420,7 +2456,7 @@ index 8fcf04b..032bc7c 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1726,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1754,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2451,7 +2487,7 @@ index 8fcf04b..032bc7c 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1758,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1786,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2494,7 +2530,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1799,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1827,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2525,7 +2561,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1832,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1860,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2542,7 +2578,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1857,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1885,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2551,7 +2587,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1868,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1896,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2733,7 +2769,7 @@ index 8fcf04b..032bc7c 100644 }; } -@@ -423,10 +2074,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2102,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2884,7 +2920,7 @@ index 8fcf04b..032bc7c 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2229,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2257,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2902,7 +2938,7 @@ index 8fcf04b..032bc7c 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2250,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2278,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2922,7 +2958,7 @@ index 8fcf04b..032bc7c 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2268,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2296,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2946,7 +2982,7 @@ index 8fcf04b..032bc7c 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2301,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2329,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2970,7 +3006,7 @@ index 8fcf04b..032bc7c 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2374,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2402,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2991,7 +3027,7 @@ index 8fcf04b..032bc7c 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2398,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2426,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3016,7 +3052,7 @@ index 8fcf04b..032bc7c 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2431,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2459,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3037,7 +3073,7 @@ index 8fcf04b..032bc7c 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2501,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2529,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3224,7 +3260,7 @@ index 8fcf04b..032bc7c 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2671,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2699,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3387,7 +3423,9 @@ index 8fcf04b..032bc7c 100644 - const src = fs.readFileSync(podspecPath, 'utf8'); + let shimRaw = null; + if (choice.reader === 'ruby') { -+ shimRaw = runPodspecShim(podspecPath).raw; ++ shimRaw = runPodspecShim(podspecPath, { ++ interpreter: choice.interpreter, ++ }).raw; + // $FlowFixMe[prop-missing] the shim's dynamic shape + const rnXtool = shimRaw.__rn_xtool__; + used = { @@ -3516,7 +3554,7 @@ index 8fcf04b..032bc7c 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2954,13 @@ function readPodspecNames( +@@ -794,12 +2984,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3531,7 +3569,7 @@ index 8fcf04b..032bc7c 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2978,9 @@ function readPodspecNames( +@@ -817,8 +3008,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3543,7 +3581,7 @@ index 8fcf04b..032bc7c 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2996,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3026,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index e9844ba..f9cfffb 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -51,10 +51,10 @@ index 872450e..79dd476 100644 } diff --git a/node_modules/react-native/scripts/spm/read-podspec-shim.rb b/node_modules/react-native/scripts/spm/read-podspec-shim.rb new file mode 100644 -index 0000000..2bd1819 +index 0000000..8fb9e73 --- /dev/null +++ b/node_modules/react-native/scripts/spm/read-podspec-shim.rb -@@ -0,0 +1,519 @@ +@@ -0,0 +1,527 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + @@ -62,18 +62,25 @@ index 0000000..2bd1819 +# DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). +# +# ruby read-podspec-shim.rb --probe -+# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. ++# prints {"ruby":"","floor":"","usable":true,"interpreter":""}, or "usable":false with a ++# "why", and exits 0. The interpreter is the absolute path of the Ruby that ran (RbConfig.ruby): reads run it, not ++# whatever `ruby` a version manager's shim picks in the podspec's folder. +# ruby read-podspec-shim.rb +# run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. +# Nothing of the shim's own goes to stdout; the podspec's prints do. +# +# Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. + ++require 'rbconfig' ++ +RN_XTOOL_RUBY_FLOOR = '2.7.0' +if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 + why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" + abort why unless ARGV == ['--probe'] -+ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) ++ # Without `json`, which this Ruby may not load: the path escaped as a JSON string by hand. ++ interpreter = RbConfig.ruby.gsub(/[\\"]/) { |c| "\\#{c}" }.gsub(/[\x00-\x1f]/) { |c| format('\\u%04x', c.ord) } ++ puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}",) + ++ %("interpreter":"#{interpreter}"}) + exit 0 +end + @@ -85,7 +92,8 @@ index 0000000..2bd1819 +require 'json' + +if ARGV == ['--probe'] -+ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) ++ puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true, ++ 'interpreter' => RbConfig.ruby) + exit 0 +end + @@ -575,7 +583,7 @@ index 0000000..2bd1819 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..032bc7c 100644 +index 8fcf04b..87225cc 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -604,7 +612,7 @@ index 8fcf04b..032bc7c 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1681 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1709 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -659,9 +667,17 @@ index 8fcf04b..032bc7c 100644 + +/*:: +type PodspecReaderChoice = -+ | {reader: 'ruby', ruby: string, forced: false, warning: ?string} ++ | { ++ reader: 'ruby', ++ ruby: string, ++ interpreter?: string, ++ forced: false, ++ warning: ?string, ++ } + | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; -+type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; ++type RubyProbe = ++ | {usable: true, ruby: string, interpreter?: string} ++ | {usable: false, why: string}; +*/ + +const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); @@ -766,16 +782,21 @@ index 8fcf04b..032bc7c 100644 + answer = null; + } + if (answer?.usable === true && typeof answer.ruby === 'string') { -+ return {usable: true, ruby: answer.ruby}; ++ // The absolute path of the Ruby that answered: a version manager's ++ // `ruby` shim on PATH may pick another one in the podspec's folder. ++ return typeof answer.interpreter === 'string' && ++ path.isAbsolute(answer.interpreter) ++ ? {usable: true, ruby: answer.ruby, interpreter: answer.interpreter} ++ : {usable: true, ruby: answer.ruby}; + } + if (answer?.usable === false && typeof answer.why === 'string') { + return {usable: false, why: answer.why}; + } -+ } + } + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; - } ++ } + let detail; + if (stderr.length > 0) { + detail = stderr[0]; @@ -830,9 +851,18 @@ index 8fcf04b..032bc7c 100644 + probe = probeRuby(shim, env); + rubyProbes.set(key, probe); + } -+ return probe.usable -+ ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} -+ : {reader: 'reduced', why: probe.why, forced: false, warning}; ++ if (!probe.usable) { ++ return {reader: 'reduced', why: probe.why, forced: false, warning}; ++ } ++ return probe.interpreter != null ++ ? { ++ reader: 'ruby', ++ ruby: probe.ruby, ++ interpreter: probe.interpreter, ++ forced: false, ++ warning, ++ } ++ : {reader: 'ruby', ruby: probe.ruby, forced: false, warning}; +} + +// The app's `ios/` folder, CocoaPods' installation root for the podspec: @@ -849,12 +879,18 @@ index 8fcf04b..032bc7c 100644 +} + +// Runs the podspec with Ruby through the shim, in the podspec's folder, with -+// an empty stdin and `podspecChildEnv`: its model, and what it printed. ++// an empty stdin and `podspecChildEnv`: its model, and what it printed. The ++// Ruby is `opts.interpreter`, the one the probe found, else `ruby` on PATH. +function runPodspecShim( + podspecPath /*: string */, -+ opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, ++ opts /*: { ++ timeoutMs?: number, ++ installationRoot?: string, ++ interpreter?: ?string, ++ } */ = {}, +) /*: {raw: RawSpec, output: string} */ { + const podspec = path.resolve(podspecPath); ++ const ruby = opts.interpreter ?? 'ruby'; + const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; + const root = opts.installationRoot ?? installationRootFor(podspec); + const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); @@ -863,7 +899,7 @@ index 8fcf04b..032bc7c 100644 + let written = null; try { - result = spawnSync('pod', ['ipc', 'spec', patchedPath], { -+ result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { ++ result = spawnSync(ruby, [PODSPEC_SHIM, podspec, out, root], { + cwd: path.dirname(podspec), encoding: 'utf8', - timeout: 30000, @@ -1094,8 +1130,10 @@ index 8fcf04b..032bc7c 100644 + return h; + } + return v; -+} -+ + } + +-function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { +- if (patchedPath == null) return; +// The source-glob fields an unevaluated expression must not reach silently. +const STRICT_FIELDS /*: Set */ = new Set([ + 'source_files', @@ -1174,7 +1212,7 @@ index 8fcf04b..032bc7c 100644 + } + } + return null; - } ++} +const PLATFORM_SCOPES /*: Set */ = new Set([ + 'ios', + 'osx', @@ -1183,9 +1221,7 @@ index 8fcf04b..032bc7c 100644 + 'visionos', + 'watchos', +]); - --function cleanupPatchedPodspec(patchedPath /*: ?string */) /*: void */ { -- if (patchedPath == null) return; ++ +// Tokens of one Ruby expression. A double-quoted string keeps its parts: +// literal text and the source of each `#{...}`. +function tokenizeRubyExpr(src /*: string */) /*: Array */ { @@ -2420,7 +2456,7 @@ index 8fcf04b..032bc7c 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1726,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1754,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2451,7 +2487,7 @@ index 8fcf04b..032bc7c 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1758,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1786,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2494,7 +2530,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1799,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1827,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2525,7 +2561,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1832,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1860,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2542,7 +2578,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1857,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1885,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2551,7 +2587,7 @@ index 8fcf04b..032bc7c 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1868,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1896,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2733,7 +2769,7 @@ index 8fcf04b..032bc7c 100644 }; } -@@ -423,10 +2074,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2102,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2884,7 +2920,7 @@ index 8fcf04b..032bc7c 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2229,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2257,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2902,7 +2938,7 @@ index 8fcf04b..032bc7c 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2250,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2278,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2922,7 +2958,7 @@ index 8fcf04b..032bc7c 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2268,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2296,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2946,7 +2982,7 @@ index 8fcf04b..032bc7c 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2301,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2329,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -2970,7 +3006,7 @@ index 8fcf04b..032bc7c 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2374,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2402,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -2991,7 +3027,7 @@ index 8fcf04b..032bc7c 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2398,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2426,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3016,7 +3052,7 @@ index 8fcf04b..032bc7c 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2431,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2459,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3037,7 +3073,7 @@ index 8fcf04b..032bc7c 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2501,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2529,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3224,7 +3260,7 @@ index 8fcf04b..032bc7c 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2671,262 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2699,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3387,7 +3423,9 @@ index 8fcf04b..032bc7c 100644 - const src = fs.readFileSync(podspecPath, 'utf8'); + let shimRaw = null; + if (choice.reader === 'ruby') { -+ shimRaw = runPodspecShim(podspecPath).raw; ++ shimRaw = runPodspecShim(podspecPath, { ++ interpreter: choice.interpreter, ++ }).raw; + // $FlowFixMe[prop-missing] the shim's dynamic shape + const rnXtool = shimRaw.__rn_xtool__; + used = { @@ -3516,7 +3554,7 @@ index 8fcf04b..032bc7c 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2954,13 @@ function readPodspecNames( +@@ -794,12 +2984,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3531,7 +3569,7 @@ index 8fcf04b..032bc7c 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +2978,9 @@ function readPodspecNames( +@@ -817,8 +3008,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3543,7 +3581,7 @@ index 8fcf04b..032bc7c 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +2996,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3026,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/src/tools/podspecReader.ts b/src/tools/podspecReader.ts index 33d30ff..fdc1b72 100644 --- a/src/tools/podspecReader.ts +++ b/src/tools/podspecReader.ts @@ -5,7 +5,7 @@ import { packageRoot } from "./exec.js"; /** Which reader the vendored scaffolder reads podspecs with (`podspecReader` in vendor/rn-spm/spm/read-podspec.js). */ export type PodspecReaderChoice = - | { reader: "ruby"; ruby: string; forced: false; warning: string | null } + | { reader: "ruby"; ruby: string; interpreter?: string; forced: false; warning: string | null } | { reader: "reduced"; why: string; forced: boolean; warning: string | null }; type PodspecReader = (opts: { env?: NodeJS.ProcessEnv }) => PodspecReaderChoice; diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index a0ef778..04fed69 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -1,4 +1,4 @@ -import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { accessSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; @@ -130,6 +130,17 @@ describe("the podspec reader's choice", () => { }); }); + it("keeps the interpreter the probe names", () => { + const bin = fakeRuby(`echo '{"ruby":"9.9.9","floor":"2.7.0","usable":true,"interpreter":"/opt/rubies/9.9.9/bin/ruby"}'`); + expect(podspecReader({ env: { PATH: bin } })).toEqual({ + reader: "ruby", + ruby: "9.9.9", + interpreter: "/opt/rubies/9.9.9/bin/ruby", + forced: false, + warning: null, + }); + }); + it("probes Ruby once per PATH", () => { const counter = path.join(tempDir(), "probes"); const bin = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); @@ -141,6 +152,27 @@ describe("the podspec reader's choice", () => { }); }); +describe("the interpreter a read runs", () => { + it("runs the podspec with the interpreter the probe named, not the ruby on PATH", () => { + const rn = tempDir(); + writeFileSync(path.join(rn, "package.json"), JSON.stringify({ name: "react-native", version: "0.86.3" })); + vi.stubEnv("RN_SPM_RN_ROOT", rn); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + vi.stubEnv("RN_SPM_PODSPEC_READS", undefined); + // The interpreter: writes a model to ($3). + const real = path.join(tempDir(), "ruby-9.9.9"); + writeFileSync(real, `#!/bin/sh\necho '{"name":"Foo","source_files":"pinned/**/*.m"}' > "$3"\n`); + chmodSync(real, 0o755); + // The `ruby` on PATH: answers the probe with that interpreter, and fails any read it is given. + const bin = fakeRuby( + `if [ "$2" = --probe ]; then echo '{"ruby":"9.9.9","floor":"2.7.0","usable":true,"interpreter":"${real}"}'; ` + + `else echo "the ruby on PATH ran the podspec" >&2; exit 7; fi`, + ); + vi.stubEnv("PATH", `${bin}:${process.env.PATH}`); + expect(readPodspec(library(spec())).sourceFiles).toEqual(["pinned/**/*.m"]); + }); +}); + describe("the podspec's installation root", () => { it("finds the installation root", () => { vi.stubEnv("RN_SPM_APP_IOS_DIR", "/a/ios"); @@ -274,6 +306,13 @@ describe.skipIf(needsRuby !== "")(`readPodspec${needsRuby}`, () => { }); const forceReduced = () => vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced"); + it("pins the Ruby this machine's probe finds", () => { + const choice = podspecReader({ env: { PATH: process.env.PATH } }); + expect(choice.reader).toBe("ruby"); + expect(path.isAbsolute(choice.interpreter)).toBe(true); + accessSync(choice.interpreter, constants.X_OK); + }); + it("reads with Ruby and says so", () => { const podspec = library(spec(' s.version = "1.0.0"', ' s.source_files = "ios/**/*.{h,m}"')); expect(readPodspec(podspec)).toMatchObject({ diff --git a/tests/podspecShim.test.ts b/tests/podspecShim.test.ts index 4ec8978..ab7b8ce 100644 --- a/tests/podspecShim.test.ts +++ b/tests/podspecShim.test.ts @@ -1,4 +1,4 @@ -import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { accessSync, constants, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { packageRoot } from "../src/tools/exec.js"; @@ -18,8 +18,20 @@ const NEEDS_RN = RN_LINES.map((line) => needsTarball(line)).find((needs) => need const WORKLETS = path.join(packageRoot(), "tests", "fixtures", "podspecs", "RNWorklets-0.8.3"); describe.skipIf(needsRuby !== "")(`the podspec shim${needsRuby}`, () => { - it("--probe prints the Ruby version and the floor", () => { - expect(JSON.parse(tool("ruby", [SHIM, "--probe"]).stdout)).toEqual({ ruby: expect.stringMatching(/^\d+\.\d+\.\d+/), floor: "2.7.0", usable: true }); + it("--probe prints the Ruby version, the floor and the interpreter", () => { + const probe = JSON.parse(tool("ruby", [SHIM, "--probe"]).stdout); + expect(probe).toEqual({ ruby: expect.stringMatching(/^\d+\.\d+\.\d+/), floor: "2.7.0", usable: true, interpreter: expect.any(String) }); + expect(path.isAbsolute(probe.interpreter)).toBe(true); + accessSync(probe.interpreter, constants.X_OK); + }); + + it("--probe names the interpreter below the floor too", () => { + const shim = path.join(tempDir(), "read-podspec-shim.rb"); + writeFileSync(shim, readFileSync(SHIM, "utf8").replace("RN_XTOOL_RUBY_FLOOR = '2.7.0'", "RN_XTOOL_RUBY_FLOOR = '99.0.0'")); + const probe = JSON.parse(tool("ruby", [shim, "--probe"]).stdout); + expect(probe).toMatchObject({ floor: "99.0.0", usable: false, why: `ruby ${probe.ruby} is older than 99.0.0` }); + expect(probe.interpreter).toEqual(expect.any(String)); + expect(probe.interpreter).toBe(JSON.parse(tool("ruby", [SHIM, "--probe"]).stdout).interpreter); }); it("writes the spec in CocoaPods' JSON form", () => { diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index 3f85030..ebd689f 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -190,7 +190,7 @@ --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2882,9 +2882,15 @@ +@@ -2912,9 +2912,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec-shim.rb b/vendor/rn-spm/spm/read-podspec-shim.rb index 2bd1819..8fb9e73 100644 --- a/vendor/rn-spm/spm/read-podspec-shim.rb +++ b/vendor/rn-spm/spm/read-podspec-shim.rb @@ -5,18 +5,25 @@ # DSL, and writes the spec in CocoaPods' JSON form (what `pod ipc spec` prints). # # ruby read-podspec-shim.rb --probe -# prints {"ruby":"","floor":"","usable":true}, or "usable":false with a "why", and exits 0. +# prints {"ruby":"","floor":"","usable":true,"interpreter":""}, or "usable":false with a +# "why", and exits 0. The interpreter is the absolute path of the Ruby that ran (RbConfig.ruby): reads run it, not +# whatever `ruby` a version manager's shim picks in the podspec's folder. # ruby read-podspec-shim.rb # run in the podspec's folder: exits 0 with the model in , or 1 with {"error":{"kind","message"}} in it. # Nothing of the shim's own goes to stdout; the podspec's prints do. # # Ruby 2.7 syntax only: on an older Ruby the file must still parse, so that the floor check can say why it stops. +require 'rbconfig' + RN_XTOOL_RUBY_FLOOR = '2.7.0' if (RUBY_VERSION.split('.').map(&:to_i) <=> RN_XTOOL_RUBY_FLOOR.split('.').map(&:to_i)) < 0 why = "ruby #{RUBY_VERSION} is older than #{RN_XTOOL_RUBY_FLOOR}" abort why unless ARGV == ['--probe'] - puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}"}) + # Without `json`, which this Ruby may not load: the path escaped as a JSON string by hand. + interpreter = RbConfig.ruby.gsub(/[\\"]/) { |c| "\\#{c}" }.gsub(/[\x00-\x1f]/) { |c| format('\\u%04x', c.ord) } + puts %({"ruby":"#{RUBY_VERSION}","floor":"#{RN_XTOOL_RUBY_FLOOR}","usable":false,"why":"#{why}",) + + %("interpreter":"#{interpreter}"}) exit 0 end @@ -28,7 +35,8 @@ require 'json' if ARGV == ['--probe'] - puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true) + puts JSON.generate('ruby' => RUBY_VERSION, 'floor' => RN_XTOOL_RUBY_FLOOR, 'usable' => true, + 'interpreter' => RbConfig.ruby) exit 0 end diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 2d2eb43..d7940da 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -49,9 +49,17 @@ type RawSpec = {[string]: unknown}; /*:: type PodspecReaderChoice = - | {reader: 'ruby', ruby: string, forced: false, warning: ?string} + | { + reader: 'ruby', + ruby: string, + interpreter?: string, + forced: false, + warning: ?string, + } | {reader: 'reduced', why: string, forced: boolean, warning: ?string}; -type RubyProbe = {usable: true, ruby: string} | {usable: false, why: string}; +type RubyProbe = + | {usable: true, ruby: string, interpreter?: string} + | {usable: false, why: string}; */ const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); @@ -144,7 +152,12 @@ function probeRuby( answer = null; } if (answer?.usable === true && typeof answer.ruby === 'string') { - return {usable: true, ruby: answer.ruby}; + // The absolute path of the Ruby that answered: a version manager's + // `ruby` shim on PATH may pick another one in the podspec's folder. + return typeof answer.interpreter === 'string' && + path.isAbsolute(answer.interpreter) + ? {usable: true, ruby: answer.ruby, interpreter: answer.interpreter} + : {usable: true, ruby: answer.ruby}; } if (answer?.usable === false && typeof answer.why === 'string') { return {usable: false, why: answer.why}; @@ -208,9 +221,18 @@ function podspecReader( probe = probeRuby(shim, env); rubyProbes.set(key, probe); } - return probe.usable - ? {reader: 'ruby', ruby: probe.ruby, forced: false, warning} - : {reader: 'reduced', why: probe.why, forced: false, warning}; + if (!probe.usable) { + return {reader: 'reduced', why: probe.why, forced: false, warning}; + } + return probe.interpreter != null + ? { + reader: 'ruby', + ruby: probe.ruby, + interpreter: probe.interpreter, + forced: false, + warning, + } + : {reader: 'ruby', ruby: probe.ruby, forced: false, warning}; } // The app's `ios/` folder, CocoaPods' installation root for the podspec: @@ -227,12 +249,18 @@ function installationRootFor(podspecPath /*: string */) /*: string */ { } // Runs the podspec with Ruby through the shim, in the podspec's folder, with -// an empty stdin and `podspecChildEnv`: its model, and what it printed. +// an empty stdin and `podspecChildEnv`: its model, and what it printed. The +// Ruby is `opts.interpreter`, the one the probe found, else `ruby` on PATH. function runPodspecShim( podspecPath /*: string */, - opts /*: {timeoutMs?: number, installationRoot?: string} */ = {}, + opts /*: { + timeoutMs?: number, + installationRoot?: string, + interpreter?: ?string, + } */ = {}, ) /*: {raw: RawSpec, output: string} */ { const podspec = path.resolve(podspecPath); + const ruby = opts.interpreter ?? 'ruby'; const timeoutMs = opts.timeoutMs ?? PODSPEC_TIMEOUT_MS; const root = opts.installationRoot ?? installationRootFor(podspec); const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rn-xtool-podspec-')); @@ -240,7 +268,7 @@ function runPodspecShim( let result; let written = null; try { - result = spawnSync('ruby', [PODSPEC_SHIM, podspec, out, root], { + result = spawnSync(ruby, [PODSPEC_SHIM, podspec, out, root], { cwd: path.dirname(podspec), encoding: 'utf8', env: podspecChildEnv(process.env), @@ -2810,7 +2838,9 @@ function readPodspecWith( try { let shimRaw = null; if (choice.reader === 'ruby') { - shimRaw = runPodspecShim(podspecPath).raw; + shimRaw = runPodspecShim(podspecPath, { + interpreter: choice.interpreter, + }).raw; // $FlowFixMe[prop-missing] the shim's dynamic shape const rnXtool = shimRaw.__rn_xtool__; used = { From 3071846325c4991ef479bedad82708ab60f7172b Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:27:42 -0600 Subject: [PATCH 40/53] fix: give each podspec read 120 s --- docs/troubleshooting.md | 2 +- docs/upstream/react-native-scaffolder.md | 4 +- patches/react-native+0.88.0.patch | 48 +++++++++++++----------- patches/react-native+0.88.1.patch | 48 +++++++++++++----------- tests/podspecReader.test.ts | 7 +++- vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 6 ++- 7 files changed, 67 insertions(+), 50 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 5f62162..87a3f34 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1040,7 +1040,7 @@ with the reduced reader; sudo apt install ruby`). not have, often a typo); - `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2` (a `require` of a gem); - `: the podspec does not evaluate to a Pod::Spec`; - - ` did not finish in 30 s.` + - ` did not finish in 120 s.` When the failing line is in another of the library's files, `:` reads ` (:)`; when Ruby keeps no line, it is `` alone. A podspec that raises an error of its own (`raise`, `abort`) stops diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 5c62b6a..894a9d3 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -888,7 +888,7 @@ the rest with a warning, such as react-native-gesture-handler 3.3.0's `-DRNGH_US on a machine with CocoaPods, and an incomplete one on a machine without. Fix: the podspec runs in real Ruby. `read-podspec-shim.rb`, next to `read-podspec.js`, is run by the system `ruby` -(2.7 or later, standard library only) once per podspec, in the podspec's folder, with an empty stdin, a 30 s timeout +(2.7 or later, standard library only) once per podspec, in the podspec's folder, with an empty stdin, a 120 s timeout and an environment of `PATH`, `HOME`, `LANG` and fix 19's two variables (`RCT_NEW_ARCH_ENABLED=1`, `RCT_HERMES_V1_ENABLED=1`). It evaluates the podspec inside `module Pod`, as CocoaPods-core does, against a `Pod::Specification` with the attributes of CocoaPods 1.16's DSL (a setter and a getter each, the singular aliases @@ -921,7 +921,7 @@ helpers stay undefined, and a call to one fails as `method`. A podspec Ruby cannot read stops the read with a `PodspecReadError`; nothing falls back. A gap of the shim names where it stopped (`:`, or ` (:)` in another of the library's files): `method` (the podspec calls `(…)`, which the reader does not model), `constant`, `attribute` (one CocoaPods does not define), -`require` (a gem other than `colored2`) or `not-a-spec`. Its message, like a podspec that does not finish in 30 s, +`require` (a gem other than `colored2`) or `not-a-spec`. Its message, like a podspec that does not finish in 120 s, ends with `Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report.` A podspec's own `raise`, `abort`, `exit` or syntax error (`raised`) keeps Ruby's message, and a Ruby that ends without a model says `ruby exited with ` with its last stderr line. Without a diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index f9cfffb..3b6caec 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..87225cc 100644 +index 8fcf04b..2582a16 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -612,7 +612,7 @@ index 8fcf04b..87225cc 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1709 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1712 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -683,7 +683,10 @@ index 8fcf04b..87225cc 100644 +const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); +const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; +const RUBY_PROBE_TIMEOUT_MS = 10000; -+const PODSPEC_TIMEOUT_MS = 30000; ++// Generous: a podspec may copy prebuilt frameworks while it is read ++// (react-native-skia's copies hundreds of MB), and a slow disk needs the ++// time. A podspec that hangs costs this once. ++const PODSPEC_TIMEOUT_MS = 120000; +// What a read that stopped on a gap of the shim, or a podspec that did not +// finish, says to do next. A podspec's own `raise` keeps the shim's message. +const PODSPEC_READ_REMEDY = @@ -2456,7 +2459,7 @@ index 8fcf04b..87225cc 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1754,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1757,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2487,7 +2490,7 @@ index 8fcf04b..87225cc 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1786,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1789,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2530,7 +2533,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1827,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1830,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2561,7 +2564,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1860,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1863,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2578,7 +2581,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1885,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1888,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2587,7 +2590,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1896,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1899,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2769,7 +2772,7 @@ index 8fcf04b..87225cc 100644 }; } -@@ -423,10 +2102,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2105,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2920,7 +2923,7 @@ index 8fcf04b..87225cc 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2257,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2260,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2938,7 +2941,7 @@ index 8fcf04b..87225cc 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2278,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2281,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2958,7 +2961,7 @@ index 8fcf04b..87225cc 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2296,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2299,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2982,7 +2985,7 @@ index 8fcf04b..87225cc 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2329,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2332,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -3006,7 +3009,7 @@ index 8fcf04b..87225cc 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2402,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2405,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -3027,7 +3030,7 @@ index 8fcf04b..87225cc 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2426,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2429,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3052,7 +3055,7 @@ index 8fcf04b..87225cc 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2459,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2462,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3073,7 +3076,7 @@ index 8fcf04b..87225cc 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2529,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2532,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3260,7 +3263,7 @@ index 8fcf04b..87225cc 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2699,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2702,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3554,7 +3557,7 @@ index 8fcf04b..87225cc 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2984,13 @@ function readPodspecNames( +@@ -794,12 +2987,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3569,7 +3572,7 @@ index 8fcf04b..87225cc 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3008,9 @@ function readPodspecNames( +@@ -817,8 +3011,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3581,13 +3584,14 @@ index 8fcf04b..87225cc 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3026,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3029,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, + installationRootFor, + isPodspecReadError, + PodspecReadError, ++ PODSPEC_TIMEOUT_MS, + podspecReader, readPodspec, readPodspecCached, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index f9cfffb..3b6caec 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..87225cc 100644 +index 8fcf04b..2582a16 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -612,7 +612,7 @@ index 8fcf04b..87225cc 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1709 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1712 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -683,7 +683,10 @@ index 8fcf04b..87225cc 100644 +const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); +const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; +const RUBY_PROBE_TIMEOUT_MS = 10000; -+const PODSPEC_TIMEOUT_MS = 30000; ++// Generous: a podspec may copy prebuilt frameworks while it is read ++// (react-native-skia's copies hundreds of MB), and a slow disk needs the ++// time. A podspec that hangs costs this once. ++const PODSPEC_TIMEOUT_MS = 120000; +// What a read that stopped on a gap of the shim, or a podspec that did not +// finish, says to do next. A podspec's own `raise` keeps the shim's message. +const PODSPEC_READ_REMEDY = @@ -2456,7 +2459,7 @@ index 8fcf04b..87225cc 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1754,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1757,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2487,7 +2490,7 @@ index 8fcf04b..87225cc 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1786,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1789,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2530,7 +2533,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1827,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1830,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2561,7 +2564,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1860,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1863,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2578,7 +2581,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1885,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1888,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2587,7 +2590,7 @@ index 8fcf04b..87225cc 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1896,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1899,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2769,7 +2772,7 @@ index 8fcf04b..87225cc 100644 }; } -@@ -423,10 +2102,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2105,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2920,7 +2923,7 @@ index 8fcf04b..87225cc 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2257,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2260,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2938,7 +2941,7 @@ index 8fcf04b..87225cc 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2278,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2281,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2958,7 +2961,7 @@ index 8fcf04b..87225cc 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2296,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2299,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2982,7 +2985,7 @@ index 8fcf04b..87225cc 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2329,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2332,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -3006,7 +3009,7 @@ index 8fcf04b..87225cc 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2402,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2405,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -3027,7 +3030,7 @@ index 8fcf04b..87225cc 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2426,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2429,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3052,7 +3055,7 @@ index 8fcf04b..87225cc 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2459,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2462,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3073,7 +3076,7 @@ index 8fcf04b..87225cc 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2529,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2532,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3260,7 +3263,7 @@ index 8fcf04b..87225cc 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2699,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2702,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3554,7 +3557,7 @@ index 8fcf04b..87225cc 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2984,13 @@ function readPodspecNames( +@@ -794,12 +2987,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3569,7 +3572,7 @@ index 8fcf04b..87225cc 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3008,9 @@ function readPodspecNames( +@@ -817,8 +3011,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3581,13 +3584,14 @@ index 8fcf04b..87225cc 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3026,16 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3029,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, + installationRootFor, + isPodspecReadError, + PodspecReadError, ++ PODSPEC_TIMEOUT_MS, + podspecReader, readPodspec, readPodspecCached, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 04fed69..3f48b55 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -15,7 +15,7 @@ const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); const readPodspecJs = req("./read-podspec.js"); const { podspecReader, runPodspecShim, isPodspecReadError, installationRootFor } = readPodspecJs; const { readPodspec, readPodspecCached, unresolvedSourcesReason } = readPodspecJs; -const { flattenSubspecs, findPodspecs, spmDependencyReason } = readPodspecJs; +const { flattenSubspecs, findPodspecs, spmDependencyReason, PODSPEC_TIMEOUT_MS } = readPodspecJs; const { scaffoldPackageSwiftForDep } = req("./scaffold-package-swift.js"); const REMEDY = "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report."; @@ -226,6 +226,11 @@ describe.skipIf(needsRuby !== "")(`running the podspec shim${needsRuby}`, () => expect(Date.now() - start).toBeLessThan(5000); }); + it("gives a podspec 120 s by default", () => { + // skia's podspec copies its prebuilt frameworks (hundreds of MB) while it is read: a slow disk needs the time. + expect(PODSPEC_TIMEOUT_MS).toBe(120_000); + }); + it("stops a podspec that does not finish", () => { const podspec = library(spec(" sleep 5")); const e = thrown(() => runPodspecShim(podspec, { timeoutMs: 1000 })); diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index ebd689f..4836107 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -190,7 +190,7 @@ --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2912,9 +2912,15 @@ +@@ -2915,9 +2915,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index d7940da..a50696f 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -65,7 +65,10 @@ type RubyProbe = const PODSPEC_SHIM = path.join(__dirname, 'read-podspec-shim.rb'); const PODSPEC_READER_VAR = 'RN_XTOOL_PODSPEC_READER'; const RUBY_PROBE_TIMEOUT_MS = 10000; -const PODSPEC_TIMEOUT_MS = 30000; +// Generous: a podspec may copy prebuilt frameworks while it is read +// (react-native-skia's copies hundreds of MB), and a slow disk needs the +// time. A podspec that hangs costs this once. +const PODSPEC_TIMEOUT_MS = 120000; // What a read that stopped on a gap of the shim, or a podspec that did not // finish, says to do next. A podspec's own `raise` keeps the shim's message. const PODSPEC_READ_REMEDY = @@ -3035,6 +3038,7 @@ module.exports = { installationRootFor, isPodspecReadError, PodspecReadError, + PODSPEC_TIMEOUT_MS, podspecReader, readPodspec, readPodspecCached, From c3694d359e492c78b29ca8965a8529481d901a48 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:28:48 -0600 Subject: [PATCH 41/53] fix: stop rn-spm on reader plumbing errors --- docs/upstream/react-native-scaffolder.md | 5 ++++- patches/react-native+0.88.0.patch | 24 +++++++++++++++++------- patches/react-native+0.88.1.patch | 24 +++++++++++++++++------- tests/podspecReader.test.ts | 23 +++++++++++++++++++++++ vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 14 ++++++++++++-- 6 files changed, 74 insertions(+), 18 deletions(-) diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 894a9d3..1998160 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -924,7 +924,10 @@ podspec calls `(…)`, which the reader does not model), `constant`, `attr `require` (a gem other than `colored2`) or `not-a-spec`. Its message, like a podspec that does not finish in 120 s, ends with `Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor --report.` A podspec's own `raise`, `abort`, `exit` or syntax error (`raised`) keeps Ruby's message, -and a Ruby that ends without a model says `ruby exited with ` with its last stderr line. Without a +and a Ruby that ends without a model says `ruby exited with ` with its last stderr line. A failure +of the reader's own (no temp folder for the shim's out file, a podspec it cannot read) stops the read the same way, +as `: rn-xtool could not run the podspec reader: ` (kind `exit`), so the autolinking callers stop on it +too. Without a usable Ruby (none, older than 2.7, no `json`, the shim missing), or with `RN_XTOOL_PODSPEC_READER=reduced`, fix 28's evaluator reads the podspec as before, and `podspecReader()` says why; another value of the variable is named in a warning and ignored. `name`, `module_name` and `version` stay the literal readings under both readers. diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 3b6caec..1f6faba 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..2582a16 100644 +index 8fcf04b..63eea08 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -3263,7 +3263,7 @@ index 8fcf04b..2582a16 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2702,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2702,274 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3462,8 +3462,18 @@ index 8fcf04b..2582a16 100644 + recordPodspecRead(podspecPath, choice, used, null); + return model; + } catch (e) { -+ recordPodspecRead(podspecPath, choice, used, e); -+ throw e; ++ // The reader's own plumbing (a temp folder, a file it cannot read) stops ++ // the run like a podspec Ruby cannot read: the autolinking callers ++ // rethrow only a PodspecReadError. ++ const error = isPodspecReadError(e) ++ ? e ++ : new PodspecReadError( ++ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + ++ `reader: ${e instanceof Error ? e.message : String(e)}`, ++ 'exit', ++ ); ++ recordPodspecRead(podspecPath, choice, used, error); ++ throw error; + } +} + @@ -3557,7 +3567,7 @@ index 8fcf04b..2582a16 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2987,13 @@ function readPodspecNames( +@@ -794,12 +2997,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3572,7 +3582,7 @@ index 8fcf04b..2582a16 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3011,9 @@ function readPodspecNames( +@@ -817,8 +3021,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3584,7 +3594,7 @@ index 8fcf04b..2582a16 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3029,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3039,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 3b6caec..1f6faba 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..2582a16 100644 +index 8fcf04b..63eea08 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -3263,7 +3263,7 @@ index 8fcf04b..2582a16 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2702,264 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2702,274 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3462,8 +3462,18 @@ index 8fcf04b..2582a16 100644 + recordPodspecRead(podspecPath, choice, used, null); + return model; + } catch (e) { -+ recordPodspecRead(podspecPath, choice, used, e); -+ throw e; ++ // The reader's own plumbing (a temp folder, a file it cannot read) stops ++ // the run like a podspec Ruby cannot read: the autolinking callers ++ // rethrow only a PodspecReadError. ++ const error = isPodspecReadError(e) ++ ? e ++ : new PodspecReadError( ++ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + ++ `reader: ${e instanceof Error ? e.message : String(e)}`, ++ 'exit', ++ ); ++ recordPodspecRead(podspecPath, choice, used, error); ++ throw error; + } +} + @@ -3557,7 +3567,7 @@ index 8fcf04b..2582a16 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2987,13 @@ function readPodspecNames( +@@ -794,12 +2997,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3572,7 +3582,7 @@ index 8fcf04b..2582a16 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3011,9 @@ function readPodspecNames( +@@ -817,8 +3021,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3584,7 +3594,7 @@ index 8fcf04b..2582a16 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3029,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3039,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 3f48b55..515e98c 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -173,6 +173,29 @@ describe("the interpreter a read runs", () => { }); }); +describe("the reader's own failures", () => { + it("stop the read as a PodspecReadError and are recorded", () => { + const rn = tempDir(); + writeFileSync(path.join(rn, "package.json"), JSON.stringify({ name: "react-native", version: "0.86.3" })); + vi.stubEnv("RN_SPM_RN_ROOT", rn); + vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined); + const reads = path.join(tempDir(), "reads.jsonl"); + vi.stubEnv("RN_SPM_PODSPEC_READS", reads); + vi.stubEnv("PATH", fakeRuby(`echo '{"ruby":"9.9.9","floor":"2.7.0","usable":true}'`)); + const podspec = library(spec()); + // No temp folder for the shim's out file. + const gone = path.join(tempDir(), "gone"); + vi.stubEnv("TMPDIR", gone); + const e = thrown(() => readPodspec(podspec)); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("exit"); + expect(e.message.startsWith(`${podspec}: rn-xtool could not run the podspec reader: ENOENT`)).toBe(true); + expect(e.message).toContain(gone); + const line = JSON.parse(readFileSync(reads, "utf8").trim().split("\n").pop()!); + expect(line).toMatchObject({ podspec, reader: "ruby", ok: false, error: e.message }); + }); +}); + describe("the podspec's installation root", () => { it("finds the installation root", () => { vi.stubEnv("RN_SPM_APP_IOS_DIR", "/a/ios"); diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index 4836107..13b730f 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -190,7 +190,7 @@ --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2915,9 +2915,15 @@ +@@ -2925,9 +2925,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index a50696f..2d18f08 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -2876,8 +2876,18 @@ function readPodspecWith( recordPodspecRead(podspecPath, choice, used, null); return model; } catch (e) { - recordPodspecRead(podspecPath, choice, used, e); - throw e; + // The reader's own plumbing (a temp folder, a file it cannot read) stops + // the run like a podspec Ruby cannot read: the autolinking callers + // rethrow only a PodspecReadError. + const error = isPodspecReadError(e) + ? e + : new PodspecReadError( + `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + + `reader: ${e instanceof Error ? e.message : String(e)}`, + 'exit', + ); + recordPodspecRead(podspecPath, choice, used, error); + throw error; } } From d1dd4bad2861469358b1ba2a2e9aa3be949a227f Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:30:19 -0600 Subject: [PATCH 42/53] fix: offer the escape on exit and ENV stops --- docs/troubleshooting.md | 12 +- docs/upstream/react-native-scaffolder.md | 4 +- patches/react-native+0.88.0.patch | 172 +++++++++++++---------- patches/react-native+0.88.1.patch | 172 +++++++++++++---------- tests/podspecReader.test.ts | 30 +++- vendor/rn-spm/rn-xtool-edits.patch | 2 +- vendor/rn-spm/spm/read-podspec.js | 63 ++++++--- 7 files changed, 290 insertions(+), 165 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 87a3f34..0adbffc 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1040,11 +1040,17 @@ with the reduced reader; sudo apt install ruby`). not have, often a typo); - `: cannot load such file -- ; rn-xtool's podspec reader stubs only colored2` (a `require` of a gem); - `: the podspec does not evaluate to a Pod::Spec`; - - ` did not finish in 120 s.` + - ` did not finish in 120 s.`; + - `: ruby exited with : ` or `: ruby could not run ()` + (Ruby ended without a result: out of memory, killed, or the interpreter the probe found is gone); + - `: rn-xtool could not run the podspec reader: ` (rn-xtool itself could not run the read, for + example no writable temp folder: check `TMPDIR` and the disk space); + - `:: key not found: ""` (the podspec reads an environment variable with `ENV.fetch`, and + rn-xtool gives podspecs only `PATH`, `HOME`, `LANG`, `RCT_NEW_ARCH_ENABLED` and `RCT_HERMES_V1_ENABLED`). When the failing line is in another of the library's files, `:` reads ` (:)`; - when Ruby keeps no line, it is `` alone. A podspec that raises an error of its own (`raise`, `abort`) stops - with its message after `:: ` (or `: `), without the last sentence. + when Ruby keeps no line, it is `` alone. A podspec that raises another error of its own (`raise`, `abort`) + stops with its message after `:: ` (or `: `), without the last sentence. To build for one run, set the escape on the command: `RN_XTOOL_PODSPEC_READER=reduced rn-xtool build`. `rn-spm` then prints the `⚠ RN_XTOOL_PODSPEC_READER=reduced is set` line, and `doctor --report` records the reduced reader. - **To report a podspec the reader cannot read:** run `rn-xtool doctor --report` in the project folder after the diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 1998160..5d66114 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -927,7 +927,9 @@ rn-xtool doctor --report.` A podspec's own `raise`, `abort`, `exit` or syntax er and a Ruby that ends without a model says `ruby exited with ` with its last stderr line. A failure of the reader's own (no temp folder for the shim's out file, a podspec it cannot read) stops the read the same way, as `: rn-xtool could not run the podspec reader: ` (kind `exit`), so the autolinking callers stop on it -too. Without a +too. An `exit` stop ends with the same sentence when the escape changes the reader (a Ruby read), and so does a +`raised` stop that is Ruby's `key not found: ""` from `ENV.fetch` (a name the fixed environment does not +give). Without a usable Ruby (none, older than 2.7, no `json`, the shim missing), or with `RN_XTOOL_PODSPEC_READER=reduced`, fix 28's evaluator reads the podspec as before, and `podspecReader()` says why; another value of the variable is named in a warning and ignored. `name`, `module_name` and `version` stay the literal readings under both readers. diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 1f6faba..0962458 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..63eea08 100644 +index 8fcf04b..e9843f6 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -612,7 +612,7 @@ index 8fcf04b..63eea08 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1712 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1739 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -643,22 +643,6 @@ index 8fcf04b..63eea08 100644 - .replace( - /^(\s*)install_modules_dependencies\(([^)]*)\)/gm, - '$1# install_modules_dependencies($2) # stripped for pod ipc', -- ) -- .replace( -- /^(\s*)use_react_native!\(([^)]*)\)/gm, -- '$1# use_react_native!($2) # stripped for pod ipc', -- ); -- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. -- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or -- // similar, expecting the package.json sibling. Keeping the patched file -- // in the same directory makes those reads continue to work. -- const depDir = path.dirname(podspecPath); -- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. -- // Use a dotfile prefix so the patched copy is invisible to normal listing -- // but the suffix CocoaPods requires is preserved. -- const tmpFile = path.join( -- depDir, -- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, +// The podspec reader runs each podspec with the system Ruby, against a shim of +// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' +// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, @@ -687,8 +671,10 @@ index 8fcf04b..63eea08 100644 +// (react-native-skia's copies hundreds of MB), and a slow disk needs the +// time. A podspec that hangs costs this once. +const PODSPEC_TIMEOUT_MS = 120000; -+// What a read that stopped on a gap of the shim, or a podspec that did not -+// finish, says to do next. A podspec's own `raise` keeps the shim's message. ++// What a read that stopped on a gap of the shim, a podspec that did not ++// finish, a Ruby that ended without a model (`exit`) or a name `ENV.fetch` ++// did not find says to do next. A podspec's own `raise` keeps the shim's ++// message. +const PODSPEC_READ_REMEDY = + 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + + 'for one run, and report it with rn-xtool doctor --report.'; @@ -720,6 +706,55 @@ index 8fcf04b..63eea08 100644 + return ( + e instanceof PodspecReadError || + (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') ++ ); ++} ++ ++// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's ++// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home ++// nor a `0` in the shell changes how a podspec reads. ++function podspecChildEnv( ++ env /*: {+[string]: ?string} */, ++) /*: {[string]: string} */ { ++ const child /*: {[string]: string} */ = {}; ++ for (const name of ['PATH', 'HOME', 'LANG']) { ++ const value = env[name]; ++ if (value != null) child[name] = value; ++ } ++ return {...child, ...RN_POD_ENV}; ++} ++ ++// `message`, then the escape. ++function withRemedy(message /*: string */) /*: string */ { ++ return `${message.replace(/\.$/, '')}. ${PODSPEC_READ_REMEDY}`; ++} ++ ++// Whether the shim's `raised` message for `podspec` is Ruby's KeyError of a ++// name `ENV.fetch` did not find: `: key not found: ""`, where ++// `` is ``, `:` or ` (:)`. ++function isEnvKeyError( ++ podspec /*: string */, ++ message /*: string */, ++) /*: boolean */ { ++ return ( ++ message.startsWith(podspec) && ++ /^(?::\d+| \([^)]*:\d+\))?: key not found: "/.test( ++ message.slice(podspec.length), + ) +- .replace( +- /^(\s*)use_react_native!\(([^)]*)\)/gm, +- '$1# use_react_native!($2) # stripped for pod ipc', +- ); +- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. +- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or +- // similar, expecting the package.json sibling. Keeping the patched file +- // in the same directory makes those reads continue to work. +- const depDir = path.dirname(podspecPath); +- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. +- // Use a dotfile prefix so the patched copy is invisible to normal listing +- // but the suffix CocoaPods requires is preserved. +- const tmpFile = path.join( +- depDir, +- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, ); - fs.writeFileSync(tmpFile, patched, 'utf8'); - return tmpFile; @@ -735,20 +770,6 @@ index 8fcf04b..63eea08 100644 - patchedPath = patchPodspecForPodIpc(podspecPath); - } catch { - return null; -+// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's -+// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home -+// nor a `0` in the shell changes how a podspec reads. -+function podspecChildEnv( -+ env /*: {+[string]: ?string} */, -+) /*: {[string]: string} */ { -+ const child /*: {[string]: string} */ = {}; -+ for (const name of ['PATH', 'HOME', 'LANG']) { -+ const value = env[name]; -+ if (value != null) child[name] = value; -+ } -+ return {...child, ...RN_POD_ENV}; -+} -+ +function nonEmptyLines(text /*: ?string */) /*: Array */ { + return String(text ?? '') + .split('\n') @@ -795,7 +816,7 @@ index 8fcf04b..63eea08 100644 + if (answer?.usable === false && typeof answer.why === 'string') { + return {usable: false, why: answer.why}; + } - } ++ } + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; @@ -853,7 +874,7 @@ index 8fcf04b..63eea08 100644 + if (probe == null) { + probe = probeRuby(shim, env); + rubyProbes.set(key, probe); -+ } + } + if (!probe.usable) { + return {reader: 'reduced', why: probe.why, forced: false, warning}; + } @@ -968,12 +989,14 @@ index 8fcf04b..63eea08 100644 + const error = result.error; + if (error != null && result.status == null && result.signal == null) { + throw new PodspecReadError( -+ `${podspec}: ruby could not run (${error.message})`, ++ withRemedy(`${podspec}: ruby could not run (${error.message})`), + 'exit', + ); + } + throw new PodspecReadError( -+ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ withRemedy( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ ), + 'exit', ); - return null; @@ -987,25 +1010,28 @@ index 8fcf04b..63eea08 100644 - `[read-podspec] pod ipc spec JSON parse failed (${e.message}); ` + - 'falling back to the regex parser (subspecs/helpers may be missed).', + throw new PodspecReadError( -+ `${podspec}: the podspec reader wrote no JSON (${e.message})`, ++ withRemedy(`${podspec}: the podspec reader wrote no JSON (${e.message})`), + 'exit', - ); ++ ); + } + if (model != null && typeof model.error === 'object' && model.error != null) { + const kind = String(model.error.kind); + const message = String(model.error.message); + throw new PodspecReadError( -+ SHIM_GAP_KINDS.includes(kind) -+ ? `${message}. ${PODSPEC_READ_REMEDY}` ++ SHIM_GAP_KINDS.includes(kind) || ++ (kind === 'raised' && isEnvKeyError(podspec, message)) ++ ? withRemedy(message) + : message, + kind, + ); + } + if (result.status !== 0) { + throw new PodspecReadError( -+ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ withRemedy( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ ), + 'exit', -+ ); + ); + } + return {raw: model, output: result.stdout}; +} @@ -2459,7 +2485,7 @@ index 8fcf04b..63eea08 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1757,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1784,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2490,7 +2516,7 @@ index 8fcf04b..63eea08 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1789,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1816,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2533,7 +2559,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1830,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1857,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2564,7 +2590,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1863,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1890,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2581,7 +2607,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1888,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1915,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2590,7 +2616,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1899,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1926,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2772,7 +2798,7 @@ index 8fcf04b..63eea08 100644 }; } -@@ -423,10 +2105,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2132,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2923,7 +2949,7 @@ index 8fcf04b..63eea08 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2260,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2287,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2941,7 +2967,7 @@ index 8fcf04b..63eea08 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2281,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2308,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2961,7 +2987,7 @@ index 8fcf04b..63eea08 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2299,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2326,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2985,7 +3011,7 @@ index 8fcf04b..63eea08 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2332,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2359,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -3009,7 +3035,7 @@ index 8fcf04b..63eea08 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2405,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2432,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -3030,7 +3056,7 @@ index 8fcf04b..63eea08 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2429,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2456,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3055,7 +3081,7 @@ index 8fcf04b..63eea08 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2462,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2489,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3076,7 +3102,7 @@ index 8fcf04b..63eea08 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2532,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2559,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3263,7 +3289,7 @@ index 8fcf04b..63eea08 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2702,274 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2729,278 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3464,14 +3490,18 @@ index 8fcf04b..63eea08 100644 + } catch (e) { + // The reader's own plumbing (a temp folder, a file it cannot read) stops + // the run like a podspec Ruby cannot read: the autolinking callers -+ // rethrow only a PodspecReadError. -+ const error = isPodspecReadError(e) -+ ? e -+ : new PodspecReadError( -+ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + -+ `reader: ${e instanceof Error ? e.message : String(e)}`, -+ 'exit', -+ ); ++ // rethrow only a PodspecReadError. The escape is offered when it changes ++ // the reader. ++ let error = e; ++ if (!isPodspecReadError(e)) { ++ const message = ++ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + ++ `reader: ${e instanceof Error ? e.message : String(e)}`; ++ error = new PodspecReadError( ++ choice.reader === 'ruby' ? withRemedy(message) : message, ++ 'exit', ++ ); ++ } + recordPodspecRead(podspecPath, choice, used, error); + throw error; + } @@ -3567,7 +3597,7 @@ index 8fcf04b..63eea08 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2997,13 @@ function readPodspecNames( +@@ -794,12 +3028,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3582,7 +3612,7 @@ index 8fcf04b..63eea08 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3021,9 @@ function readPodspecNames( +@@ -817,8 +3052,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3594,7 +3624,7 @@ index 8fcf04b..63eea08 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3039,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3070,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 1f6faba..0962458 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -583,7 +583,7 @@ index 0000000..8fb9e73 +abort 'usage: ruby read-podspec-shim.rb --probe | ' unless ARGV.length == 3 +exit(RnXtoolShim.run(ARGV[0], ARGV[1], ARGV[2]) ? 0 : 1) diff --git a/node_modules/react-native/scripts/spm/read-podspec.js b/node_modules/react-native/scripts/spm/read-podspec.js -index 8fcf04b..63eea08 100644 +index 8fcf04b..e9843f6 100644 --- a/node_modules/react-native/scripts/spm/read-podspec.js +++ b/node_modules/react-native/scripts/spm/read-podspec.js @@ -16,11 +16,12 @@ @@ -612,7 +612,7 @@ index 8fcf04b..63eea08 100644 const path = require('node:path'); /*:: -@@ -36,192 +38,1712 @@ type RawSpec = {[string]: unknown}; +@@ -36,192 +38,1739 @@ type RawSpec = {[string]: unknown}; */ // --------------------------------------------------------------------------- @@ -643,22 +643,6 @@ index 8fcf04b..63eea08 100644 - .replace( - /^(\s*)install_modules_dependencies\(([^)]*)\)/gm, - '$1# install_modules_dependencies($2) # stripped for pod ipc', -- ) -- .replace( -- /^(\s*)use_react_native!\(([^)]*)\)/gm, -- '$1# use_react_native!($2) # stripped for pod ipc', -- ); -- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. -- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or -- // similar, expecting the package.json sibling. Keeping the patched file -- // in the same directory makes those reads continue to work. -- const depDir = path.dirname(podspecPath); -- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. -- // Use a dotfile prefix so the patched copy is invisible to normal listing -- // but the suffix CocoaPods requires is preserved. -- const tmpFile = path.join( -- depDir, -- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, +// The podspec reader runs each podspec with the system Ruby, against a shim of +// CocoaPods' DSL (read-podspec-shim.rb), which writes the spec in CocoaPods' +// JSON form. Without a usable Ruby, or with RN_XTOOL_PODSPEC_READER=reduced, @@ -687,8 +671,10 @@ index 8fcf04b..63eea08 100644 +// (react-native-skia's copies hundreds of MB), and a slow disk needs the +// time. A podspec that hangs costs this once. +const PODSPEC_TIMEOUT_MS = 120000; -+// What a read that stopped on a gap of the shim, or a podspec that did not -+// finish, says to do next. A podspec's own `raise` keeps the shim's message. ++// What a read that stopped on a gap of the shim, a podspec that did not ++// finish, a Ruby that ended without a model (`exit`) or a name `ENV.fetch` ++// did not find says to do next. A podspec's own `raise` keeps the shim's ++// message. +const PODSPEC_READ_REMEDY = + 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + + 'for one run, and report it with rn-xtool doctor --report.'; @@ -720,6 +706,55 @@ index 8fcf04b..63eea08 100644 + return ( + e instanceof PodspecReadError || + (e != null && typeof e === 'object' && e.code === 'RN_SPM_PODSPEC_READ') ++ ); ++} ++ ++// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's ++// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home ++// nor a `0` in the shell changes how a podspec reads. ++function podspecChildEnv( ++ env /*: {+[string]: ?string} */, ++) /*: {[string]: string} */ { ++ const child /*: {[string]: string} */ = {}; ++ for (const name of ['PATH', 'HOME', 'LANG']) { ++ const value = env[name]; ++ if (value != null) child[name] = value; ++ } ++ return {...child, ...RN_POD_ENV}; ++} ++ ++// `message`, then the escape. ++function withRemedy(message /*: string */) /*: string */ { ++ return `${message.replace(/\.$/, '')}. ${PODSPEC_READ_REMEDY}`; ++} ++ ++// Whether the shim's `raised` message for `podspec` is Ruby's KeyError of a ++// name `ENV.fetch` did not find: `: key not found: ""`, where ++// `` is ``, `:` or ` (:)`. ++function isEnvKeyError( ++ podspec /*: string */, ++ message /*: string */, ++) /*: boolean */ { ++ return ( ++ message.startsWith(podspec) && ++ /^(?::\d+| \([^)]*:\d+\))?: key not found: "/.test( ++ message.slice(podspec.length), + ) +- .replace( +- /^(\s*)use_react_native!\(([^)]*)\)/gm, +- '$1# use_react_native!($2) # stripped for pod ipc', +- ); +- // Write the patched copy NEXT TO the original podspec, not in os.tmpdir. +- // Podspecs commonly do `File.read(File.join(__dir__, 'package.json'))` or +- // similar, expecting the package.json sibling. Keeping the patched file +- // in the same directory makes those reads continue to work. +- const depDir = path.dirname(podspecPath); +- // pod ipc only accepts files ending in `.podspec` or `.podspec.json`. +- // Use a dotfile prefix so the patched copy is invisible to normal listing +- // but the suffix CocoaPods requires is preserved. +- const tmpFile = path.join( +- depDir, +- `.spm-scaffold-${process.pid}-${path.basename(podspecPath)}`, ); - fs.writeFileSync(tmpFile, patched, 'utf8'); - return tmpFile; @@ -735,20 +770,6 @@ index 8fcf04b..63eea08 100644 - patchedPath = patchPodspecForPodIpc(podspecPath); - } catch { - return null; -+// The child's whole environment: `PATH`, `HOME`, `LANG` and React Native's -+// two pod variables (`RN_POD_ENV`), so neither RUBYOPT, Bundler, a gem home -+// nor a `0` in the shell changes how a podspec reads. -+function podspecChildEnv( -+ env /*: {+[string]: ?string} */, -+) /*: {[string]: string} */ { -+ const child /*: {[string]: string} */ = {}; -+ for (const name of ['PATH', 'HOME', 'LANG']) { -+ const value = env[name]; -+ if (value != null) child[name] = value; -+ } -+ return {...child, ...RN_POD_ENV}; -+} -+ +function nonEmptyLines(text /*: ?string */) /*: Array */ { + return String(text ?? '') + .split('\n') @@ -795,7 +816,7 @@ index 8fcf04b..63eea08 100644 + if (answer?.usable === false && typeof answer.why === 'string') { + return {usable: false, why: answer.why}; + } - } ++ } + const stderr = nonEmptyLines(result.stderr); + if (stderr.some(line => /cannot load such file -- json\b/.test(line))) { + return {usable: false, why: 'ruby cannot load json'}; @@ -853,7 +874,7 @@ index 8fcf04b..63eea08 100644 + if (probe == null) { + probe = probeRuby(shim, env); + rubyProbes.set(key, probe); -+ } + } + if (!probe.usable) { + return {reader: 'reduced', why: probe.why, forced: false, warning}; + } @@ -968,12 +989,14 @@ index 8fcf04b..63eea08 100644 + const error = result.error; + if (error != null && result.status == null && result.signal == null) { + throw new PodspecReadError( -+ `${podspec}: ruby could not run (${error.message})`, ++ withRemedy(`${podspec}: ruby could not run (${error.message})`), + 'exit', + ); + } + throw new PodspecReadError( -+ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ withRemedy( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ ), + 'exit', ); - return null; @@ -987,25 +1010,28 @@ index 8fcf04b..63eea08 100644 - `[read-podspec] pod ipc spec JSON parse failed (${e.message}); ` + - 'falling back to the regex parser (subspecs/helpers may be missed).', + throw new PodspecReadError( -+ `${podspec}: the podspec reader wrote no JSON (${e.message})`, ++ withRemedy(`${podspec}: the podspec reader wrote no JSON (${e.message})`), + 'exit', - ); ++ ); + } + if (model != null && typeof model.error === 'object' && model.error != null) { + const kind = String(model.error.kind); + const message = String(model.error.message); + throw new PodspecReadError( -+ SHIM_GAP_KINDS.includes(kind) -+ ? `${message}. ${PODSPEC_READ_REMEDY}` ++ SHIM_GAP_KINDS.includes(kind) || ++ (kind === 'raised' && isEnvKeyError(podspec, message)) ++ ? withRemedy(message) + : message, + kind, + ); + } + if (result.status !== 0) { + throw new PodspecReadError( -+ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ withRemedy( ++ `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, ++ ), + 'exit', -+ ); + ); + } + return {raw: model, output: result.stdout}; +} @@ -2459,7 +2485,7 @@ index 8fcf04b..63eea08 100644 } // The fields that identify the spec, and only when the receiver spelling -@@ -235,9 +1757,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -235,9 +1784,27 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: // s. = ["a", "b"] (array) // s. = "single" (single value treated as 1-element array) @@ -2490,7 +2516,7 @@ index 8fcf04b..63eea08 100644 if (mArr != null) { const inner = mArr[1]; const out /*: Array */ = []; -@@ -249,16 +1789,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -249,16 +1816,37 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { } return out; } @@ -2533,7 +2559,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; out.push(m[1]); } -@@ -269,21 +1830,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -269,21 +1857,25 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // s.framework "X" → ["X"] // s.framework = "X" → ["X"] // s.frameworks = ["X","Y"] → ["X","Y"] @@ -2564,7 +2590,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; const itemRe = /["']([^"']+)["']/g; while (true) { -@@ -298,12 +1863,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -298,12 +1890,14 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { // Matches: 'HEADER_SEARCH_PATHS' => '...' or => ["...","..."] // Returns the raw token strings (still containing $(PODS_TARGET_SRCROOT) // etc.); substitution happens at translation time. @@ -2581,7 +2607,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; const itemRe = /["']((?:[^"'\\]|\\.)+)["']/g; while (true) { -@@ -321,7 +1888,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -321,7 +1915,7 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { const strRe = /["']HEADER_SEARCH_PATHS["']\s*=>\s*["']((?:[^"'\\]|\\.)+)["']/g; while (true) { @@ -2590,7 +2616,7 @@ index 8fcf04b..63eea08 100644 if (m == null) break; for (const token of m[1].split(/\s+/)) { if (token.length > 0) { -@@ -332,48 +1899,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { +@@ -332,48 +1926,163 @@ function regexPodspec(podspecPath /*: string */) /*: RawSpec */ { return Array.from(new Set(out)); } @@ -2772,7 +2798,7 @@ index 8fcf04b..63eea08 100644 }; } -@@ -423,10 +2105,150 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -423,10 +2132,150 @@ function shellTokenize(value /*: string */) /*: Array */ { return tokens; } @@ -2923,7 +2949,7 @@ index 8fcf04b..63eea08 100644 /** * Merges a podspec's default subspecs (or all subspecs when no defaults are * declared) into a single logical view. RN libraries use subspecs for -@@ -438,8 +2260,16 @@ function shellTokenize(value /*: string */) /*: Array */ { +@@ -438,8 +2287,16 @@ function shellTokenize(value /*: string */) /*: Array */ { * - String fields → top-level wins; if absent, take the first subspec's value * - pod_target_xcconfig HEADER_SEARCH_PATHS → array-union across all selected subspecs * - dependencies → array-union of name strings (version constraints dropped) @@ -2941,7 +2967,7 @@ index 8fcf04b..63eea08 100644 const warnings /*: Array */ = []; // $FlowFixMe[prop-missing] dynamic shape const partial /*: boolean */ = rawSpec.__regex_partial__ === true; -@@ -451,12 +2281,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -451,12 +2308,17 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { } } @@ -2961,7 +2987,7 @@ index 8fcf04b..63eea08 100644 const wanted = new Set(rawSpec.default_subspecs); selected = subspecs.filter(s => { // $FlowFixMe[prop-missing] dynamic shape -@@ -464,7 +2299,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -464,7 +2326,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return name != null && wanted.has(name); }); } @@ -2985,7 +3011,7 @@ index 8fcf04b..63eea08 100644 function mergeArrayField(key /*: string */) /*: Array */ { const out /*: Array */ = []; -@@ -482,11 +2332,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -482,11 +2359,22 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return Array.from(new Set(out)); } @@ -3009,7 +3035,7 @@ index 8fcf04b..63eea08 100644 return typeof value === 'string' && value.length > 0 ? value : null; } -@@ -544,6 +2405,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -544,6 +2432,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // `-D`s are safe to forward; arbitrary flags may be machine- or // example-app-specific. $(inherited), unresolved $(...) tokens, and invalid // C identifiers are skipped. @@ -3030,7 +3056,7 @@ index 8fcf04b..63eea08 100644 function mergePreprocessorDefines() /*: Array */ { const out /*: Array */ = []; const seen /*: Set */ = new Set(); -@@ -554,7 +2429,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -554,7 +2456,23 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { config /*: ?('debug' | 'release') */, ) => { if (!validName.test(name)) return; @@ -3055,7 +3081,7 @@ index 8fcf04b..63eea08 100644 return; // unresolved Xcode/Ruby token — don't emit a broken define } const key = `${name}|${config ?? ''}`; -@@ -571,6 +2462,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -571,6 +2489,20 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { 'xcconfig', 'user_target_xcconfig', ]; @@ -3076,7 +3102,7 @@ index 8fcf04b..63eea08 100644 for (const layer of layers) { if (layer == null || typeof layer !== 'object') continue; for (const xcKey of XCCONFIG_KEYS) { -@@ -627,56 +2532,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -627,56 +2559,160 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { return out; } @@ -3263,7 +3289,7 @@ index 8fcf04b..63eea08 100644 return { name: specStringField('name') ?? '', version: specStringField('version') ?? '', -@@ -693,80 +2702,274 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { +@@ -693,80 +2729,278 @@ function flattenSubspecs(rawSpec /*: RawSpec */) /*: PodspecModel */ { // header_mappings_dir copy step, which SPM has no equivalent for. headerMappingsDirs: mergeArrayField('header_mappings_dir'), headerDir: specStringField('header_dir'), @@ -3464,14 +3490,18 @@ index 8fcf04b..63eea08 100644 + } catch (e) { + // The reader's own plumbing (a temp folder, a file it cannot read) stops + // the run like a podspec Ruby cannot read: the autolinking callers -+ // rethrow only a PodspecReadError. -+ const error = isPodspecReadError(e) -+ ? e -+ : new PodspecReadError( -+ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + -+ `reader: ${e instanceof Error ? e.message : String(e)}`, -+ 'exit', -+ ); ++ // rethrow only a PodspecReadError. The escape is offered when it changes ++ // the reader. ++ let error = e; ++ if (!isPodspecReadError(e)) { ++ const message = ++ `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + ++ `reader: ${e instanceof Error ? e.message : String(e)}`; ++ error = new PodspecReadError( ++ choice.reader === 'ruby' ? withRemedy(message) : message, ++ 'exit', ++ ); ++ } + recordPodspecRead(podspecPath, choice, used, error); + throw error; + } @@ -3567,7 +3597,7 @@ index 8fcf04b..63eea08 100644 * spawn — name resolution runs for every dep, including self-managed ones that * need nothing else from the podspec. * -@@ -794,12 +2997,13 @@ function readPodspecNames( +@@ -794,12 +3028,13 @@ function readPodspecNames( if (hasShadowingSubspec(source)) { return null; } @@ -3582,7 +3612,7 @@ index 8fcf04b..63eea08 100644 const name = field('name'); const moduleName = field('module_name'); -@@ -817,8 +3021,9 @@ function readPodspecNames( +@@ -817,8 +3052,9 @@ function readPodspecNames( /** * Every podspec in `dir`, sorted so two of them name a target the same way on @@ -3594,7 +3624,7 @@ index 8fcf04b..63eea08 100644 */ function findPodspecs(dir /*: string */) /*: Array */ { try { -@@ -834,10 +3039,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { +@@ -834,10 +3070,17 @@ function findPodspecs(dir /*: string */) /*: Array */ { module.exports = { findPodspecs, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 515e98c..3a94408 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -191,11 +191,26 @@ describe("the reader's own failures", () => { expect(e.kind).toBe("exit"); expect(e.message.startsWith(`${podspec}: rn-xtool could not run the podspec reader: ENOENT`)).toBe(true); expect(e.message).toContain(gone); + expect(e.message.endsWith(`. ${REMEDY}`)).toBe(true); const line = JSON.parse(readFileSync(reads, "utf8").trim().split("\n").pop()!); expect(line).toMatchObject({ podspec, reader: "ruby", ok: false, error: e.message }); }); }); +describe("the reduced reader's own failures", () => { + it("stop the read without the escape's advice", () => { + vi.stubEnv("RN_XTOOL_PODSPEC_READER", "reduced"); + vi.stubEnv("RN_SPM_PODSPEC_READS", undefined); + const podspec = library(spec()); + chmodSync(podspec, 0o000); + const e = thrown(() => readPodspec(podspec)); + chmodSync(podspec, 0o644); + expect(isPodspecReadError(e)).toBe(true); + expect(e.kind).toBe("exit"); + expect(e.message).toBe(`${podspec}: rn-xtool could not run the podspec reader: EACCES: permission denied, open '${podspec}'`); + }); +}); + describe("the podspec's installation root", () => { it("finds the installation root", () => { vi.stubEnv("RN_SPM_APP_IOS_DIR", "/a/ios"); @@ -216,7 +231,7 @@ describe("running the podspec shim without Ruby", () => { const e = thrown(() => runPodspecShim(podspec)); expect(isPodspecReadError(e)).toBe(true); expect(e.kind).toBe("exit"); - expect(e.message).toBe(`${podspec}: ruby could not run (spawnSync ruby ENOENT)`); + expect(e.message).toBe(`${podspec}: ruby could not run (spawnSync ruby ENOENT). ${REMEDY}`); }); }); @@ -275,11 +290,22 @@ describe.skipIf(needsRuby !== "")(`running the podspec shim${needsRuby}`, () => expect(r.message).toBe(shimMessage(raised)); }); + it("ends a missing ENV.fetch name with how to go on", () => { + const fetch = library(spec(' s.summary = ENV.fetch("RN_XTOOL_TEST_UNSET")')); + const e = thrown(() => runPodspecShim(fetch)); + expect(e.kind).toBe("raised"); + expect(shimMessage(fetch)).toBe(`${fetch}:3: key not found: "RN_XTOOL_TEST_UNSET"`); + expect(e.message).toBe(`${shimMessage(fetch)}. ${REMEDY}`); + // The podspec's own message that merely mentions it keeps Ruby's message. + const own = library(spec(' raise "the build says key not found: \\"X\\""')); + expect(thrown(() => runPodspecShim(own)).message).toBe(shimMessage(own)); + }); + it("says how ruby ended when the shim wrote nothing", () => { const podspec = library(spec(" exit! 3")); const e = thrown(() => runPodspecShim(podspec)); expect(isPodspecReadError(e)).toBe(true); - expect(e.message).toBe(`${podspec}: ruby exited with 3`); + expect(e.message).toBe(`${podspec}: ruby exited with 3. ${REMEDY}`); }); it("removes its temp out folder", () => { diff --git a/vendor/rn-spm/rn-xtool-edits.patch b/vendor/rn-spm/rn-xtool-edits.patch index 13b730f..e9012f3 100644 --- a/vendor/rn-spm/rn-xtool-edits.patch +++ b/vendor/rn-spm/rn-xtool-edits.patch @@ -190,7 +190,7 @@ --- a/spm/read-podspec.js +++ b/spm/read-podspec.js -@@ -2925,9 +2925,15 @@ +@@ -2956,9 +2956,15 @@ // The installed React Native's version as the macros libraries derive from it. function readRnVersionMacros() /*: {[string]: number} */ { diff --git a/vendor/rn-spm/spm/read-podspec.js b/vendor/rn-spm/spm/read-podspec.js index 2d18f08..44b2612 100644 --- a/vendor/rn-spm/spm/read-podspec.js +++ b/vendor/rn-spm/spm/read-podspec.js @@ -69,8 +69,10 @@ const RUBY_PROBE_TIMEOUT_MS = 10000; // (react-native-skia's copies hundreds of MB), and a slow disk needs the // time. A podspec that hangs costs this once. const PODSPEC_TIMEOUT_MS = 120000; -// What a read that stopped on a gap of the shim, or a podspec that did not -// finish, says to do next. A podspec's own `raise` keeps the shim's message. +// What a read that stopped on a gap of the shim, a podspec that did not +// finish, a Ruby that ended without a model (`exit`) or a name `ENV.fetch` +// did not find says to do next. A podspec's own `raise` keeps the shim's +// message. const PODSPEC_READ_REMEDY = 'Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader ' + 'for one run, and report it with rn-xtool doctor --report.'; @@ -119,6 +121,26 @@ function podspecChildEnv( return {...child, ...RN_POD_ENV}; } +// `message`, then the escape. +function withRemedy(message /*: string */) /*: string */ { + return `${message.replace(/\.$/, '')}. ${PODSPEC_READ_REMEDY}`; +} + +// Whether the shim's `raised` message for `podspec` is Ruby's KeyError of a +// name `ENV.fetch` did not find: `: key not found: ""`, where +// `` is ``, `:` or ` (:)`. +function isEnvKeyError( + podspec /*: string */, + message /*: string */, +) /*: boolean */ { + return ( + message.startsWith(podspec) && + /^(?::\d+| \([^)]*:\d+\))?: key not found: "/.test( + message.slice(podspec.length), + ) + ); +} + function nonEmptyLines(text /*: ?string */) /*: Array */ { return String(text ?? '') .split('\n') @@ -297,12 +319,14 @@ function runPodspecShim( const error = result.error; if (error != null && result.status == null && result.signal == null) { throw new PodspecReadError( - `${podspec}: ruby could not run (${error.message})`, + withRemedy(`${podspec}: ruby could not run (${error.message})`), 'exit', ); } throw new PodspecReadError( - `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + withRemedy( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + ), 'exit', ); } @@ -311,7 +335,7 @@ function runPodspecShim( model = JSON.parse(written); } catch (e) { throw new PodspecReadError( - `${podspec}: the podspec reader wrote no JSON (${e.message})`, + withRemedy(`${podspec}: the podspec reader wrote no JSON (${e.message})`), 'exit', ); } @@ -319,15 +343,18 @@ function runPodspecShim( const kind = String(model.error.kind); const message = String(model.error.message); throw new PodspecReadError( - SHIM_GAP_KINDS.includes(kind) - ? `${message}. ${PODSPEC_READ_REMEDY}` + SHIM_GAP_KINDS.includes(kind) || + (kind === 'raised' && isEnvKeyError(podspec, message)) + ? withRemedy(message) : message, kind, ); } if (result.status !== 0) { throw new PodspecReadError( - `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + withRemedy( + `${podspec}: ruby exited with ${howRubyEnded(result)}${lastStderr}`, + ), 'exit', ); } @@ -2878,14 +2905,18 @@ function readPodspecWith( } catch (e) { // The reader's own plumbing (a temp folder, a file it cannot read) stops // the run like a podspec Ruby cannot read: the autolinking callers - // rethrow only a PodspecReadError. - const error = isPodspecReadError(e) - ? e - : new PodspecReadError( - `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + - `reader: ${e instanceof Error ? e.message : String(e)}`, - 'exit', - ); + // rethrow only a PodspecReadError. The escape is offered when it changes + // the reader. + let error = e; + if (!isPodspecReadError(e)) { + const message = + `${path.resolve(podspecPath)}: rn-xtool could not run the podspec ` + + `reader: ${e instanceof Error ? e.message : String(e)}`; + error = new PodspecReadError( + choice.reader === 'ruby' ? withRemedy(message) : message, + 'exit', + ); + } recordPodspecRead(podspecPath, choice, used, error); throw error; } From c6dd8af90f3953099ed75301354860f3145d8d6b Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:31:19 -0600 Subject: [PATCH 43/53] fix: drop stale CocoaPods text in the scaffolder --- patches/react-native+0.88.0.patch | 43 ++++++++++++++++---- patches/react-native+0.88.1.patch | 43 ++++++++++++++++---- tests/podspecReader.test.ts | 17 ++++++++ vendor/rn-spm/setup-apple-spm.js | 5 +-- vendor/rn-spm/spm/expand-spm-dependencies.js | 4 +- vendor/rn-spm/spm/spm-types.js | 4 +- 6 files changed, 90 insertions(+), 26 deletions(-) diff --git a/patches/react-native+0.88.0.patch b/patches/react-native+0.88.0.patch index 0962458..1113113 100644 --- a/patches/react-native+0.88.0.patch +++ b/patches/react-native+0.88.0.patch @@ -1,5 +1,21 @@ +diff --git a/node_modules/react-native/scripts/setup-apple-spm.js b/node_modules/react-native/scripts/setup-apple-spm.js +index 0ace968..35d5749 100644 +--- a/node_modules/react-native/scripts/setup-apple-spm.js ++++ b/node_modules/react-native/scripts/setup-apple-spm.js +@@ -439,9 +439,8 @@ function runCodegenStep( + /** + * Walks autolinking.json and writes a Package.swift into each community RN + * package that ships a podspec but no SPM manifest. Reuses the dep's +- * podspec (via `pod ipc spec` when available) so the scaffolded file +- * captures the dep's actual sources, header search paths, frameworks, and +- * dependencies. Files carrying the scaffolder's own marker are regenerated ++ * podspec so the scaffolded file captures the dep's actual sources, header ++ * search paths, frameworks, and dependencies. Files carrying the scaffolder's own marker are regenerated + * when the cache slot changes (manifest-hash bump); files without the + * marker are left alone (upstream-shipped or user-managed). + * diff --git a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js -index 872450e..79dd476 100644 +index 872450e..d0f302d 100644 --- a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +++ b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js @@ -12,6 +12,7 @@ @@ -10,6 +26,17 @@ index 872450e..79dd476 100644 readPodspecCached, readPodspecNames, } = require('./read-podspec'); +@@ -198,8 +199,8 @@ function resolveSwiftName( + const fromNpm = toSwiftName(npmName); + if (podspec != null) { + warn( +- `'${npmName}' ships a podspec React Native could not read a name from (CocoaPods may not be installed), so it is named '${fromNpm}' after its npm package instead. ` + +- `A machine that can read the podspec may resolve a different name — set 'swiftpmConfig.name' in ${npmName}'s package.json to settle it everywhere.`, ++ `'${npmName}' ships a podspec whose name is computed in Ruby, which rn-xtool does not use for names, so it is named '${fromNpm}' after its npm package instead. ` + ++ `Set 'swiftpmConfig.name' in its package.json to override.`, + ); + } + return {name: fromNpm, source: 'npm'}; @@ -300,7 +301,8 @@ function expandSpmDependencies( byName.set(dep.name, {...dep, spmDependencies: []}); } @@ -5573,7 +5600,7 @@ index cf7e587..75d9715 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..4eb4089 100644 +index a89142f..24a3fa8 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5611,7 +5638,7 @@ index a89142f..4eb4089 100644 // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. preprocessorDefines: Array, // File paths or glob patterns the dep declares as bundled resources. -@@ -460,17 +462,28 @@ export type PodspecModel = { +@@ -460,17 +462,26 @@ export type PodspecModel = { // a user can spot fields that didn't translate cleanly (unknown env vars, // unrecognized $(...) tokens, etc.). Never throws on parse errors. warnings: Array, @@ -5621,9 +5648,7 @@ index a89142f..4eb4089 100644 + // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the + // reduced reader (podspecReader in read-podspec.js says why). + reader: 'ruby' | 'reduced', -+ // True when produced by the reduced reader rather than Ruby. Used to emit a -+ // louder banner in the scaffold summary explaining that dependency wiring -+ // may be incomplete. ++ // True when produced by the reduced reader rather than Ruby. partial: boolean, - // True when the podspec source calls `install_modules_dependencies(s)` — - // RN's Podfile-side helper that injects the React-Core family. We strip that @@ -5649,7 +5674,7 @@ index a89142f..4eb4089 100644 }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -485,7 +498,7 @@ export type SpmScaffoldSpec = { +@@ -485,7 +496,7 @@ export type SpmScaffoldSpec = { // Header search paths resolved to dep-root-relative form. Each entry // becomes `.headerSearchPath("")` in cSettings + cxxSettings. headerSearchPaths: Array, @@ -5658,7 +5683,7 @@ index a89142f..4eb4089 100644 // cSettings + cxxSettings, honoring any per-config scope. preprocessorDefines: Array, // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + -@@ -502,6 +515,9 @@ export type SpmScaffoldSpec = { +@@ -502,6 +513,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5668,7 +5693,7 @@ index a89142f..4eb4089 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +555,11 @@ export type ScaffoldResult = +@@ -539,6 +553,11 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/patches/react-native+0.88.1.patch b/patches/react-native+0.88.1.patch index 0962458..1113113 100644 --- a/patches/react-native+0.88.1.patch +++ b/patches/react-native+0.88.1.patch @@ -1,5 +1,21 @@ +diff --git a/node_modules/react-native/scripts/setup-apple-spm.js b/node_modules/react-native/scripts/setup-apple-spm.js +index 0ace968..35d5749 100644 +--- a/node_modules/react-native/scripts/setup-apple-spm.js ++++ b/node_modules/react-native/scripts/setup-apple-spm.js +@@ -439,9 +439,8 @@ function runCodegenStep( + /** + * Walks autolinking.json and writes a Package.swift into each community RN + * package that ships a podspec but no SPM manifest. Reuses the dep's +- * podspec (via `pod ipc spec` when available) so the scaffolded file +- * captures the dep's actual sources, header search paths, frameworks, and +- * dependencies. Files carrying the scaffolder's own marker are regenerated ++ * podspec so the scaffolded file captures the dep's actual sources, header ++ * search paths, frameworks, and dependencies. Files carrying the scaffolder's own marker are regenerated + * when the cache slot changes (manifest-hash bump); files without the + * marker are left alone (upstream-shipped or user-managed). + * diff --git a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js -index 872450e..79dd476 100644 +index 872450e..d0f302d 100644 --- a/node_modules/react-native/scripts/spm/expand-spm-dependencies.js +++ b/node_modules/react-native/scripts/spm/expand-spm-dependencies.js @@ -12,6 +12,7 @@ @@ -10,6 +26,17 @@ index 872450e..79dd476 100644 readPodspecCached, readPodspecNames, } = require('./read-podspec'); +@@ -198,8 +199,8 @@ function resolveSwiftName( + const fromNpm = toSwiftName(npmName); + if (podspec != null) { + warn( +- `'${npmName}' ships a podspec React Native could not read a name from (CocoaPods may not be installed), so it is named '${fromNpm}' after its npm package instead. ` + +- `A machine that can read the podspec may resolve a different name — set 'swiftpmConfig.name' in ${npmName}'s package.json to settle it everywhere.`, ++ `'${npmName}' ships a podspec whose name is computed in Ruby, which rn-xtool does not use for names, so it is named '${fromNpm}' after its npm package instead. ` + ++ `Set 'swiftpmConfig.name' in its package.json to override.`, + ); + } + return {name: fromNpm, source: 'npm'}; @@ -300,7 +301,8 @@ function expandSpmDependencies( byName.set(dep.name, {...dep, spmDependencies: []}); } @@ -5573,7 +5600,7 @@ index cf7e587..75d9715 100644 scaffoldAll, scaffoldPackageSwiftForDep, diff --git a/node_modules/react-native/scripts/spm/spm-types.js b/node_modules/react-native/scripts/spm/spm-types.js -index a89142f..4eb4089 100644 +index a89142f..24a3fa8 100644 --- a/node_modules/react-native/scripts/spm/spm-types.js +++ b/node_modules/react-native/scripts/spm/spm-types.js @@ -411,8 +411,8 @@ export type PreprocessorDefine = { @@ -5611,7 +5638,7 @@ index a89142f..4eb4089 100644 // `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target. preprocessorDefines: Array, // File paths or glob patterns the dep declares as bundled resources. -@@ -460,17 +462,28 @@ export type PodspecModel = { +@@ -460,17 +462,26 @@ export type PodspecModel = { // a user can spot fields that didn't translate cleanly (unknown env vars, // unrecognized $(...) tokens, etc.). Never throws on parse errors. warnings: Array, @@ -5621,9 +5648,7 @@ index a89142f..4eb4089 100644 + // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the + // reduced reader (podspecReader in read-podspec.js says why). + reader: 'ruby' | 'reduced', -+ // True when produced by the reduced reader rather than Ruby. Used to emit a -+ // louder banner in the scaffold summary explaining that dependency wiring -+ // may be incomplete. ++ // True when produced by the reduced reader rather than Ruby. partial: boolean, - // True when the podspec source calls `install_modules_dependencies(s)` — - // RN's Podfile-side helper that injects the React-Core family. We strip that @@ -5649,7 +5674,7 @@ index a89142f..4eb4089 100644 }; // Intermediate translation result — concrete data the Swift emitter consumes. -@@ -485,7 +498,7 @@ export type SpmScaffoldSpec = { +@@ -485,7 +496,7 @@ export type SpmScaffoldSpec = { // Header search paths resolved to dep-root-relative form. Each entry // becomes `.headerSearchPath("")` in cSettings + cxxSettings. headerSearchPaths: Array, @@ -5658,7 +5683,7 @@ index a89142f..4eb4089 100644 // cSettings + cxxSettings, honoring any per-config scope. preprocessorDefines: Array, // True when the target has ObjC(++) sources (.m/.mm). Drives emitting + -@@ -502,6 +515,9 @@ export type SpmScaffoldSpec = { +@@ -502,6 +513,9 @@ export type SpmScaffoldSpec = { coreReactNative: boolean, siblingNames: Array, siblingSwiftNames?: {[npmName: string]: string}, @@ -5668,7 +5693,7 @@ index a89142f..4eb4089 100644 // Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics // set. Merged with the defaults at emit time. extraFrameworks: Array, -@@ -539,6 +555,11 @@ export type ScaffoldResult = +@@ -539,6 +553,11 @@ export type ScaffoldResult = // What became of `swiftpmConfig.name` in the library's package.json. // Absent when the name was not podspec-derived, so nothing was attempted. swiftpmName?: SwiftpmNameOutcome, diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index 3a94408..ebc4f32 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -731,6 +731,23 @@ describe("reader failures propagate", () => { expect(thrown(() => expand(dep, defaultReadPodspec)).message).toBe(e.message); }); + it("names a library after its npm package when its podspec computes the name", () => { + const warn = vi.spyOn(console, "warn").mockImplementation(() => {}); + try { + const dep = { name: "react-native-foo", root: tempDir(), platforms: { ios: {} } }; + const computed = () => ({ name: "#{package['name']}", moduleName: null, headerDir: null }); + expect(expand(dep, computed)[0]).toMatchObject({ swiftName: "ReactNativeFoo", swiftNameSource: "npm" }); + const said = warn.mock.calls.map((c) => String(c[0]).replace(/\x1b\[[0-9;]*m/g, "")).join("\n"); + expect(said).toContain( + "'react-native-foo' ships a podspec whose name is computed in Ruby, which rn-xtool does not use for names, " + + "so it is named 'ReactNativeFoo' after its npm package instead. Set 'swiftpmConfig.name' in its package.json to override.", + ); + expect(said).not.toMatch(/CocoaPods|different name/); + } finally { + warn.mockRestore(); + } + }); + it("keeps the old answer for an unreadable file", () => { const { root, podspecPath, dep, outputDir } = installedDep(null); expect(defaultReadPodspec(root, podspecPath)).toBeNull(); diff --git a/vendor/rn-spm/setup-apple-spm.js b/vendor/rn-spm/setup-apple-spm.js index 0ace968..35d5749 100644 --- a/vendor/rn-spm/setup-apple-spm.js +++ b/vendor/rn-spm/setup-apple-spm.js @@ -439,9 +439,8 @@ function runCodegenStep( /** * Walks autolinking.json and writes a Package.swift into each community RN * package that ships a podspec but no SPM manifest. Reuses the dep's - * podspec (via `pod ipc spec` when available) so the scaffolded file - * captures the dep's actual sources, header search paths, frameworks, and - * dependencies. Files carrying the scaffolder's own marker are regenerated + * podspec so the scaffolded file captures the dep's actual sources, header + * search paths, frameworks, and dependencies. Files carrying the scaffolder's own marker are regenerated * when the cache slot changes (manifest-hash bump); files without the * marker are left alone (upstream-shipped or user-managed). * diff --git a/vendor/rn-spm/spm/expand-spm-dependencies.js b/vendor/rn-spm/spm/expand-spm-dependencies.js index 79dd476..d0f302d 100644 --- a/vendor/rn-spm/spm/expand-spm-dependencies.js +++ b/vendor/rn-spm/spm/expand-spm-dependencies.js @@ -199,8 +199,8 @@ function resolveSwiftName( const fromNpm = toSwiftName(npmName); if (podspec != null) { warn( - `'${npmName}' ships a podspec React Native could not read a name from (CocoaPods may not be installed), so it is named '${fromNpm}' after its npm package instead. ` + - `A machine that can read the podspec may resolve a different name — set 'swiftpmConfig.name' in ${npmName}'s package.json to settle it everywhere.`, + `'${npmName}' ships a podspec whose name is computed in Ruby, which rn-xtool does not use for names, so it is named '${fromNpm}' after its npm package instead. ` + + `Set 'swiftpmConfig.name' in its package.json to override.`, ); } return {name: fromNpm, source: 'npm'}; diff --git a/vendor/rn-spm/spm/spm-types.js b/vendor/rn-spm/spm/spm-types.js index 4eb4089..24a3fa8 100644 --- a/vendor/rn-spm/spm/spm-types.js +++ b/vendor/rn-spm/spm/spm-types.js @@ -465,9 +465,7 @@ export type PodspecModel = { // Which reader read the podspec: Ruby through read-podspec-shim.rb, or the // reduced reader (podspecReader in read-podspec.js says why). reader: 'ruby' | 'reduced', - // True when produced by the reduced reader rather than Ruby. Used to emit a - // louder banner in the scaffold summary explaining that dependency wiring - // may be incomplete. + // True when produced by the reduced reader rather than Ruby. partial: boolean, // True when the podspec calls `install_modules_dependencies(s)` — RN's // Podfile-side helper that injects the React-Core family. With Ruby, when From 11e66e9068e1fbd48ad181f71f44d5eb9b8568f7 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:32:32 -0600 Subject: [PATCH 44/53] fix: give Ruby install advice only when it helps --- docs/troubleshooting.md | 23 +++++++++++++++++------ src/commands/setup.ts | 10 ++++++++-- src/pipeline/podspecReads.ts | 7 +++++-- src/tools/podspecReader.ts | 13 +++++++++++++ tests/doctor.test.ts | 18 ++++++++++++++++++ tests/podspecReads.test.ts | 17 +++++++++++++++++ tests/setup.test.ts | 22 ++++++++++++++++++++++ 7 files changed, 100 insertions(+), 10 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 0adbffc..8ece402 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -979,15 +979,26 @@ The `rn-spm` step reads each library's podspec with the system `ruby`, through a Native's podspec helpers, so a podspec gives the same fields it gives under CocoaPods. Without a usable Ruby, it reads them with its reduced reader, written in JavaScript, which evaluates the subset of Ruby podspecs use for their fields. `rn-xtool doctor` names the reader this machine uses (`✔ ruby — 3.3.8`, or `⚠ ruby — not found — podspecs are read -with the reduced reader; sudo apt install ruby`). +with the reduced reader; sudo apt install ruby`). The Ruby is the first `ruby` on `PATH`, asked once per run where it +lives; every podspec then runs with that interpreter, so a version manager (rbenv, asdf, mise) cannot switch Ruby +between podspecs. - **"⚠ Ruby was not found, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does.":** `rn-spm` prints this once, after its runs, - when the reduced reader read a podspec. The first words say why: `Ruby was not found`, `ruby 2.6.10 is older than - 2.7.0`, `ruby cannot load json`, `ruby could not run the podspec reader ()`, or `the podspec reader's Ruby - shim is missing from `. The build goes on with the reduced reader. Install Ruby 2.7 or newer (`sudo apt - install ruby`), check it with `rn-xtool doctor`, and build again. When the shim is missing, reinstall the package - whose folder `` names (rn-xtool, or an installed React Native 0.88), then build again. + when the reduced reader read a podspec. The build goes on with the reduced reader. The first words say why, and + `rn-xtool doctor` and `rn-xtool setup` give the same reason: + - `Ruby was not found`, or `ruby is older than 2.7.0`: the line ends with the install advice. Install Ruby + 2.7 or newer (`sudo apt install ruby`), check it with `rn-xtool doctor`, and build again. + - `ruby cannot load json`: the line ends with a link to this section instead. The Ruby on `PATH` is built without + its standard library's `json`; install the distribution's Ruby (`sudo apt install ruby`) or rebuild that Ruby + with its default gems, then check it with `rn-xtool doctor`. + - `ruby could not run the podspec reader ()`: the line ends with a link to this section. The `ruby` on + `PATH` did not answer, often a version manager's shim that failed. Run `ruby --version` in the project folder: + when it fails there, the detail says why, for example a `.ruby-version` (in the project or a folder above it) + that selects a Ruby the version manager has not installed. Install that version, or change the `.ruby-version`, + and run `rn-xtool doctor` in the project folder again. + - `the podspec reader's Ruby shim is missing from `: the line ends with a link to this section. Reinstall the + package whose folder `` names (rn-xtool, or an installed React Native 0.88), then build again. - **"⚠ patches/ was written by the reduced podspec reader; Ruby is available here: delete it so rn-xtool regenerates it (also remove node_modules/ and reinstall: that copy still has the old Package.swift)":** the `patches` step found a scaffold the reduced reader persisted, for example by a teammate without Ruby, on a machine diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 8cf214f..3eb408e 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -3,10 +3,11 @@ import { accessSync, constants, existsSync } from "node:fs"; import { mkdir, readFile, rm, stat, statfs } from "node:fs/promises"; import { homedir } from "node:os"; import path from "node:path"; +import { troubleshootingUrl } from "../docs.js"; import { cacheDir } from "../paths.js"; import { downloadFile } from "../tools/download.js"; import { run, toolEnv } from "../tools/exec.js"; -import { podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; +import { installingRubyHelps, podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; import { authStatus, defaultXtoolPath } from "../tools/xtool.js"; import { SWIFT_VERSION, XTOOL_SHA256, XTOOL_VERSION } from "../versions.js"; @@ -37,7 +38,12 @@ export interface SetupDeps { function rubySetupLines(c: PodspecReaderChoice): string[] { if (c.reader === "ruby") return c.warning ? [`✔ ruby ${c.ruby}`, `⚠ ${c.warning}`] : [`✔ ruby ${c.ruby}`]; const reduced = `⚠ ${c.why}: rn-xtool reads podspecs with its reduced reader`; - return [c.forced ? reduced : `${reduced}; install Ruby with: sudo apt install ruby`]; + if (c.forced) return [reduced]; + return [ + installingRubyHelps(c.why) + ? `${reduced}; install Ruby with: sudo apt install ruby` + : `${reduced}. See ${troubleshootingUrl("podspec-reader")}`, + ]; } export const GB = 1024 ** 3; diff --git a/src/pipeline/podspecReads.ts b/src/pipeline/podspecReads.ts index 8a01ff7..0e4de84 100644 --- a/src/pipeline/podspecReads.ts +++ b/src/pipeline/podspecReads.ts @@ -6,6 +6,7 @@ import { readFileSync } from "node:fs"; import path from "node:path"; import { troubleshootingUrl } from "../docs.js"; +import { installingRubyHelps } from "../tools/podspecReader.js"; export interface PodspecRead { /** The podspec's absolute path. */ @@ -86,11 +87,13 @@ export function readerLines(reads: PodspecRead[]): string[] { const reduced = reads.find((r) => r.reader === "reduced"); if (reduced !== undefined) { const see = `See ${troubleshootingUrl("podspec-reader")}`; + const why = reduced.why ?? "Ruby was not used"; lines.push( reduced.forced ? `⚠ RN_XTOOL_PODSPEC_READER=reduced is set, ${REDUCED}; unset it to read them as CocoaPods does. ${see}` - : `⚠ ${reduced.why ?? "Ruby was not used"}, ${REDUCED}; install Ruby (sudo apt install ruby) to read them as ` + - `CocoaPods does. ${see}`, + : installingRubyHelps(why) + ? `⚠ ${why}, ${REDUCED}; install Ruby (sudo apt install ruby) to read them as CocoaPods does. ${see}` + : `⚠ ${why}, ${REDUCED}. ${see}`, ); } return lines; diff --git a/src/tools/podspecReader.ts b/src/tools/podspecReader.ts index fdc1b72..19d4ec6 100644 --- a/src/tools/podspecReader.ts +++ b/src/tools/podspecReader.ts @@ -1,6 +1,7 @@ import { createRequire } from "node:module"; import path from "node:path"; import type { DoctorCheck } from "../commands/doctor.js"; +import { troubleshootingUrl } from "../docs.js"; import { packageRoot } from "./exec.js"; /** Which reader the vendored scaffolder reads podspecs with (`podspecReader` in vendor/rn-spm/spm/read-podspec.js). */ @@ -18,12 +19,24 @@ export function podspecReaderHere(env: NodeJS.ProcessEnv = process.env): Podspec const REDUCED = "podspecs are read with the reduced reader"; +/** + * Whether installing the distribution's Ruby fixes why the reduced reader reads: no Ruby, or one older than the + * shim's floor. Any other reason (no `json`, a Ruby that cannot run the shim, the shim missing) needs the + * troubleshooting page instead. + */ +export function installingRubyHelps(why: string): boolean { + return why === "Ruby was not found" || /^ruby \S+ is older than \S+$/.test(why); +} + /** doctor's `ruby` check: a reader other than Ruby, or a Ruby with a warning, is a warning, never a failure. */ export function rubyCheck(c: PodspecReaderChoice): Omit { if (c.reader === "ruby") { return c.warning ? { status: "warn", detail: `${c.ruby}; ${c.warning}` } : { status: "ok", detail: c.ruby }; } if (c.forced) return { status: "warn", detail: `${c.why} — ${REDUCED}` }; + if (!installingRubyHelps(c.why)) { + return { status: "warn", detail: `${c.why} — ${REDUCED}; see ${troubleshootingUrl("podspec-reader")}` }; + } const why = c.why === "Ruby was not found" ? "not found" : c.why; return { status: "warn", detail: `${why} — ${REDUCED}; sudo apt install ruby` }; } diff --git a/tests/doctor.test.ts b/tests/doctor.test.ts index be42c49..393aa4d 100644 --- a/tests/doctor.test.ts +++ b/tests/doctor.test.ts @@ -94,6 +94,8 @@ const good: DoctorProbes = { const statusOf = (r: { checks: { name: string; status: string }[] }, name: string) => r.checks.find((c) => c.name === name)?.status; +const PODSPEC_READER_LINK = "https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader"; + describe("renderReport", () => { it("marks ok, fail and warn with distinct symbols", () => { const out = renderReport([ @@ -563,6 +565,22 @@ describe("ruby check", () => { }); }); + it("points to the troubleshooting page when installing Ruby does not help", async () => { + for (const why of [ + "ruby cannot load json", + "ruby could not run the podspec reader (rbenv: version '3.1.2' is not installed)", + "the podspec reader's Ruby shim is missing from /x/read-podspec-shim.rb", + ]) { + const r = await doctorWithProbes({ ...good, podspecReader: () => ({ ...reduced, why }) }); + expect(r.checks[1]).toEqual({ + name: "ruby", + status: "warn", + detail: `${why} — podspecs are read with the reduced reader; see ${PODSPEC_READER_LINK}`, + }); + expect(r.ok).toBe(true); + } + }); + it("names the forced reduced reader", async () => { const r = await doctorWithProbes({ ...good, diff --git a/tests/podspecReads.test.ts b/tests/podspecReads.test.ts index f18ba9a..c732adc 100644 --- a/tests/podspecReads.test.ts +++ b/tests/podspecReads.test.ts @@ -58,6 +58,23 @@ describe("readerLines", () => { expect(lines[0]!.endsWith(`See ${LINK}`)).toBe(true); }); + it("gives the install advice only when installing Ruby helps", () => { + const old = read("/a/A.podspec", { reader: "reduced", ruby: undefined, why: "ruby 2.5.1 is older than 2.7.0" }); + expect(readerLines([old])).toEqual([ + "⚠ ruby 2.5.1 is older than 2.7.0, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset " + + `of Ruby; install Ruby (sudo apt install ruby) to read them as CocoaPods does. See ${LINK}`, + ]); + for (const why of [ + "ruby cannot load json", + "ruby could not run the podspec reader (rbenv: version '3.1.2' is not installed)", + "the podspec reader's Ruby shim is missing from /x/read-podspec-shim.rb", + ]) { + expect(readerLines([read("/a/A.podspec", { reader: "reduced", ruby: undefined, why })])).toEqual([ + `⚠ ${why}, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby. See ${LINK}`, + ]); + } + }); + it("names the forced reader", () => { expect(readerLines([forced("/proj/node_modules/a/A.podspec"), forced("/proj/node_modules/b/B.podspec")])).toEqual([ "⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read the podspecs with its reduced reader, which evaluates " + diff --git a/tests/setup.test.ts b/tests/setup.test.ts index c73ee46..d976efd 100644 --- a/tests/setup.test.ts +++ b/tests/setup.test.ts @@ -134,6 +134,28 @@ describe("setup", () => { ]); }); + it("gives the install advice only when installing Ruby helps", async () => { + const lines = async (why: string): Promise => { + const log = vi.fn(); + const podspecReader = () => ({ reader: "reduced", why, forced: false, warning: null }) as const; + await setup({}, { checkSwiftPackages: noPending, probe: async () => all, podspecReader, log }); + return log.mock.calls.map((c) => c[0] as string); + }; + expect((await lines("ruby 2.5.1 is older than 2.7.0"))[0]).toBe( + "⚠ ruby 2.5.1 is older than 2.7.0: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby", + ); + for (const why of [ + "ruby cannot load json", + "ruby could not run the podspec reader (rbenv: version '3.1.2' is not installed)", + "the podspec reader's Ruby shim is missing from /x/read-podspec-shim.rb", + ]) { + expect((await lines(why))[0]).toBe( + `⚠ ${why}: rn-xtool reads podspecs with its reduced reader. See ` + + "https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader", + ); + } + }); + it("gives no install advice when the reduced reader is forced", async () => { const log = vi.fn(); const forced = () => ({ reader: "reduced", why: "RN_XTOOL_PODSPEC_READER=reduced is set", forced: true, warning: null }) as const; From a7a7411bbe7cdafb3d152a2e059f3762c92241fc Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:36:11 -0600 Subject: [PATCH 45/53] test: give sweep reads and tar more time --- tests/podspecReaderSweep.test.ts | 36 +++++++++++++++++++++--- tests/support/podspecSweep.ts | 47 ++++++++++++++++++++++++++++---- tests/support/tarballs.ts | 4 +-- tests/support/tools.ts | 5 ++++ tests/tools.test.ts | 7 ++++- 5 files changed, 87 insertions(+), 12 deletions(-) diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index 6545e3d..18d8e63 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -1,3 +1,5 @@ +import { mkdirSync, readdirSync, utimesSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; @@ -13,12 +15,17 @@ import { orphanGoldens, podspecsOf, record, + removeStaleSweepDirs, shimGapKinds, sweepSkipReason, + sweepTestTimeout, type SweepEntry, } from "./support/podspecSweep.js"; import { HEAVY_FETCH_HINT, MANIFEST } from "./support/tarballs.js"; import { mkTmp } from "./support/expoSpm.js"; +import { VENDORED_RN_SPM } from "./support/rnScaffold.js"; + +const { PODSPEC_TIMEOUT_MS } = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js"))("./read-podspec.js"); // The podspec reader sweep: every podspec of the libraries in tests/podspec-sweep.json, read with Ruby and with the // reduced reader, against its reviewed golden in tests/fixtures/podspec-sweep (RN_XTOOL_SWEEP_WRITE=1 rewrites them). @@ -27,9 +34,6 @@ import { mkTmp } from "./support/expoSpm.js"; const CI = process.env.CI === "true"; const skipReason = (entry: SweepEntry) => sweepSkipReason(entry, CI); const skip = (entry: SweepEntry) => skipReason(entry) !== ""; -// A heavy library's read can copy hundreds of MB (skia's podspec copies its prebuilt frameworks into the library): -// tens of seconds on a slow or busy disk, past the suite's 20 s. -const timeout = (entry: SweepEntry) => (isHeavyEntry(entry) ? 120_000 : undefined); describe("the podspec reader sweep", () => { for (const entry of SWEEP) @@ -37,7 +41,7 @@ describe("the podspec reader sweep", () => { it.skipIf(skip(entry))( `reads ${entryName(entry)} ${podspec} as its golden${skipReason(entry)}`, () => expect(record(entry, podspec)).toEqual(golden(entry, podspec)), - timeout(entry), + sweepTestTimeout(entry), ); it("keeps every library's names under both readers", () => expect(nameDifferences()).toEqual([])); @@ -84,6 +88,30 @@ describe("the sweep's guards", () => { expect([isHeavyEntry(needsHeavy), isHeavyEntry(unpinned)]).toEqual([true, false]); }); + it("gives a heavy library's reads more time than the reader gives a podspec", () => { + expect([sweepTestTimeout(needsHeavy), sweepTestTimeout(unpinned)]).toEqual([180_000, 60_000]); + expect(sweepTestTimeout(needsHeavy)).toBeGreaterThan(PODSPEC_TIMEOUT_MS); + }); + + it("removes only the sweep's own temp folders older than an hour", () => { + const dir = mkTmp("sweep-stale-"); + const now = Date.now(); + const hoursAgo = (h: number) => new Date(now - h * 3_600_000); + const make = (name: string, age: number, file = false) => { + const p = path.join(dir, name); + if (file) writeFileSync(p, ""); + else mkdirSync(path.join(p, "node_modules"), { recursive: true }); + utimesSync(p, hoursAgo(age), hoursAgo(age)); + }; + make("rn-xtool-sweep-old", 2); + make("rn-xtool-sweep-recent", 0.5); + make("rn-xtool-sweep-file", 2, true); + make("rn-xtool-shim-old", 2); + make("other", 3); + expect(removeStaleSweepDirs(dir, now)).toEqual(["rn-xtool-sweep-old"]); + expect(readdirSync(dir).sort()).toEqual(["other", "rn-xtool-shim-old", "rn-xtool-sweep-file", "rn-xtool-sweep-recent"]); + }); + it("does not report a heavy tarball as missing on CI", () => { const empty = mkTmp("sweep-empty-cache-"); const orphans = orphanGoldens([needsHeavy], true, empty).join("\n"); diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index 20431bf..cb2197e 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -4,19 +4,19 @@ * and what was read against a reviewed golden in `tests/fixtures/podspec-sweep`. `RN_XTOOL_SWEEP_WRITE=1` writes the * goldens instead. The temp root is written as ``, so a golden holds no machine's path. */ -import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs"; +import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import { homedir, tmpdir } from "node:os"; import path from "node:path"; import { isDeepStrictEqual } from "node:util"; -import { afterAll, vi } from "vitest"; +import { afterAll, beforeAll, vi } from "vitest"; import { podspecResources } from "../../src/pipeline/scaffoldResources.js"; import { podDependencies, podspecFiles, podspecLines, unconditionalLineIndexes } from "../../src/project/podspecs.js"; import { packageRoot } from "../../src/tools/exec.js"; import { VENDORED_RN_SPM } from "./rnScaffold.js"; import { needsRuby } from "./ruby.js"; import { isHeavy, needsTarball, tarballPath } from "./tarballs.js"; -import { tool } from "./tools.js"; +import { TAR_TIMEOUT_MS, tool } from "./tools.js"; const ROOT = packageRoot(); export const SWEEP_GOLDENS = path.join(ROOT, "tests", "fixtures", "podspec-sweep"); @@ -56,6 +56,41 @@ afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); }, 120_000); +const SWEEP_PREFIX = "rn-xtool-sweep-"; +const STALE_MS = 3_600_000; +/** + * Removes the sweep projects an interrupted run left in `dir` (`os.tmpdir()`): the folders named `rn-xtool-sweep-*` + * last changed more than an hour before `now`, never a newer one (another run's) and nothing else. Their names. + */ +export function removeStaleSweepDirs(dir: string = tmpdir(), now: number = Date.now()): string[] { + let names: string[]; + try { + names = readdirSync(dir); + } catch { + return []; + } + const removed: string[] = []; + for (const name of names.filter((n) => n.startsWith(SWEEP_PREFIX)).sort()) { + const full = path.join(dir, name); + try { + const st = lstatSync(full); + if (!st.isDirectory() || now - st.mtimeMs <= STALE_MS) continue; + rmSync(full, { recursive: true, force: true }); + removed.push(name); + } catch { + // gone meanwhile, or not ours to remove + } + } + return removed; +} +// A sweep killed before its afterAll leaves its projects (skia's alone is hundreds of MB). +beforeAll(() => { + removeStaleSweepDirs(); +}, 120_000); + +/** The `it` timeout of a sweep read, above the reader's own 120 s for a heavy library so its message wins. */ +export const sweepTestTimeout = (entry: SweepEntry): number => (isHeavyEntry(entry) ? 180_000 : 60_000); + const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); const tarballsOf = (entry: SweepEntry) => [entry.spec, entry.rn, ...(entry.with ?? [])]; @@ -70,7 +105,9 @@ function extract(spec: string, dir: string, members: string[] = []): void { const file = tarballPath(spec); if (file === undefined) throw new Error(`${spec}: not cached or not pinned in tests/tarballs.json${needsTarball(spec)}`); mkdirSync(dir, { recursive: true }); - const r = tool("tar", ["-xzf", file, "-C", dir, "--strip-components=1", ...members.map((m) => `package/${m}`)]); + const r = tool("tar", ["-xzf", file, "-C", dir, "--strip-components=1", ...members.map((m) => `package/${m}`)], { + timeout: TAR_TIMEOUT_MS, + }); if (r.status !== 0) throw new Error(`tar failed for ${spec}: ${r.stderr}`); } @@ -83,7 +120,7 @@ const projects = new Map(); export function sweepProject(entry: SweepEntry): { root: string; podspecs: string[] } { let project = projects.get(entryName(entry)); if (project) return project; - const root = realpathSync(mkdtempSync(path.join(tmpdir(), "rn-xtool-sweep-"))); + const root = realpathSync(mkdtempSync(path.join(tmpdir(), SWEEP_PREFIX))); tmp.push(root); const modules = path.join(root, "node_modules"); for (const spec of [entry.spec, ...(entry.with ?? [])]) extract(spec, path.join(modules, nameOf(spec))); diff --git a/tests/support/tarballs.ts b/tests/support/tarballs.ts index 04c3b2b..831fdc1 100644 --- a/tests/support/tarballs.ts +++ b/tests/support/tarballs.ts @@ -10,7 +10,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { afterAll } from "vitest"; import { packageRoot } from "../../src/tools/exec.js"; -import { hasTool, patchTool, tool } from "./tools.js"; +import { TAR_TIMEOUT_MS, hasTool, patchTool, tool } from "./tools.js"; const ROOT = packageRoot(); const CACHE = path.join(ROOT, "tests", ".cache"); @@ -77,7 +77,7 @@ function extract(spec: string, prefix: string): string { tmp.push(base); const dir = path.join(base, "node_modules", nameOf(spec)); mkdirSync(dir, { recursive: true }); - const r = tool("tar", ["-xzf", tarballPath(spec)!, "-C", dir, "--strip-components=1"]); + const r = tool("tar", ["-xzf", tarballPath(spec)!, "-C", dir, "--strip-components=1"], { timeout: TAR_TIMEOUT_MS }); if (r.status !== 0) throw new Error(`tar failed for ${spec}: ${r.stderr}`); return dir; } diff --git a/tests/support/tools.ts b/tests/support/tools.ts index 38d75bc..208185b 100644 --- a/tests/support/tools.ts +++ b/tests/support/tools.ts @@ -8,6 +8,11 @@ import { spawnSync, type SpawnSyncOptions, type SpawnSyncReturns } from "node:child_process"; export const TOOL_TIMEOUT_MS = 15_000; +/** + * The timeout of a `tar` extraction of a pinned tarball: a heavy one (skia's prebuilt packages, hundreds of MB) takes + * longer than {@link TOOL_TIMEOUT_MS} on a slow disk, and the sweep extracts while it collects its tests. + */ +export const TAR_TIMEOUT_MS = 60_000; /** The timeout of a `swift` call. */ export const SWIFT_TIMEOUT_MS = 60_000; /** The `it` timeout of a test that runs `swift`. */ diff --git a/tests/tools.test.ts b/tests/tools.test.ts index 235f6eb..6cbbafc 100644 --- a/tests/tools.test.ts +++ b/tests/tools.test.ts @@ -3,7 +3,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; import { mkTmp } from "./support/expoSpm.js"; -import { SWIFT_TEST_TIMEOUT_MS, SWIFT_TIMEOUT_MS, TOOL_TIMEOUT_MS, hasTool, patchTool, tool } from "./support/tools.js"; +import { SWIFT_TEST_TIMEOUT_MS, SWIFT_TIMEOUT_MS, TAR_TIMEOUT_MS, TOOL_TIMEOUT_MS, hasTool, patchTool, tool } from "./support/tools.js"; describe("tests/support/tools", () => { it("fails a hung tool at its timeout instead of hanging the worker", () => { @@ -18,6 +18,11 @@ describe("tests/support/tools", () => { expect(TOOL_TIMEOUT_MS).toBe(15_000); }); + it("gives tar a minute to extract a tarball", () => { + // skia's prebuilt packages are hundreds of MB; they are extracted while the sweep collects its tests. + expect(TAR_TIMEOUT_MS).toBe(60_000); + }); + it("gives swift a longer timeout, and the tests that run it a longer test timeout still", () => { // A cold swift (first run, toolchain not in the page cache) is the slowest tool on a hosted runner. expect(SWIFT_TIMEOUT_MS).toBe(60_000); From fcc97b07f60e3e610ad8ab30893aaf557cbd8971 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:39:31 -0600 Subject: [PATCH 46/53] test: sweep gesture-handler with worklets --- .../RNGestureHandler.podspec.json | 85 +++++++++++++++++++ tests/podspec-sweep.json | 1 + tests/podspecReaderSweep.test.ts | 8 ++ tests/support/podspecSweep.ts | 14 ++- 4 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1+with-worklets/RNGestureHandler.podspec.json diff --git a/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1+with-worklets/RNGestureHandler.podspec.json b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1+with-worklets/RNGestureHandler.podspec.json new file mode 100644 index 0000000..6b58267 --- /dev/null +++ b/tests/fixtures/podspec-sweep/react-native-gesture-handler@3.3.0@rn-0.88.1+with-worklets/RNGestureHandler.podspec.json @@ -0,0 +1,85 @@ +{ + "env": [ + "GH_EXAMPLE_APP_NAME", + "USE_FRAMEWORKS" + ], + "helpers": [ + "install_modules_dependencies" + ], + "names": { + "reduced": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + }, + "shim": { + "headerDir": null, + "moduleName": null, + "name": "RNGestureHandler" + } + }, + "reduced": { + "differs": { + "preprocessorDefines": [], + "warnings": [ + "Left out of s.xcconfig OTHER_CFLAGS: `#{worklets_flag}`, which the podspec reader cannot evaluate; CocoaPods passes its value.", + "`install_modules_dependencies(s)` detected — dependency wiring may be incomplete without Ruby.", + "Env-var or Ruby-config interpolation detected — values may not translate cleanly without Ruby." + ] + } + }, + "shim": { + "compilerFlags": [], + "dependencies": [ + "RNWorklets" + ], + "excludeFiles": [], + "frameworks": [], + "headerDir": null, + "headerDirScopes": [], + "headerMappingsDir": null, + "headerMappingsDirs": [], + "headerSearchPaths": [], + "libraries": [], + "moduleName": null, + "name": "RNGestureHandler", + "partial": false, + "preprocessorDefines": [ + { + "config": null, + "name": "RNGH_USE_WORKLETS", + "value": "1" + } + ], + "privateHeaderFiles": [], + "publicHeaderFiles": [], + "reader": "ruby", + "requiresArc": true, + "resources": [], + "sourceFiles": [ + "apple/**/*.{h,m,mm}", + "shared/**/*.{h,cpp}" + ], + "spmDependencies": [], + "subspecDependencies": {}, + "swiftConditions": [], + "swiftVersions": [], + "unresolvedSources": [], + "usesInstallModulesDependencies": true, + "version": "", + "warnings": [], + "weakFrameworks": [] + }, + "tsReaders": { + "dependencies": { + "onlyShim": [ + "RNWorklets" + ], + "onlyTs": [] + }, + "resourceBundles": { + "onlyShim": [], + "onlyTs": [] + } + } +} diff --git a/tests/podspec-sweep.json b/tests/podspec-sweep.json index 624f428..76a515b 100644 --- a/tests/podspec-sweep.json +++ b/tests/podspec-sweep.json @@ -40,6 +40,7 @@ { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.86.3" }, { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.87.1" }, { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.88.1" }, + { "spec": "react-native-gesture-handler@3.3.0", "rn": "react-native@0.88.1", "with": ["react-native-worklets@0.13.1"], "variant": "with-worklets" }, { "spec": "react-native-gesture-handler@3.4.0", "rn": "react-native@0.88.1" }, { "spec": "react-native-gesture-handler@3.5.0", "rn": "react-native@0.88.1" }, { "spec": "react-native-get-random-values@2.1.0", "rn": "react-native@0.88.1" }, diff --git a/tests/podspecReaderSweep.test.ts b/tests/podspecReaderSweep.test.ts index 18d8e63..764a62a 100644 --- a/tests/podspecReaderSweep.test.ts +++ b/tests/podspecReaderSweep.test.ts @@ -71,6 +71,14 @@ describe("the sweep's guards", () => { expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.86.3/ (no goldens)"); }); + it("gives a variant of an entry its own name and golden folder", () => { + const variant: SweepEntry = { ...unpinned, with: ["react-native-worklets@0.13.1"], variant: "with-worklets" }; + expect(entryName(variant)).toBe("react-native-unpinned@0.0.1 on react-native@0.88.1 (with-worklets)"); + const orphans = orphanGoldens([unpinned, variant], false); + expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.88.1/ (no goldens)"); + expect(orphans).toContain("react-native-unpinned@0.0.1@rn-0.88.1+with-worklets/ (no goldens)"); + }); + // A library that needs a heavy tarball, with a cache folder that holds nothing. const heavy = MANIFEST.find((e) => e.heavy)!; const needsHeavy: SweepEntry = { spec: "react-native-unpinned@0.0.1", rn: "react-native@0.88.1", with: [heavy.spec] }; diff --git a/tests/support/podspecSweep.ts b/tests/support/podspecSweep.ts index cb2197e..8c7aa19 100644 --- a/tests/support/podspecSweep.ts +++ b/tests/support/podspecSweep.ts @@ -24,8 +24,10 @@ export const SWEEP_GOLDENS = path.join(ROOT, "tests", "fixtures", "podspec-sweep /** * An entry of `tests/podspec-sweep.json`: a library, the React Native it is read against, and the packages it needs. A * library and a React Native together name the entry: the same library may be read against several React Natives. + * `variant` names an entry that reads the same library against the same React Native with other packages beside it + * (gesture-handler with worklets installed), and is part of its name and golden folder. */ -export type SweepEntry = { spec: string; rn: string; with?: string[] }; +export type SweepEntry = { spec: string; rn: string; with?: string[]; variant?: string }; export const SWEEP = JSON.parse(readFileSync(path.join(ROOT, "tests", "podspec-sweep.json"), "utf8")) as SweepEntry[]; const req = createRequire(path.join(VENDORED_RN_SPM, "read-podspec.js")); @@ -95,7 +97,8 @@ const nameOf = (spec: string) => spec.slice(0, spec.lastIndexOf("@")); const versionOf = (spec: string) => spec.slice(spec.lastIndexOf("@") + 1); const tarballsOf = (entry: SweepEntry) => [entry.spec, entry.rn, ...(entry.with ?? [])]; /** The entry's name in titles and messages: ` on `. */ -export const entryName = (entry: SweepEntry) => `${entry.spec} on ${entry.rn}`; +export const entryName = (entry: SweepEntry) => + `${entry.spec} on ${entry.rn}${entry.variant === undefined ? "" : ` (${entry.variant})`}`; /** Whether the entry needs a heavy tarball (`tests/tarballs.json`): fetched on request, and slow to read. */ export const isHeavyEntry = (entry: SweepEntry): boolean => tarballsOf(entry).some(isHeavy); const message = (e: unknown) => (e instanceof Error ? e.message : String(e)); @@ -136,10 +139,13 @@ export function sweepProject(entry: SweepEntry): { root: string; podspecs: strin /** * The entry's golden folder, `@rn-` with a scoped name's `/` as `+` (the last `@` starts - * React Native's version), and a podspec's golden file in it. + * React Native's version) and `+` for a variant, and a podspec's golden file in it. */ const goldenDir = (entry: SweepEntry) => - path.join(SWEEP_GOLDENS, `${entry.spec.replaceAll("/", "+")}@rn-${versionOf(entry.rn)}`); + path.join( + SWEEP_GOLDENS, + `${entry.spec.replaceAll("/", "+")}@rn-${versionOf(entry.rn)}${entry.variant === undefined ? "" : `+${entry.variant}`}`, + ); const goldenFile = (entry: SweepEntry, podspec: string) => path.join(goldenDir(entry), `${podspec.replaceAll("/", "__")}.json`); /** The podspecs the entry's goldens are for. */ function goldenPodspecs(entry: SweepEntry): string[] { From 409af791f7b3da47e74dc2401137d9b88e415842 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:39:54 -0600 Subject: [PATCH 47/53] test: check mentions in tracked markdown only --- tests/mentions.test.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/mentions.test.ts b/tests/mentions.test.ts index 1c7e754..ac6cc76 100644 --- a/tests/mentions.test.ts +++ b/tests/mentions.test.ts @@ -1,4 +1,4 @@ -import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; +import { readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; @@ -9,16 +9,14 @@ import { tool } from "./support/tools.js"; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const SCRIPT = path.join(ROOT, "scripts", "check-mentions.mjs"); -/** Every tracked Markdown file, and the local PR and notes files under `.superpowers/` when that folder exists. */ +/** + * Every tracked Markdown file. A pull request's description is checked by the Mentions workflow, and a local draft by + * `npm run check:mentions -- ` before it is used (docs/RELEASING.md). + */ function markdownFiles(): string[] { const r = tool("git", ["ls-files", "*.md"], { cwd: ROOT }); expect(r.status, r.stderr).toBe(0); - const tracked = r.stdout.split("\n").filter((f) => f !== ""); - const local = path.join(ROOT, ".superpowers"); - const notes = existsSync(local) - ? readdirSync(local).filter((f) => f.endsWith(".md")).map((f) => path.join(".superpowers", f)) - : []; - return [...tracked, ...notes]; + return r.stdout.split("\n").filter((f) => f !== ""); } describe("mentions", () => { @@ -46,7 +44,7 @@ describe("mentions", () => { expect(mentions("~~~ `x`\n@y\n~~~\n")).toEqual([]); }); - it("finds none in the tracked markdown or the local PR and notes files", () => { + it("finds none in the tracked markdown", () => { const hits = markdownFiles().flatMap((f) => mentions(readFileSync(path.join(ROOT, f), "utf8")).map((m) => `${f}:${m.line}: @${m.word}`), ); From ffdcd128fba6a587f0ccd95ab90a0ea201085302 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:40:56 -0600 Subject: [PATCH 48/53] test: read the scaffold golden from app-golden --- docs/RELEASING.md | 3 ++- docs/upstream/react-native-scaffolder.md | 3 ++- tests/rn-scaffolder.test.ts | 12 +++++++++--- tests/support/rnScaffold.ts | 8 ++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index f802a63..63b20f7 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -101,7 +101,8 @@ and `vendor/rn-spm/rn-xtool-edits.patch` (E1–E6) applied, for 0.85–0.87 and warning for each persisted scaffold patch, so the CHANGELOG's "Upgrading" section says so. A change that alters no scaffold output keeps the revision. 4. Regenerates the goldens in `tests/fixtures/scaffold-golden/` when the reference app's manifests change (the golden - test reads `RN_XTOOL_REF_APP`, else `../app`). + test reads `RN_XTOOL_REF_APP`, else `../app-golden`, a reference app beside the repo that holds exactly the eight + golden libraries at the golden's versions; `RN_XTOOL_WRITE_GOLDEN=1` writes the goldens instead of comparing). The byte tests need the pinned tarballs in `tests/.cache` (`node scripts/fetch-test-tarballs.mjs`); without them they skip, and the vitest summary says so. Before committing a scaffolder change, run `npx vitest run diff --git a/docs/upstream/react-native-scaffolder.md b/docs/upstream/react-native-scaffolder.md index 5d66114..6b9f701 100644 --- a/docs/upstream/react-native-scaffolder.md +++ b/docs/upstream/react-native-scaffolder.md @@ -979,7 +979,8 @@ every generated or scaffolded Swift target that depends on a mixed module the sa ## Tests `tests/rn-scaffolder.test.ts` loads the patched modules from the reference app and checks the fixes against fixtures -(skipped when the reference app is not present; set `RN_XTOOL_REF_APP` to point at it). It also asserts that each hunk +(skipped when the reference app is not present; it reads `../app-golden` beside the repo, or the app +`RN_XTOOL_REF_APP` names). It also asserts that each hunk is present in the installed RN files. Fixes 14 to 29 are tested on the vendored copy (`vendor/rn-spm/spm`), so they run without the reference app, against podspec fixtures from the SDK 57 pins in `tests/fixtures/podspecs/` (worklets 0.10.1, reanimated 4.5.1, screens 4.26.2, gesture-handler 2.32.0), from screens 4.30.1 (the clang-only importer paths diff --git a/tests/rn-scaffolder.test.ts b/tests/rn-scaffolder.test.ts index e3cb329..e530244 100644 --- a/tests/rn-scaffolder.test.ts +++ b/tests/rn-scaffolder.test.ts @@ -8,6 +8,7 @@ import { GOLDEN_LIBS, PODSPEC_FIXTURES, VENDORED_RN_SPM, + goldenApp, podspecCopy, readGolden, scaffoldLibraries, @@ -32,8 +33,8 @@ const realPodspec = (spec: string, file: string) => ({ const RNGH_PODSPEC = realPodspec("react-native-gesture-handler@3.4.0", "RNGestureHandler.podspec"); const SCREENS_PODSPEC = realPodspec("react-native-screens@4.30.0", "RNScreens.podspec"); const SVG_PODSPEC = realPodspec("react-native-svg@15.16.0", "RNSVG.podspec"); -// The golden test scaffolds the reference app's libraries (override with RN_XTOOL_REF_APP). -const APP = process.env["RN_XTOOL_REF_APP"] ?? path.resolve(import.meta.dirname, "../../app"); +// The golden test scaffolds the golden's reference app's libraries (override with RN_XTOOL_REF_APP). +const APP = goldenApp(); const SWIFTLY_PATH = `${process.env["HOME"]}/.local/share/swiftly/bin:${process.env["PATH"]}`; /** `swift package dump-package` reads the 6.4 manifest only with a 6.4 toolchain (6.5 picks Package@swift-6.5.swift). */ const swift64 = /\bSwift version 6\.4(\.\d+)?\b/.test( @@ -1166,8 +1167,13 @@ describe("the scaffold golden (vendor/rn-spm)", () => { beforeEach(() => vi.stubEnv("RN_XTOOL_PODSPEC_READER", undefined)); afterEach(() => vi.unstubAllEnvs()); + it("reads the golden's libraries from ../app-golden unless RN_XTOOL_REF_APP names another app", () => { + expect(goldenApp({})).toBe(path.resolve(import.meta.dirname, "../../app-golden")); + expect(goldenApp({ RN_XTOOL_REF_APP: "/elsewhere/app" })).toBe("/elsewhere/app"); + }); + it.skipIf(needsRuby !== "" || !GOLDEN_LIBS.every((l) => existsSync(path.join(APP, "node_modules", l))))( - `scaffolds the reference app's libraries as the golden (needs RN_XTOOL_REF_APP or ../app with the eight golden libraries)${needsRuby}`, + `scaffolds the reference app's libraries as the golden (needs ../app-golden or RN_XTOOL_REF_APP with the eight golden libraries)${needsRuby}`, () => { const now = scaffoldLibraries( VENDORED_RN_SPM, diff --git a/tests/support/rnScaffold.ts b/tests/support/rnScaffold.ts index dc4aade..e792dd3 100644 --- a/tests/support/rnScaffold.ts +++ b/tests/support/rnScaffold.ts @@ -19,6 +19,14 @@ export const RN_TARBALL = path.join(ROOT, "tests", ".cache", "react-native-0.88. export const RN_INTEGRITY = "sha512-v/wee0nYWcammMYBnSat/e3WY/5iaf9YQOMcBrfKT/wPApPPlHp94hgZovBtwhMuthR01yc/8cGn0FpFTE/C4A=="; +/** + * The app whose installed {@link GOLDEN_LIBS} the scaffold golden reads: `RN_XTOOL_REF_APP` in `env`, else + * `../app-golden` beside the repo, a reference app that holds exactly those libraries at the golden's versions. + */ +export function goldenApp(env: NodeJS.ProcessEnv = process.env): string { + return env["RN_XTOOL_REF_APP"] ?? path.resolve(ROOT, "..", "app-golden"); +} + /** The libraries whose scaffolds the reference app persists in `patches/`. */ export const GOLDEN_LIBS = [ "react-native-screens", From 15f66fe51ba3ce9fa322e44e062fdf816eb3fcc1 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:41:50 -0600 Subject: [PATCH 49/53] test: give the fake Ruby a version no host has --- tests/doctor.test.ts | 8 ++++---- tests/podspecReader.test.ts | 12 ++++++------ tests/report.test.ts | 10 +++++----- tests/setup.test.ts | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/doctor.test.ts b/tests/doctor.test.ts index 393aa4d..a23bee3 100644 --- a/tests/doctor.test.ts +++ b/tests/doctor.test.ts @@ -88,7 +88,7 @@ const good: DoctorProbes = { portFree: async () => true, wifi: async () => ({ usb: { udid: "u1", enabled: true } }), capabilities: async () => expo58Caps, - podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }), + podspecReader: () => ({ reader: "ruby", ruby: "9.9.9", forced: false, warning: null }), }; const statusOf = (r: { checks: { name: string; status: string }[] }, name: string) => @@ -532,16 +532,16 @@ describe("ruby check", () => { const r = await doctorWithProbes(good); expect(r.checks.slice(0, 2)).toEqual([ { name: "node", status: "ok", detail: "24.15.0" }, - { name: "ruby", status: "ok", detail: "3.3.8" }, + { name: "ruby", status: "ok", detail: "9.9.9" }, ]); const warned = await doctorWithProbes({ ...good, - podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby" }), + podspecReader: () => ({ reader: "ruby", ruby: "9.9.9", forced: false, warning: "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby" }), }); expect(warned.checks[1]).toEqual({ name: "ruby", status: "warn", - detail: "3.3.8; RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby", + detail: "9.9.9; RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby", }); expect(warned.ok).toBe(true); }); diff --git a/tests/podspecReader.test.ts b/tests/podspecReader.test.ts index ebc4f32..1f1a191 100644 --- a/tests/podspecReader.test.ts +++ b/tests/podspecReader.test.ts @@ -32,7 +32,7 @@ function fakeRuby(body: string): string { chmodSync(path.join(bin, "ruby"), 0o755); return bin; } -const usableRuby = () => fakeRuby(`echo '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); +const usableRuby = () => fakeRuby(`echo '{"ruby":"9.9.9","floor":"2.7.0","usable":true}'`); /** `files` (paths relative to it) written into a temp library folder, and the path of its `Foo.podspec`. */ function library(podspec: string, files: Record = {}): string { @@ -88,7 +88,7 @@ describe("the podspec reader's choice", () => { }); it("reads with Ruby when the probe says it is usable", () => { - expect(podspecReader({ env: { PATH: usableRuby() } })).toEqual({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }); + expect(podspecReader({ env: { PATH: usableRuby() } })).toEqual({ reader: "ruby", ruby: "9.9.9", forced: false, warning: null }); }); it("is forced to the reduced reader by RN_XTOOL_PODSPEC_READER=reduced", () => { @@ -103,7 +103,7 @@ describe("the podspec reader's choice", () => { it("names an unknown RN_XTOOL_PODSPEC_READER value", () => { expect(podspecReader({ env: { PATH: usableRuby(), RN_XTOOL_PODSPEC_READER: "REDUCED" } })).toEqual({ reader: "ruby", - ruby: "3.3.8", + ruby: "9.9.9", forced: false, warning: "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby", }); @@ -143,10 +143,10 @@ describe("the podspec reader's choice", () => { it("probes Ruby once per PATH", () => { const counter = path.join(tempDir(), "probes"); - const bin = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); + const bin = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"9.9.9","floor":"2.7.0","usable":true}'`); for (let i = 0; i < 3; i++) expect(podspecReader({ env: { PATH: bin } }).reader).toBe("ruby"); expect(readFileSync(counter, "utf8")).toBe("probe\n"); - const other = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"3.3.8","floor":"2.7.0","usable":true}'`); + const other = fakeRuby(`echo probe >> '${counter}'\necho '{"ruby":"9.9.9","floor":"2.7.0","usable":true}'`); podspecReader({ env: { PATH: other } }); expect(readFileSync(counter, "utf8")).toBe("probe\nprobe\n"); }); @@ -766,6 +766,6 @@ describe("the podspec reader rn-xtool reports", () => { expect(podspecReaderHere(forced)).toEqual(podspecReader({ env: forced })); const withFake = { PATH: usableRuby() }; expect(podspecReaderHere(withFake)).toEqual(podspecReader({ env: withFake })); - expect(podspecReaderHere(withFake)).toEqual({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }); + expect(podspecReaderHere(withFake)).toEqual({ reader: "ruby", ruby: "9.9.9", forced: false, warning: null }); }); }); diff --git a/tests/report.test.ts b/tests/report.test.ts index d21c2a4..35094f7 100644 --- a/tests/report.test.ts +++ b/tests/report.test.ts @@ -89,7 +89,7 @@ const probes: DoctorProbes = { portFree: async () => true, wifi: async () => ({ usb: { udid: "00008110-000000000000AAAA", enabled: true } }), capabilities: async () => caps, - podspecReader: () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }), + podspecReader: () => ({ reader: "ruby", ruby: "9.9.9", forced: false, warning: null }), }; const env: ReportEnv = { rnXtoolVersion: "9.9.9", os: "Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic", arch: "x64", home: "/home/me" }; @@ -150,12 +150,12 @@ describe("doctorReport", () => { "node: 24.15.0", "swift: 6.4", `xtool: ${XTOOL_VERSION}`, - "ruby: 3.3.8", + "ruby: 9.9.9", "podspec reader: not recorded", "os: Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic, x64", "project: expo, Expo SDK 58, expo 58.0.21, react-native 0.88.1", "✔ node — 24.15.0", - "✔ ruby — 3.3.8", + "✔ ruby — 9.9.9", "✔ swift — 6.4", "✔ llvm-nm — LLVM 21.0.0", "✔ llvm-ar — LLVM 21.0.0", @@ -261,7 +261,7 @@ describe("doctorReport", () => { expect(lines.slice(4, 10)).toEqual([ "swift: not checked (--project)", "xtool: not checked (--project)", - "ruby: 3.3.8", + "ruby: 9.9.9", "podspec reader: not recorded", "os: Ubuntu 24.04.1 LTS, Linux 6.8.0-45-generic, x64", "project: expo, Expo SDK 58, expo 58.0.21, react-native 0.88.1", @@ -291,7 +291,7 @@ describe("doctorReport", () => { const lines = (await doctorReport(root, { env, probes })).split("\n"); const at = lines.indexOf(`xtool: ${XTOOL_VERSION}`); expect(lines.slice(at + 1, at + 5)).toEqual([ - "ruby: 3.3.8", + "ruby: 9.9.9", "podspec reader: reduced: RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 2 podspecs)", "podspec ENV:", " node_modules/x/X.podspec: RCT_NEW_ARCH_ENABLED, USE_FRAMEWORKS", diff --git a/tests/setup.test.ts b/tests/setup.test.ts index d976efd..2220371 100644 --- a/tests/setup.test.ts +++ b/tests/setup.test.ts @@ -20,8 +20,8 @@ import { } from "../src/commands/setup.js"; const all = { hasSwift: true, hasXtool: true, hasSdk: true, loggedIn: true }; -const withRuby = () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning: null }) as const; -const RUBY_LINE = "✔ ruby 3.3.8"; +const withRuby = () => ({ reader: "ruby", ruby: "9.9.9", forced: false, warning: null }) as const; +const RUBY_LINE = "✔ ruby 9.9.9"; const noPending = async () => undefined; // No test reaches the network: a download that slips through fails here instead. @@ -60,7 +60,7 @@ const noInstaller = (name: string) => async () => { }; /** * Every setup() in this file goes through here: the real installers are replaced by ones that throw (a test's own - * fakes win), the disk is roomy unless the test probes it, Ruby 3.3.8 reads podspecs unless the test says otherwise, + * fakes win), the disk is roomy unless the test probes it, Ruby 9.9.9 reads podspecs unless the test says otherwise, * and HOME is temporary unless the test set one up. */ const setup = (opts: Parameters[0], deps: Partial = {}) => { @@ -126,7 +126,7 @@ describe("setup", () => { "⚠ Ruby was not found: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby", "✔ Nothing to do: toolchain already set up", ]); - expect(await lines({ podspecReader: withRuby })).toEqual(["✔ ruby 3.3.8", "✔ Nothing to do: toolchain already set up"]); + expect(await lines({ podspecReader: withRuby })).toEqual(["✔ ruby 9.9.9", "✔ Nothing to do: toolchain already set up"]); // With an action to run, the line comes before it; the throwing installers prove nothing is installed for Ruby. expect(await lines({ podspecReader: noRuby, probe: async () => ({ ...all, loggedIn: false }) })).toEqual([ "⚠ Ruby was not found: rn-xtool reads podspecs with its reduced reader; install Ruby with: sudo apt install ruby", @@ -169,10 +169,10 @@ describe("setup", () => { it("names an unknown RN_XTOOL_PODSPEC_READER value under the Ruby line", async () => { const log = vi.fn(); const warning = "RN_XTOOL_PODSPEC_READER=REDUCED is not a reader rn-xtool knows (only reduced); reading podspecs with Ruby"; - const warned = () => ({ reader: "ruby", ruby: "3.3.8", forced: false, warning }) as const; + const warned = () => ({ reader: "ruby", ruby: "9.9.9", forced: false, warning }) as const; await setup({}, { checkSwiftPackages: noPending, probe: async () => all, podspecReader: warned, log }); expect(log.mock.calls.map((c) => c[0] as string)).toEqual([ - "✔ ruby 3.3.8", + "✔ ruby 9.9.9", `⚠ ${warning}`, "✔ Nothing to do: toolchain already set up", ]); From 810d3d55ead3453217988ebe69577c71d2473868 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:42:40 -0600 Subject: [PATCH 50/53] docs: rewrite the alpha.8 upgrade notes --- CHANGELOG.md | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dfa0fb..b9146db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,34 +6,42 @@ versions follow [Semantic Versioning](https://semver.org/) with `alpha` prerelea ## [Unreleased] ### Upgrading from 0.1.0-alpha.7 +- Install Ruby 2.7 or newer (`sudo apt install ruby`) before your first build with this release, so rn-xtool reads + podspecs as CocoaPods does; `rn-xtool doctor` shows the reader this machine uses. Without Ruby, `rn-spm` reads them + with the reduced reader and says so in a `⚠` line. +- On React Native 0.88 (bare, and Expo SDK 58), the first build after the upgrade stops at `patches` with "rn-xtool + could not apply its patch to react-native@0.88.1 (patch file: react-native+0.88.1.patch): node_modules/react-native + is the version the patch is for, but its files match neither the original package nor the patched one.": this + release changes the bundled react-native patch (a new file, `scripts/spm/read-podspec-shim.rb`, and a rewritten + `scripts/spm/read-podspec.js`), and `node_modules/react-native` still holds 0.1.0-alpha.7's. Run + `rm -rf node_modules/react-native && npm install`, then build again. - The scaffolder is now revision 8, so every scaffold patch rn-xtool persisted in your `patches/` before this release gets a warning at each `build`: "⚠ patches/ was written by an older rn-xtool scaffolder (revision 7, now 8); delete it so rn-xtool regenerates it (also remove node_modules/ and reinstall: that copy still has the old - Package.swift)". Delete each such patch, remove the library from `node_modules` and reinstall it, then build: - rn-xtool scaffolds it again and persists the new patch. -- Install Ruby 2.7 or newer (`sudo apt install ruby`) before you regenerate those patches, to read podspecs as - CocoaPods does; `rn-xtool doctor` shows the reader this machine uses. Without Ruby, `rn-spm` reads them with the - reduced reader and says so in a `⚠` line. + Package.swift)". With Ruby installed, delete each such patch, remove the library from `node_modules` and reinstall + it, then build: rn-xtool scaffolds it again and persists the new patch. ### Changed - The scaffolder reads every podspec with the system `ruby` (2.7 or later) through a shim of CocoaPods' DSL and React Native's podspec helpers, the way CocoaPods runs it on a Mac: `install_modules_dependencies`, `defined?` and `respond_to?` answer as under React Native's Podfile, and a library's own Ruby and `node` scripts run. So react-native-gesture-handler 3.3.0 gets `RNGH_USE_WORKLETS=1` beside react-native-worklets 0.8 or later, and - react-native-webview 14.0.1 takes its `install_modules_dependencies` branch. Without a usable Ruby, the reduced - reader of earlier releases reads them, and `rn-spm` prints one `⚠` line saying why. See - [how-it-works.md](docs/how-it-works.md#cocoapods-only-libraries). + react-native-webview 14.0.1 takes its `install_modules_dependencies` branch. Every podspec runs with the + interpreter of the first `ruby` on `PATH`, by its absolute path, so a version manager's `ruby` shim cannot pick + another one per folder, for at most 120 s. Without a usable Ruby, the reduced reader of earlier releases reads them, and + `rn-spm` prints one `⚠` line saying why. See [how-it-works.md](docs/how-it-works.md#cocoapods-only-libraries). - `pod ipc spec` is no longer run, so a machine with CocoaPods reads a podspec exactly as any machine with Ruby, instead of with React Native's helpers stripped (react-native-webview, `@react-native-async-storage/async-storage`, react-native-keychain and react-native-video took their old-architecture branch there). - A podspec's `ios` attributes (`s.ios.exclude_files`, `ss.ios.dependency`, …) are merged over the spec and each subspec the scaffold uses, as CocoaPods merges them for an iOS target; `osx`, `tvos`, `visionos` and `watchos` ones are never read. -- A podspec Ruby cannot read stops `rn-spm` with the podspec (and its line, when Ruby keeps one) and the reason, also - when autolinking reads it for header search paths, instead of leaving that library without them; a gap of the - reader ends with "Set RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it - with rn-xtool doctor --report." See [troubleshooting.md](docs/troubleshooting.md#podspec-reader). For React Native - 0.85–0.87 and Expo SDK 57 this is edit E6 of the vendored scripts (`spm/generate-spm-autolinking.js`). +- A podspec Ruby cannot read, or one that does not finish in 120 s, stops `rn-spm` with the podspec (and its line, + when Ruby keeps one) and the reason, also when autolinking reads it for header search paths, on React Native 0.88 + and in the copy used for 0.85–0.87 and Expo SDK 57, instead of leaving that library without them. A gap of the + reader, a timeout, a Ruby that ends without a result and a `key not found` from `ENV.fetch` end with "Set + RN_XTOOL_PODSPEC_READER=reduced to read it with the reduced reader for one run, and report it with rn-xtool doctor + --report." See [troubleshooting.md](docs/troubleshooting.md#podspec-reader). - A podspec that calls React Native's `spm_dependency` is refused by name, ": uses spm_dependency(url: , products: ), which rn-xtool does not map yet", instead of scaffolding a target that would not link. - A podspec that sets `script_phases`, `prepare_command`, `info_plist` or `module_map` gets a line at `rn-spm`, @@ -42,8 +50,9 @@ versions follow [Semantic Versioning](https://semver.org/) with `alpha` prerelea ### Added - `rn-xtool doctor` (also with `--project`) and `rn-xtool setup` report Ruby: `✔ ruby — 3.3.8`, or `⚠ ruby — not - found — podspecs are read with the reduced reader; sudo apt install ruby`. `setup` names the install command when - Ruby is missing and never installs it. + found — podspecs are read with the reduced reader; sudo apt install ruby`. The install command is named when Ruby is + missing or older than 2.7; for another reason (no `json`, a Ruby that cannot run the reader) the line names it and + links the troubleshooting page. `setup` never installs Ruby. - `RN_XTOOL_PODSPEC_READER=reduced` reads every podspec with the reduced reader for one run, the escape when Ruby cannot read one; `rn-spm` says so in a `⚠` line. Another value is named in a warning and ignored. - Each scaffolded `Package.swift` names its podspec reader on its marker (`// rn-xtool-podspec-reader: ruby` or @@ -56,10 +65,6 @@ versions follow [Semantic Versioning](https://semver.org/) with `alpha` prerelea compares them with recorded goldens, the shim's tests on Ruby 2.7, and a check that no Markdown file holds a bare `@` mention, which would notify a GitHub user. -### Fixed -- The recipe in [RELEASING.md](docs/RELEASING.md) that regenerates the 0.88 patches gives a new file's header the `a/` - side patch-package reads, instead of a patch that patch-package refuses whole. - ## [0.1.0-alpha.7] - 2026-11-06 ### Upgrading from 0.1.0-alpha.6 From fb7830cd046e1943448e394ca296f78c89dade56 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:42:59 -0600 Subject: [PATCH 51/53] docs: say when podspec ENV appears in a report --- docs/troubleshooting.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 8ece402..4351650 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1022,7 +1022,8 @@ between podspecs. every other variable a podspec reads (`USE_FRAMEWORKS`, `USE_HERMES`, a library's own) is unset, whatever your shell has. The podspec runs in its own folder, with `ios/` as CocoaPods' installation root and nothing on its standard input. The names each podspec read are in `rn-xtool doctor --report`, under `podspec ENV:`, one `: NAME, - NAME` line per podspec; the build does not print them. + NAME` line per podspec that read any; the build does not print them. Only Ruby records them: after a run of the + reduced reader, the report has no `podspec ENV:` block. - **Podfile globals:** a podspec reads as with a Podfile that sets no globals (`$VCEnableLocation`, `$VCEnableFrameProcessors`, `$RNVideoUseVideoCaching` are undefined), so it takes its default branch: react-native-vision-camera compiles its location APIs in, and its frame processors only when @@ -1067,8 +1068,9 @@ between podspecs. - **To report a podspec the reader cannot read:** run `rn-xtool doctor --report` in the project folder after the failed build and paste its block into a GitHub issue, with the stop's text and the library's name and version. Its `podspec reader:` line names the reader of the last `rn-spm` and how many podspecs it read (`podspec reader: reduced: - RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 12 podspecs)`), and `podspec ENV:` lists the names each podspec - read. + RN_XTOOL_PODSPEC_READER=reduced is set (last rn-spm, 12 podspecs)`). When a podspec read environment variables, + `podspec ENV:` follows with the names each one read; a run of the reduced reader records none, so the block is + not there. ### Scaffolded libraries From 04cfa4c7afcee6e7d3190047a0b0f4752af0e12d Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:43:38 -0600 Subject: [PATCH 52/53] docs: record the plan 1 amendments --- ...026-11-06-alpha-8-plan-1-podspec-reader.md | 6 +++++ .../2026-11-06-alpha-8-fail-early-design.md | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md b/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md index 7defc82..cd617ce 100644 --- a/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md +++ b/docs/design/plans/2026-11-06-alpha-8-plan-1-podspec-reader.md @@ -39,6 +39,12 @@ that `@{u}` is `origin/feature/alpha-8-podspec-reader`. - The podspec's environment: `RCT_NEW_ARCH_ENABLED='1'`, `RCT_HERMES_V1_ENABLED='1'` (`RN_POD_ENV`, `read-podspec.js:230`), every other variable unset; the child gets `PATH`, `HOME`, `LANG` and those two only. - One Ruby process per podspec, working directory the podspec's folder, 30 s timeout. +- Amended 2026-11-09 (the spec's "Amendments (2026-11-09)" rules): the timeout is 120 s, as skia's podspec copies + hundreds of MB while it is read; the probe prints the interpreter's absolute path (`RbConfig.ruby`) and every podspec + runs with it; `min_ios_version_supported` and the folly config are constants in the shim, with a drift test over the + cached React Native lines (`RN_LINES`); the heavy tier (skia's prebuilt packages) is optional and not fetched in CI; + worklets' own stop text appears only with `react-native` installed beside it (otherwise `worklets_utils.rb:2` fails + first). - The escape is exactly `RN_XTOOL_PODSPEC_READER=reduced`; it prints a `⚠` line naming itself and `doctor --report` records it (R2). - `ENV` names a podspec read go to the reads file and `doctor --report`, never to the terminal (R4). diff --git a/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md index b9baf85..04607ae 100644 --- a/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md +++ b/docs/design/specs/2026-11-06-alpha-8-fail-early-design.md @@ -897,3 +897,27 @@ R1–R8 and R10, the sweep's set by R11 (source and date in F1), and log retenti - The Objective-C fixture's contents (written for rn-xtool from React Native's pre-0.77 template, MIT) and how the drift watch overlays it on the CLI's project. - The wording of the stops and lines not quoted above, and of the docs sections. + +## Amendments (2026-11-09) + +Recorded after the final review of plan 1. The sections above keep their text; where they differ, these rule. + +- **A.2, the timeout: 30 s → 120 s.** rn-xtool gives each podspec 120 s. `@shopify/react-native-skia`'s podspec + copies its prebuilt frameworks (hundreds of MB) into the library while it is read: on a slow disk, 30 s can stop a + working app (an anti-goal), while a podspec that hangs costs 120 s once. Row 8's stop reads `did not finish in + 120 s`. +- **A.2, the interpreter.** `ruby --probe` also prints the absolute path of the interpreter that ran it + (`RbConfig.ruby`), and every podspec runs with that path, not with `ruby` from `PATH`: a version manager's `ruby` + shim (rbenv, asdf, mise) cannot pick another Ruby from a `.ruby-version` in a library's folder. +- **A.3, React Native's values.** `min_ios_version_supported` and `get_folly_config` answer constants held in the + shim; the shim does not load the installed React Native's `helpers.rb`. A drift test in `tests/podspecShim.test.ts` + checks the constants against `scripts/cocoapods` of every cached React Native line (`RN_LINES`: 0.85.0, 0.86.3, + 0.87.1, 0.88.0 and 0.88.1). +- **F.1 and R11, the heavy tier.** skia's three prebuilt packages (about 530 MB) are an optional heavy tier of + `tests/tarballs.json`: `node scripts/fetch-test-tarballs.mjs` skips them unless asked (`--heavy` or + `RN_XTOOL_FETCH_HEAVY=1`), and the sweep skips skia with a named reason when they are missing. CI does not fetch + them (the owner's decision), so skia's golden is checked where the tier is fetched. +- **Rows 7 and 9, worklets' stop.** Worklets' own message (`[Worklets] Unable to recognize your react-native + version…`) appears only when a `react-native` package is installed beside it. Without one, its + `scripts/worklets_utils.rb:2` fails first, with Ruby's `no implicit conversion of nil into String`; either way the + read stops as `raised`, with the podspec's path. From e9f337a9ea03cdd534beb60c106e4126126c1a75 Mon Sep 17 00:00:00 2001 From: Willy Antunez Date: Mon, 9 Nov 2026 11:51:07 -0600 Subject: [PATCH 53/53] fix: match the patch warning to the Ruby advice --- docs/troubleshooting.md | 4 +++- src/pipeline/patches.ts | 14 ++++++++++---- tests/patches.test.ts | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 4351650..80bbbf6 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1009,7 +1009,9 @@ between podspecs. (): keep the patch, and install Ruby (sudo apt install ruby) before you regenerate it":** the opposite case. The patch is the better reading, so keep it; a scaffold regenerated here would be the reduced reader's. With `RN_XTOOL_PODSPEC_READER=reduced` set, the line ends `keep the patch, and unset RN_XTOOL_PODSPEC_READER before you - regenerate it`. + regenerate it`. When installing Ruby would not help (`ruby cannot load json`, `ruby could not run the podspec + reader ()`, the shim missing), it ends `keep the patch; see before you regenerate + it`: fix the reason as the first entry of this section says. - **"⚠ RN_XTOOL_PODSPEC_READER=reduced is set, so rn-xtool read the podspecs with its reduced reader, which evaluates a subset of Ruby; unset it to read them as CocoaPods does.":** the variable is set in the environment of the build, so the reduced reader read every podspec, Ruby or not. Unset it (`unset RN_XTOOL_PODSPEC_READER`) once the podspec diff --git a/src/pipeline/patches.ts b/src/pipeline/patches.ts index 503e731..63c062a 100644 --- a/src/pipeline/patches.ts +++ b/src/pipeline/patches.ts @@ -3,6 +3,7 @@ import { copyFile, mkdir, readFile, realpath, rm, symlink } from "node:fs/promis import { createRequire } from "node:module"; import path from "node:path"; import { execa } from "execa"; +import { troubleshootingUrl } from "../docs.js"; import { projectPaths } from "../paths.js"; import { compareVersions, @@ -16,7 +17,7 @@ import { scaffoldedPods } from "../project/earlyChecks.js"; import type { PodSource, PodTable } from "../project/podTable.js"; import type { ProjectKind } from "../project/types.js"; import { packageRoot, toolEnv } from "../tools/exec.js"; -import { podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; +import { installingRubyHelps, podspecReaderHere, type PodspecReaderChoice } from "../tools/podspecReader.js"; import { outside, packagesWithManifest } from "./manifests.js"; /** The patch-package pinned in this CLI's own dependencies, not whatever npx would fetch. */ @@ -504,13 +505,18 @@ function scaffoldPatchFindings( } // Advice to keep the patch, so its pins are still compared below. if (written === "ruby" && reader.reader === "reduced") { - // A forced reader was chosen on purpose, and Ruby may be installed: no apt advice (as rubyCheck). - const before = reader.forced ? "unset RN_XTOOL_PODSPEC_READER" : "install Ruby (sudo apt install ruby)"; + // A forced reader was chosen on purpose, and Ruby may be installed: no apt advice (as rubyCheck). The apt + // advice only when installing Ruby fixes the reason; any other reason points to the troubleshooting page. + const advice = reader.forced + ? "keep the patch, and unset RN_XTOOL_PODSPEC_READER" + : installingRubyHelps(reader.why) + ? "keep the patch, and install Ruby (sudo apt install ruby)" + : `keep the patch; see ${troubleshootingUrl("podspec-reader")}`; findings.push({ kind: "reader", line: `⚠ patches/${name} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + - `(${reader.why}): keep the patch, and ${before} before you regenerate it`, + `(${reader.why}): ${advice} before you regenerate it`, }); } } diff --git a/tests/patches.test.ts b/tests/patches.test.ts index 78a6a70..3c0a5c9 100644 --- a/tests/patches.test.ts +++ b/tests/patches.test.ts @@ -936,6 +936,22 @@ describe("scaffold patches from another React Native version", () => { ]); }); + it("points to the troubleshooting page when installing Ruby does not help", async () => { + const root = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); + const why = "ruby could not run the podspec reader (rbenv: version '3.1.2' is not installed)"; + const broken: PodspecReaderChoice = { reader: "reduced", why, forced: false, warning: null }; + expect(scaffoldPatchWarnings(root, undefined, [], undefined, broken)).toEqual([ + `⚠ patches/${SVG} was written by the Ruby podspec reader, and this machine reads podspecs with the reduced one ` + + `(${why}): keep the patch; see ` + + "https://github.com/WillyAntunez/react-native-xtool/blob/main/docs/troubleshooting.md#podspec-reader before you " + + "regenerate it", + ]); + const old: PodspecReaderChoice = { reader: "reduced", why: "ruby 2.5.1 is older than 2.7.0", forced: false, warning: null }; + expect(scaffoldPatchWarnings(root, undefined, [], undefined, old)[0]).toMatch( + /\(ruby 2\.5\.1 is older than 2\.7\.0\): keep the patch, and install Ruby \(sudo apt install ruby\) before you regenerate it$/, + ); + }); + it("asks to unset the variable when the reduced reader is forced", async () => { const root = await svgApp(scaffoldPatch("0.88.1", SCAFFOLD_REVISION, "ruby")); const forced: PodspecReaderChoice = {