Skip to content

feat(🍏): download the Apple binaries from GitHub releases (CocoaPods/SPM) - #640

Merged
wcandillon merged 4 commits into
wcandillon:mainfrom
theeket:feat/apple-sdk-binary-preparation
Nov 24, 2026
Merged

wcandillon merged 4 commits into
wcandillon:mainfrom
theeket:feat/apple-sdk-binary-preparation

Conversation

@theeket

@theeket theeket commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ℹ️ This PR requires prebuilt binaries from react-native-skia#4494, and its updated binaries.json

Summary

Android already download the prebuilt binaries from GitHub releases (#628); released in 0.22.0,
This PR uses the same CocoaPods/SwiftPM preparation workflow as react-native-skia#4498. See other changes there.

WebGPU-specific changes:

  • Downloads Dawn from Skia’s shared binaries release.
  • Shares Skia’s cache directory, checksums, and locks. Existing downloads are reused.
  • Always supplies its own Dawn. Compatible Skia integration uses that same copy.
  • Removes react-native-webgpu-dawn; headers ship inside react-native-webgpu.
  • Updates Dawn header preparation, no npm needed.

Other minor changes (in this PR) to be able to test:

  • Update spm-example to support scene lifecycle. Otherwise it will crash in Xcode 27.
  • Temporarily disables Skia examples and interop tests until compatible Skia ships. Otherwise, pod install will fails.

Validation:

  • Eight SDK preparation paths, cache reuse, and failure handling checked.
  • CocoaPods Debug builds passed on iPhone/Simulator and macOS (example app), rendering as expected.
  • SwiftPM example builds passed on iPhone/Simulator, rendering as expected.
  • Tested removing / rebuilding slice and build again / incremental build, the script works as expected.

@theeket
theeket force-pushed the feat/apple-sdk-binary-preparation branch 4 times, most recently from 729c912 to 85ce5b4 Compare November 22, 2026 12:06
@theeket
theeket marked this pull request as ready for review November 22, 2026 14:52
@theeket

theeket commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

What's going on there:

flowchart TD
  %% Installation configures linking; binary downloads wait for Xcode.
  subgraph SETUP["Installation — no binary downloads"]
    NPM["npm / yarn install<br/>JS, Dawn headers, binaries.json"]
    CP["CocoaPods: pod install<br/>Configure library links and pod-target phase"]
    SPM["Optional SwiftPM: spm update<br/>RN 0.87.1+ plugin generates<br/>link-settings package and app-target phase"]

    NPM --> CP
    NPM --> SPM
    PIN["Installed binaries.json<br/>Release tag, asset SHA-256, Dawn commit"]
    NPM -.-> PIN
  end

  CP --> PHASE
  SPM --> PHASE

  %% The same shell implementation handles both integrations.
  PHASE["Every Xcode build<br/>prepare-apple-binaries.sh<br/>Bash and system tools; no Node"]
  PHASE --> SDK["Select SDK and variant from Xcode<br/>Apply ARCHS, EXCLUDED_ARCHS, ONLY_ACTIVE_ARCH<br/>Catalyst selects maccatalyst, not native macOS"]

  %% WebGPU always supplies its own Dawn.
  SDK --> LOCAL{"Local Dawn directory exists?<br/>libs/apple"}

  LOCAL -->|Yes| OVERRIDE["Use local SDK folder read-only<br/>Never overwrite or download replacements"]
  OVERRIDE --> VALID

  LOCAL -->|No| ASSET["Locate selected SDK's Dawn asset in pin<br/>Shared Skia/WebGPU cache keyed by release tag and ZIP SHA-256"]
  PIN -.-> ASSET
  ASSET -->|Asset missing| FAIL
  ASSET --> CACHE{"Cached ZIP exists<br/>and SHA-256 matches?"}

  %% Downloads are bounded, verified, and synchronized across builds.
  CACHE -->|No| DOWNLOAD["Download selected SDK ZIP only<br/>GitHub, mirror, or file:///<br/>Bounded retries; verify SHA-256"]
  DOWNLOAD -->|Download or checksum failure| FAIL
  DOWNLOAD -->|Verified| MARKER
  CACHE -->|Yes: no download| MARKER{"Extraction marker matches SHA-256?"}

  MARKER -->|Yes: reuse extracted files| VALID
  MARKER -->|No| EXTRACT["Check archive paths<br/>Extract temporarily; atomically replace cache"]
  EXTRACT --> VALID

  VALID{"SDK metadata valid?<br/>Platform, variant, required architectures,<br/>library, and deployment minimum"}
  VALID -->|No| FAIL
  VALID -->|Yes| ROOT["Assembly root under OBJROOT<br/>Version + manifest hash<br/>Source signature: ZIP hash or local metadata/file stats"]

  %% A changed pin selects new storage; old binaries cannot silently win.
  PIN -. "Changed tag or SHA selects new cache entry" .-> ASSET
  PIN -. "Changed manifest selects new assembly root" .-> ROOT

  subgraph INCREMENTAL["Incremental preparation — synchronized per build root"]
    ROOT --> SAME{"Source signature unchanged<br/>and SDK slice files exist?"}
    SAME -->|Yes: reuse container| STAGED
    SAME -->|No| COMPOSE["Atomically append or replace current SDK slice<br/>Preserve other SDK slices for this manifest<br/>Update Info.plist from metadata<br/>No compilation or lipo"]
    COMPOSE --> STAGED

    STAGED{"Staged signature matches<br/>and linker archive exists?"}
    STAGED -->|Yes: skip copy| LINK
    STAGED -->|No| COPY["Stage selected SDK as librnwgpu_webgpu_dawn.a<br/>APFS clone or ordinary copy"]
    COPY --> LINK
  end

  LINK["Compile WebGPU wrapper using bundled headers<br/>Statically link prepared Dawn into app/framework<br/>No Dawn XCFramework embedding"]

  FAIL["Stop build with actionable Xcode error<br/>Clean temporary files and release owned locks"]

  %% Highlight SDK selection, downloads, preparation, and final linking.
  classDef selection fill:#dbeafe,stroke:#2563eb,color:#111827,stroke-width:2px;
  classDef download fill:#ffedd5,stroke:#ea580c,color:#111827,stroke-width:2px;
  classDef preparation fill:#ccfbf1,stroke:#0f766e,color:#111827,stroke-width:2px;
  classDef linking fill:#ede9fe,stroke:#7c3aed,color:#111827,stroke-width:2px;
  classDef failure fill:#fee2e2,stroke:#b91c1c,color:#111827;

  class SDK selection;
  class DOWNLOAD download;
  class PHASE,COMPOSE preparation;
  class LINK linking;
  class FAIL failure;
Loading

@theeket
theeket force-pushed the feat/apple-sdk-binary-preparation branch 2 times, most recently from f2f7c80 to 88a36fd Compare November 22, 2026 15:33
@theeket
theeket force-pushed the feat/apple-sdk-binary-preparation branch from 88a36fd to af523f6 Compare November 22, 2026 15:38
Pins the first release with SDK-grouped Apple archives. Same Dawn commit as 158.0.0.
@wcandillon
wcandillon self-requested a review November 24, 2026 14:28
- Ignore the dormant Skia demos in the example's ESLint config, matching
  tsconfig.json (fixes the failing lint step in CI).
- Restore the RNWGPU_USE_SPM stub mode of the podspec so apps that link
  through SwiftPM but still run CocoaPods don't get the module twice.
- Keep Dawn's headers out of the pod's public headers instead of setting
  header_mappings_dir, preserving the flat public header layout.
- Serialize stale lock recovery so a waiter never removes a lock another
  build has just taken over.
- Treat minimumDeploymentTarget as optional in SDK metadata.
@wcandillon
wcandillon merged commit 46bae15 into wcandillon:main Nov 24, 2026
8 of 9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants