You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 46bae15
Browse filesBrowse the repository at this point in the historyBrowse files
feat(🍏): download the Apple binaries from GitHub releases (CocoaPods/SPM) (#640)
* feat(🍏): download the Apple binaries from GitHub releases (CocoaPods/SPM)
* chore(⬆️): use the binaries-158.1.0 release
Pins the first release with SDK-grouped Apple archives. Same Dawn commit as 158.0.0.
* fix(🍏): address review findings on Apple binary preparation
- 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.
---------
Co-authored-by: William Candillon <wcandillon@gmail.com>
Copy file name to clipboardExpand all lines: apps/docs/content/docs/getting-started/installation.mdx
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,17 @@ npm i react-native-webgpu
24
24
25
25
An Android app with a lower `minSdkVersion` fails to build; on Expo, the [config plugin](/docs/getting-started/expo#config-plugin) raises it for you.
26
26
27
+
## Prebuilt binaries
28
+
29
+
Both platforms use the [React Native Skia binaries release](https://github.com/wcandillon/react-native-skia/releases) pinned by this package's `binaries.json`:
30
+
31
+
-**Android:** Gradle downloads only the ABIs being built and caches them as Gradle dependencies.
32
+
-**Apple:**
33
+
-**CocoaPods:**`pod install` registers an Xcode phase; it downloads only the selected SDK's Dawn archive during compilation.
34
+
-**SwiftPM (optional):** The autolinking plugin registers the same phase. Package resolution uses bundled headers and a local link-settings package, without downloading Dawn.
35
+
36
+
Apple archives share Skia's `~/Library/Caches/react-native-skia` cache; set `RNSKIA_CACHE_DIR` to override it.
37
+
27
38
## Setup
28
39
29
40
Once installed, the global `navigator.gpu` API is available, the same entry point as in Chrome or Safari:
@@ -63,16 +74,16 @@ This replaces the package with a JS-only stand-in: `<Canvas>` renders as a plain
63
74
64
75
By default, `react-native-webgpu` links on iOS/macOS through CocoaPods autolinking, with no extra setup. The long-term plan is to move the Apple platforms to Swift Package Manager. It is available today as an alternative: the package also ships a `Package.swift` for React Native's SwiftPM autolinking, which needs no CocoaPods at all:
65
76
66
-
1. Use **React Native 0.87 or newer**. Earlier releases have no SwiftPM autolinking, so keep CocoaPods there.
77
+
1. Use **React Native 0.87.1 or newer**, with the autolinking plugin's `scriptPhases` hook. Keep CocoaPods on earlier releases.
67
78
2. From your app's `ios` directory, run `npx react-native spm add --deintegrate` once. It removes CocoaPods from the project and adds the Swift packages to the `.xcodeproj`. Then build the project (not a workspace) as usual.
68
79
3. Do not run `pod install` in that app: it would re-integrate CocoaPods and break the Swift packages.
69
80
70
-
Dawn comes as a prebuilt binary that Xcode downloads the first time it resolves packages.
81
+
Set **User Script Sandboxing** to **NO** on the app target. The Xcode phase needs access to the shared cache and build products. After upgrading the package, run `npx react-native spm update` again.
71
82
72
-
With React Native Skia v3 installed alongside, package resolution checks that both packages link the same Dawn release, and fails if they are not at [compatible versions](/docs/integrations/react-native-skia#compatibility). After changing either version, reset the package caches in Xcode (File > Packages > Reset Package Caches) if the error persists.
83
+
With a compatible React Native Skia integration installed, WebGPU supplies the single Dawn copy. Both packages must pin the same release version and Dawn commit; mismatches fail before linking. See [compatible versions](/docs/integrations/react-native-skia#compatibility).
73
84
74
85
<Callouttype="warn"title="Platform coverage">
75
-
The Swift package targets iOS only: tvOS, macOS and Android still require the CocoaPods/Gradle autolinked path. See `spm-example` at the root of the [React Native WebGPU repo](https://github.com/wcandillon/react-native-webgpu) for a working reference project, and its README for the gotchas (stale `Package.resolved`, the stub `Podfile`).
86
+
The Swift package targets iOS only: tvOS, macOS and Android still require the CocoaPods/Gradle autolinked path. See `spm-example` at the root of the [React Native WebGPU repo](https://github.com/wcandillon/react-native-webgpu) for a working reference project, and its README for setup notes and the stub `Podfile`.
76
87
</Callout>
77
88
78
89
## Troubleshooting
@@ -101,8 +112,8 @@ The simulator's Metal stack is not identical to real hardware, and validation ca
101
112
Learn more in [Apple's documentation on validating Metal API usage](https://developer.apple.com/documentation/xcode/validating-your-apps-metal-api-usage/).
102
113
</Callout>
103
114
104
-
<Callouttype="info"title="Android builds without network access">
105
-
Gradle downloads the prebuilt Dawn from the [GitHub releases of React Native Skia](https://github.com/wcandillon/react-native-skia/releases), which builds it, the first time it builds, only for the architectures being built, and caches it like any other Gradle dependency. To download it from a mirror or a local directory instead, set the `reactNativeSkiaBinariesUrl` Gradle property (or the `REACT_NATIVE_SKIA_BINARIES_URL`environment variable) to a URL or a `file:///`directory that holds the release assets under `binaries-<version>/`.
115
+
<Callouttype="info"title="Builds without network access">
116
+
To use a mirror or local release directory on either platform, set `REACT_NATIVE_SKIA_BINARIES_URL` to a URL or `file:///`path holding `binaries-<version>/<asset>`. Android also accepts the `reactNativeSkiaBinariesUrl` Gradle property.
Copy file name to clipboardExpand all lines: apps/docs/content/docs/integrations/react-native-skia.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Because the two packages share Dawn, React Native Skia v3 and React Native WebGP
26
26
| 0.12.1 | 3.0.6 to 3.0.8, or 3.1.0 and later |
27
27
| 0.10.0 to 0.11.2 | 3.0.0 to 3.0.5 |
28
28
29
-
If the versions don't match, the native build fails with a `Dawn version mismatch` error rather than misbehaving at runtime. Both packages get Dawn from the `react-native-webgpu-dawn` npm package: make sure a single version of it is installed (`npm ls react-native-webgpu-dawn`, or `yarn why react-native-webgpu-dawn`).
29
+
For SDK-archive integration, both packages must pin the same release version and `dawn.commit` in `binaries.json`. WebGPU supplies Dawn; Skia must use its compatible external-Dawn integration so the app links one copy. A mismatch fails with `Dawn version mismatch`. The older binary-npm integrations follow their release-specific installation instructions.
30
30
31
31
The Graphite previews of v2 (`@shopify/react-native-skia@next`) follow the same rule. Regular v2 releases don't use Dawn, so they work alongside any version of React Native WebGPU.
0 commit comments