Repository navigation
feat(🍏): download the Apple binaries from GitHub releases (CocoaPods/SPM) - #4498
Conversation
|
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, 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"]
SDK --> DAWN{"WebGPU supplies Dawn?"}
DAWN -->|Yes| MATCH{"WebGPU binaries.json matches<br/>release version and Dawn commit?"}
MATCH -->|No| FAIL
MATCH -->|Yes: skip own Dawn| MODULE
DAWN -->|No: prepare own Dawn| MODULE
%% Skia and Dawn resolve independently.
MODULE["For each owned module<br/>Skia; Dawn unless supplied by WebGPU"]
MODULE --> LOCAL{"Local module directory exists?<br/>libs/apple or libs/dawn/apple"}
LOCAL -->|Yes| OVERRIDE["Use local SDK folder read-only<br/>Never overwrite or download replacements"]
OVERRIDE --> VALID
LOCAL -->|No| ASSET["Locate selected SDK asset in pin<br/>Shared 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/>libraries, 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 containers| 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 archives exist?"}
STAGED -->|Yes: skip copies| NEXT
STAGED -->|No| COPY["Stage selected SDK as librnskia_*.a<br/>APFS clone or ordinary copy"]
COPY --> NEXT
end
NEXT{"More owned modules?"}
NEXT -->|Yes| MODULE
NEXT -->|No| LINK["Compile wrapper using bundled headers<br/>Statically link prepared libraries into app/framework<br/>No Skia/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;
|
|
@theeket I like it (haven’t reviewed it yet), but just a heads-up: when we downloaded from GitHub releases in CocoaPods in the past, we got a lot of pushback from users (slow downloads, hash issues). Let’s revisit it, though. There are two things I like about your approach:
This feels very compelling. CC’ing @chrfalch to show that this would likely incentivizing users toward SPM :) |
|
I'm not sure about the CocoaPods download back then, which approach is it. But currently, it uses direct bash script in Xcode (not at Pods / SPM install time); and only download one required slice. So, it should as fast as Gradle downloads 🚀 Also, it is not SPM binaryTarget, so the #4494 works with this. SPM alone still downloads other unused slices before compilation time. So, this Xcode build phase solved that. Both Pods and SPM! 🚀 |
3282c8a to
a112161
Compare
|
Other minor changes in this PR to be able to test (test passed):
|
6c4c399 to
2160407
Compare
2160407 to
37d8f7c
Compare
wcandillon
left a comment
There was a problem hiding this comment.
This is fantastic stuff. A big Thank You 💚 Here's how I'll do this.
0. There is a TN Skia release I want to do first for safety
- Merge this PR in an integration branch
- Run the 158.1.0 release
- Merge integration branch
- Release and on the RN WebGPU side too
|
Great! Thanks 🚀 |
ℹ️ This PR requires prebuilt binaries from #4494, and its updated binaries.json
Summary
Move Apple binary consumption from large npm dependencies to SDK-specific GitHub release assets from #4494.
react-native-skia.Workflow
pod installorreact-native spm update.iphoneosarchives without fetching simulator, Catalyst, or macOS binaries.$OBJROOT/ReactNativeSkiaBinaries. Append or replace the current SDK slice while retaining other prepared slices for the same manifest.librnskia_*.ain build products. CocoaPods library settings or SwiftPM.linkedLibrarysettings link them statically into the app/framework. No Skia/Dawn framework needs embedding or signing separately.Unchanged inputs reuse existing containers and staged libraries. Release/checksum changes select new cache entries; manifest changes select a new assembly root.
Integration
pod install.binaries.jsonrelease version and Dawn commit, then omit Skia’s own Dawn preparation.Validation
file:///).Voila! You just reduce total download size of > 900MB into 20-40MB a time 🚀
Multiple different projects with the same binaries version ? still download only once.