Skip to content

Commit 2ed4cc8

Browse files
olilarkinclaude
andcommitted
Fix visionOS build: use target_os=ios with visionOS compiler flags
GN doesn't recognize "xros" as a valid target OS, causing assertion failures in Skia's GN files (e.g., zlib BUILD.gn "Unsupported ARM OS"). Solution: Use target_os="ios" but pass -target arm64-apple-xros1.0 via extra_cflags. This leverages iOS/visionOS similarity while targeting the correct platform. Research from react-native ecosystem: - react-native-skia #2280: visionOS blocked by GN limitations - react-native-webgpu #90: uses CMake instead of GN for visionOS Changes: - Use target_os="ios" in visionOS GN args (GPU and CPU variants) - Remove zlib patch (no longer needed) - Document visionOS approach in CLAUDE.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 682dd2f commit 2ed4cc8

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

CLAUDE.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Overview
66

7-
This repository provides a Python script and GitHub Actions workflow for building Skia static libraries for multiple platforms (macOS, iOS, Windows, Linux, WASM). It automates build environment setup, Skia repository cloning, GN argument configuration, and compilation.
7+
This repository provides a Python script and GitHub Actions workflow for building Skia static libraries for multiple platforms (macOS, iOS, visionOS, Windows, Linux, WASM). It automates build environment setup, Skia repository cloning, GN argument configuration, and compilation.
88

99
## Build Commands
1010

@@ -17,6 +17,7 @@ ulimit -n 2048
1717
# Build libraries directly
1818
python3 build-skia.py mac # macOS universal (arm64 + x86_64)
1919
python3 build-skia.py ios # iOS (arm64 + x86_64 simulator)
20+
python3 build-skia.py visionos # visionOS (arm64)
2021
python3 build-skia.py win # Windows x64
2122
python3 build-skia.py linux # Linux x64
2223
python3 build-skia.py wasm # WebAssembly
@@ -60,6 +61,7 @@ build/
6061
├── include/ # Packaged headers
6162
├── mac/lib/ # macOS libraries
6263
├── ios/lib/ # iOS libraries (per-arch)
64+
├── visionos/lib/ # visionOS libraries (arm64)
6365
├── win/lib/ # Windows libraries
6466
├── linux/lib/ # Linux libraries
6567
├── wasm/lib/ # WASM libraries
@@ -71,11 +73,26 @@ build/
7173
- `MAC_MIN_VERSION` / `IOS_MIN_VERSION` set deployment targets
7274
- `EXCLUDE_DEPS` lists Skia dependencies to skip during sync
7375

76+
## visionOS Support
77+
78+
visionOS builds use a workaround because **GN (Google's build tool) doesn't recognize visionOS/xros as a valid target OS**. This causes assertion failures in Skia's GN files (e.g., `third_party/zlib/BUILD.gn`).
79+
80+
**Our approach:** Use `target_os = "ios"` with visionOS-specific compiler flags:
81+
- `-target arm64-apple-xros1.0` tells clang to use the visionOS target triple
82+
- The visionOS SDK is automatically selected based on the target triple
83+
84+
This approach was informed by research into:
85+
- [react-native-skia #2280](https://github.com/Shopify/react-native-skia/issues/2280) - visionOS support blocked by GN limitations
86+
- [react-native-webgpu #90](https://github.com/wcandillon/react-native-webgpu/pull/90) - successfully supports visionOS using CMake instead of GN
87+
88+
**Alternative approach (not used):** Build with CMake instead of GN, like react-native-webgpu does for Dawn. This would require significant changes to the build script.
89+
7490
## CI
7591

7692
The GitHub Actions workflow (`.github/workflows/build-skia.yml`) builds all platforms in parallel and creates releases tagged with the Skia branch name. Change `SKIA_BRANCH` env var to target different Skia versions.
7793

7894
```bash
79-
gh workflow run build-skia.yml # Trigger a build manually
80-
gh run list # Check CI status
95+
gh workflow run build-skia.yml # Build all platforms
96+
gh workflow run build-skia.yml -f platforms=visionos # Build only visionOS
97+
gh run list # Check CI status
8198
```

build-skia.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ def colored_print(message, color):
208208
extra_cflags_c = ["-Wno-error"]
209209
""",
210210

211+
# visionOS: Use target_os="ios" because GN doesn't recognize "xros".
212+
# The -target flag ensures clang uses the visionOS SDK and target triple.
213+
# See: https://github.com/Shopify/react-native-skia/issues/2280
211214
"visionos": f"""
212215
skia_use_metal = true
213-
target_os = "xros"
216+
target_os = "ios"
214217
skia_ios_use_signing = false
215218
extra_cflags = [
216219
"-target", "arm64-apple-xros{VISIONOS_MIN_VERSION}",
@@ -307,9 +310,10 @@ def colored_print(message, color):
307310
extra_cflags_c = ["-Wno-error"]
308311
""",
309312

313+
# visionOS: Use target_os="ios" because GN doesn't recognize "xros".
310314
"visionos": f"""
311315
skia_use_metal = false
312-
target_os = "xros"
316+
target_os = "ios"
313317
skia_ios_use_signing = false
314318
extra_cflags = [
315319
"-target", "arm64-apple-xros{VISIONOS_MIN_VERSION}",

patches/zlib-visionos-support.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)