@geastack/apple 0.2.34 → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/targets/ios/main/ios_display.mm +10 -0
- package/targets/watchos/Info.plist.in +18 -0
- package/targets/watchos/README.md +116 -0
- package/targets/watchos/build-watchos.sh +255 -0
- package/targets/watchos/generate-xcode-project.mjs +434 -0
- package/targets/watchos/main/watchos_app.swift +140 -0
- package/targets/watchos/main/watchos_bridge.h +48 -0
- package/targets/watchos/main/watchos_host.mm +224 -0
- package/targets/watchos/main/watchos_platform.mm +95 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/apple",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Generated Apple SDK bindings plus the macOS, iOS and
|
|
3
|
+
"version": "0.2.35",
|
|
4
|
+
"description": "Generated Apple SDK bindings plus the macOS, iOS, tvOS and watchOS native build targets for Gea apps.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@geastack/compiler": "^1.0.74",
|
|
119
119
|
"@geastack/core": "^0.1.72",
|
|
120
120
|
"@geastack/elements": "^0.1.7",
|
|
121
|
-
"@geastack/engine": "^0.1.
|
|
121
|
+
"@geastack/engine": "^0.1.39",
|
|
122
122
|
"@geastack/geatsc-plugin-apple-native": "^0.1.4",
|
|
123
123
|
"@geastack/geatsc-plugin-gea": "^0.1.32",
|
|
124
124
|
"@geastack/host": "^0.1.29"
|
|
@@ -30,6 +30,9 @@ int g_flush_depth = 2;
|
|
|
30
30
|
int g_flush_calls = 0;
|
|
31
31
|
int g_flush_rects = 0;
|
|
32
32
|
int g_flush_pixels = 0;
|
|
33
|
+
// Bumped whenever pixels reach the presented buffer, so a shell that snapshots
|
|
34
|
+
// it (the watchOS SwiftUI host) can skip frames where nothing was presented.
|
|
35
|
+
std::uint32_t g_presented_generation = 0;
|
|
33
36
|
|
|
34
37
|
void ensure_canvas()
|
|
35
38
|
{
|
|
@@ -49,6 +52,7 @@ void ensure_canvas()
|
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
54
|
g_canvas.bindPixels(g_framebuffer, g_canvas_width, g_canvas_height);
|
|
55
|
+
g_presented_generation++;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
void count_rect(int x0, int y0, int x1, int y1)
|
|
@@ -76,6 +80,7 @@ void copy_rect_to_presented(int x0, int y0, int x1, int y1)
|
|
|
76
80
|
const std::size_t offset = static_cast<std::size_t>(y) * g_canvas_width + x0;
|
|
77
81
|
std::copy_n(g_framebuffer + offset, width, g_presented_framebuffer + offset);
|
|
78
82
|
}
|
|
83
|
+
g_presented_generation++;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
} // namespace
|
|
@@ -354,6 +359,11 @@ extern "C" const std::uint32_t *gea_ios_display_presented_pixels()
|
|
|
354
359
|
return g_presented_framebuffer ? g_presented_framebuffer : g_framebuffer;
|
|
355
360
|
}
|
|
356
361
|
|
|
362
|
+
extern "C" std::uint32_t gea_ios_display_presented_generation()
|
|
363
|
+
{
|
|
364
|
+
return g_presented_generation;
|
|
365
|
+
}
|
|
366
|
+
|
|
357
367
|
extern "C" void gea_ios_display_set_viewport_size(int width, int height)
|
|
358
368
|
{
|
|
359
369
|
if (width <= 0 || height <= 0) return;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key><string>en</string>
|
|
6
|
+
<key>CFBundleDisplayName</key><string>@APP_DISPLAY_NAME@</string>
|
|
7
|
+
<key>CFBundleExecutable</key><string>@APP_EXEC@</string>
|
|
8
|
+
<key>CFBundleIdentifier</key><string>@BUNDLE_ID@</string>
|
|
9
|
+
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
|
|
10
|
+
<key>CFBundleName</key><string>@APP_NAME@</string>
|
|
11
|
+
<key>CFBundleIconName</key><string>AppIcon</string>
|
|
12
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
13
|
+
<key>CFBundleShortVersionString</key><string>0.1.0</string>
|
|
14
|
+
<key>CFBundleVersion</key><string>1</string>
|
|
15
|
+
<key>WKApplication</key><true/>
|
|
16
|
+
<key>WKWatchOnly</key><true/>
|
|
17
|
+
</dict>
|
|
18
|
+
</plist>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# watchOS target
|
|
2
|
+
|
|
3
|
+
Build a gea-embedded JSX app as a watch-only Apple Watch app.
|
|
4
|
+
|
|
5
|
+
From an app that depends on `@geastack/apple` and declares
|
|
6
|
+
`gea.targets.watchos`, the CLI drives this target:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npx gea build --target watchos # simulator .app, no launch
|
|
10
|
+
npx gea build --target watchos --mode device # watchos .app (unsigned without a team)
|
|
11
|
+
npx gea run --target watchos # build, install and launch on a watch simulator
|
|
12
|
+
npx gea run --target watchos --mode device # build, sign, install and launch on a watch
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The CLI runs `build-watchos.sh <app-id> simulator|device` from the app folder;
|
|
16
|
+
the script can be run directly the same way. Either way it needs a
|
|
17
|
+
`@geastack/cli` with watchOS support, which also builds the app icon
|
|
18
|
+
(`gea apps apple-icons --platform watchos`).
|
|
19
|
+
|
|
20
|
+
`counter-jsx` in the examples repository is the reference app for this target.
|
|
21
|
+
|
|
22
|
+
The script resolves `@geastack/core`, `@geastack/compiler` and `@geastack/cli`
|
|
23
|
+
by walking up `node_modules` from the app folder, as the iOS script does. Output
|
|
24
|
+
goes to `<app>/dist/watchos` (override with `GEA_WATCHOS_OUTPUT_DIR`); the Xcode
|
|
25
|
+
project is generated at `<app>/dist/watchos/<app-id>/GeaWatch.xcodeproj`. Do not
|
|
26
|
+
hand-edit it.
|
|
27
|
+
|
|
28
|
+
## How it renders
|
|
29
|
+
|
|
30
|
+
watchOS gives an app no UIView hierarchy, so there is no native view renderer
|
|
31
|
+
like iOS has. The shell is a SwiftUI app (`main/watchos_app.swift`): gea lays
|
|
32
|
+
out and paints the whole UI into its RGBA8888 framebuffer, and the shell shows
|
|
33
|
+
each presented frame as an image covering the screen. Touches come back through
|
|
34
|
+
a drag gesture as gea touch events. Turning the Digital Crown scrolls the
|
|
35
|
+
first vertical scroll container, as the Up/Down buttons do on touchless boards;
|
|
36
|
+
`GeaWatchHost.crownPointsPerUnit` sets how far it moves. The Crown's range is
|
|
37
|
+
that container's scroll range, so the system Crown indicator shows the scroll
|
|
38
|
+
position, however the list was scrolled. The frame loop runs at 60 Hz while the app
|
|
39
|
+
is active and stops when the watch dims or the app goes to the background.
|
|
40
|
+
|
|
41
|
+
The C++ side (`main/watchos_host.mm`) reuses the iOS host backends for the
|
|
42
|
+
framebuffer, frame clock, allocator, touch state, CoreMotion and AVAudioEngine
|
|
43
|
+
audio, and drives CSS and `data-anim` animations each frame as the embedded
|
|
44
|
+
runtime loop does. `main/watchos_platform.mm` adds what is different on a
|
|
45
|
+
watch: battery level, charging state and haptics come from WatchKit, and the
|
|
46
|
+
camera reports itself unavailable, so camera apps build and a `<camera>`
|
|
47
|
+
renders nothing.
|
|
48
|
+
|
|
49
|
+
## Sizing
|
|
50
|
+
|
|
51
|
+
The canvas is the panel's physical pixels. One CSS `px` is 1.5 physical pixels
|
|
52
|
+
by default, the ratio the ESP32 watch boards with the same panels (368x448,
|
|
53
|
+
410x502) declare, so an app is the same size on either. That makes a 46mm watch
|
|
54
|
+
277x331 CSS px and a 40mm SE 216x263. An app picks its own ratio with
|
|
55
|
+
`gea.targets.watchos.cssDevicePixelRatio` (an object target) or
|
|
56
|
+
`gea.cssDevicePixelRatio`; `GEA_WATCHOS_CSS_DEVICE_PIXEL_RATIO` overrides both
|
|
57
|
+
for one build. Font atlases are baked at the same ratio.
|
|
58
|
+
|
|
59
|
+
The canvas covers the whole screen, including the area under the system clock.
|
|
60
|
+
watchOS's safe area keeps about a fifth of the screen free at the top and
|
|
61
|
+
another at the bottom, which is too much to give up on a watch. Apps that need
|
|
62
|
+
the clock area clear lay themselves out around it, using the insets the shell
|
|
63
|
+
publishes as `:root` custom properties, in CSS px, measured for the watch it
|
|
64
|
+
runs on:
|
|
65
|
+
|
|
66
|
+
| Property | Meaning |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `--gea-safe-top` | clears the system clock |
|
|
69
|
+
| `--gea-safe-left`, `--gea-safe-right` | how far the rounded corners cut in at that depth |
|
|
70
|
+
| `--gea-safe-bottom` | where the bottom corners cut in no further than the sides |
|
|
71
|
+
| `--gea-screen-radius` | how deep the corner curve runs |
|
|
72
|
+
|
|
73
|
+
Other targets don't set them, so read them with a fallback:
|
|
74
|
+
`padding-top: var(--gea-safe-top, 4px)`. The values come from a table in
|
|
75
|
+
`main/watchos_host.mm`, one row per panel size: corners from each Simulator
|
|
76
|
+
device type's `framebufferMask`, the clock measured from a blank app. A watch
|
|
77
|
+
with a new panel size gets the nearest row, scaled by height, until it has its
|
|
78
|
+
own.
|
|
79
|
+
|
|
80
|
+
## Limits
|
|
81
|
+
|
|
82
|
+
- Runtime `gea` apps only. Apple SDK bindings (`@geastack/apple/UIKit` and the
|
|
83
|
+
rest) are not available: they drive UIKit views, and the build compiles with
|
|
84
|
+
`--no-apple-native`.
|
|
85
|
+
- No text input or virtual keyboard.
|
|
86
|
+
- Apps with their own ESP32 native code (`diagnostics`, `e-reader`,
|
|
87
|
+
`gea3d-cube`, `gea-bench`, `ttf-bench`), GPIO hardware (`headless-led`) or a
|
|
88
|
+
board-specific bitmap font (`m5-stopwatch`) do not build here.
|
|
89
|
+
- Only 40mm and larger watches are tested. Fixed-pixel layouts drawn for 245x299 (such as
|
|
90
|
+
`counter-jsx`) clip slightly on the 40mm SE.
|
|
91
|
+
|
|
92
|
+
## Simulator and device
|
|
93
|
+
|
|
94
|
+
The simulator path picks a booted Apple Watch simulator, otherwise an Apple
|
|
95
|
+
Watch Series model. Set `GEA_WATCHOS_SIMULATOR_UDID` to choose one, and
|
|
96
|
+
`GEA_WATCHOS_OPEN_SIMULATOR=0` to leave the simulator window (Simulator.app, or DeviceHub.app on Xcode 27) closed.
|
|
97
|
+
|
|
98
|
+
Device builds go through the paired iPhone. Name the watch with
|
|
99
|
+
`GEA_WATCHOS_DEVICE_ID` (from `xcrun devicectl list devices`) and the team with
|
|
100
|
+
`GEA_WATCHOS_DEVELOPMENT_TEAM` (`GEA_IOS_DEVELOPMENT_TEAM` and Xcode's last
|
|
101
|
+
selected team also work):
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
GEA_WATCHOS_DEVICE_ID=<id> GEA_WATCHOS_DEVELOPMENT_TEAM=ABCDE12345 npx gea run --target watchos --mode device
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`gea build --target watchos --mode device` without a team builds an unsigned
|
|
108
|
+
`watchos` binary, which is enough to check that the app compiles for hardware.
|
|
109
|
+
|
|
110
|
+
## Test
|
|
111
|
+
|
|
112
|
+
`test/run-watchos-counter-ui-test.sh <path/to/examples/apps/counter-jsx>` builds
|
|
113
|
+
the counter for a watch simulator and runs `GeaWatchCounterUITests`. The test
|
|
114
|
+
checks that tapping `+` repaints the counter and that a tap on empty background
|
|
115
|
+
changes nothing. The test files only exist in a checkout of this repository. The
|
|
116
|
+
generator adds the UI-test target when it finds them.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
5
|
+
WATCHOS_DIR="$ROOT_DIR/targets/watchos"
|
|
6
|
+
|
|
7
|
+
# The project is the directory this script was started in, as for iOS: the app
|
|
8
|
+
# folder, which every nested `gea` call resolves from too.
|
|
9
|
+
BUILD_INVOCATION_CWD="$(pwd -P)"
|
|
10
|
+
|
|
11
|
+
# Resolve the gea framework through npm the way build-ios.sh does: walk the
|
|
12
|
+
# node_modules chain from the app first (a hoisted install), then from this
|
|
13
|
+
# package (a linked checkout).
|
|
14
|
+
resolve_gea_package_from() {
|
|
15
|
+
node -e '
|
|
16
|
+
const fs = require("node:fs")
|
|
17
|
+
const path = require("node:path")
|
|
18
|
+
let dir = process.argv[1]
|
|
19
|
+
while (true) {
|
|
20
|
+
const candidate = path.join(dir, "node_modules", process.argv[2])
|
|
21
|
+
if (fs.existsSync(path.join(candidate, "package.json"))) {
|
|
22
|
+
process.stdout.write(fs.realpathSync(candidate))
|
|
23
|
+
break
|
|
24
|
+
}
|
|
25
|
+
const parent = path.dirname(dir)
|
|
26
|
+
if (parent === dir) break
|
|
27
|
+
dir = parent
|
|
28
|
+
}
|
|
29
|
+
' "$1" "$2" 2>/dev/null || true
|
|
30
|
+
}
|
|
31
|
+
resolve_gea_package() {
|
|
32
|
+
local start found
|
|
33
|
+
for start in "$BUILD_INVOCATION_CWD" "$ROOT_DIR"; do
|
|
34
|
+
found="$(resolve_gea_package_from "$start" "$1")"
|
|
35
|
+
if [[ -n "$found" ]]; then
|
|
36
|
+
printf '%s' "$found"
|
|
37
|
+
return 0
|
|
38
|
+
fi
|
|
39
|
+
done
|
|
40
|
+
}
|
|
41
|
+
GEA_CORE="$(resolve_gea_package @geastack/core)"
|
|
42
|
+
[ -n "$GEA_CORE" ] && [ -f "$GEA_CORE/package.json" ] || { echo "Cannot resolve @geastack/core from $BUILD_INVOCATION_CWD — add @geastack/apple to the app's dependencies and run 'npm install' there" >&2; exit 1; }
|
|
43
|
+
GEA_COMPILER="$(resolve_gea_package @geastack/compiler)"
|
|
44
|
+
[ -n "$GEA_COMPILER" ] && [ -f "$GEA_COMPILER/package.json" ] || { echo "Cannot resolve @geastack/compiler from $BUILD_INVOCATION_CWD — add @geastack/apple to the app's dependencies and run 'npm install' there" >&2; exit 1; }
|
|
45
|
+
GEA_HOST_DIR="${GEA_HOST_DIR:-$GEA_CORE/../host}"
|
|
46
|
+
GEA_ENGINE_DIR="${GEA_ENGINE_DIR:-$GEA_CORE/../engine}"
|
|
47
|
+
GEA_ELEMENTS_DIR="${GEA_ELEMENTS_DIR:-$GEA_CORE/../elements}"
|
|
48
|
+
GEA_GEAOS_PACKAGE_DIR="${GEA_GEAOS_PACKAGE_DIR:-$GEA_CORE/../geaos}"
|
|
49
|
+
# gea_sources.mjs runs as a child process and reads these from the environment.
|
|
50
|
+
export GEA_CORE GEA_HOST_DIR GEA_ENGINE_DIR GEA_ELEMENTS_DIR GEA_GEAOS_PACKAGE_DIR
|
|
51
|
+
GEA_CLI="${GEA_CLI_BIN:-}"
|
|
52
|
+
if [[ -z "$GEA_CLI" ]]; then
|
|
53
|
+
GEA_CLI="$(node -e 'process.stdout.write(require("path").join(process.argv[1], "bin", "gea.mjs"))' "$(resolve_gea_package @geastack/cli)" 2>/dev/null || true)"
|
|
54
|
+
if [[ ! -f "$GEA_CLI" ]]; then
|
|
55
|
+
GEA_CLI="$(command -v gea || true)"
|
|
56
|
+
fi
|
|
57
|
+
fi
|
|
58
|
+
[ -n "$GEA_CLI" ] && [ -f "$GEA_CLI" ] || { echo "Cannot locate GeaStack CLI — set GEA_CLI_BIN to gea.mjs, install @geastack/cli locally, or add gea to PATH" >&2; exit 1; }
|
|
59
|
+
|
|
60
|
+
# Framework sources from the shared manifest, curated like iOS: no OTA or
|
|
61
|
+
# diagnostics services, no single-app runtime shell -- SwiftUI owns the run
|
|
62
|
+
# loop. The camera bridge stays: watchos_platform.mm answers it with "no camera".
|
|
63
|
+
# shellcheck source=/dev/null
|
|
64
|
+
source "$GEA_CORE/gea_sources.sh"
|
|
65
|
+
export GEA_FW_CXX_SOURCES="$(gea_fw_cxx_sources | grep -vE "/(runtime|services/[a-z_]+)\.cpp\$")"
|
|
66
|
+
export GEA_FW_C_SOURCES="$(gea_fw_c_sources)"
|
|
67
|
+
export GEA_FW_INCLUDE_DIRS="$(gea_fw_include_flags | sed "s/^-I//")"
|
|
68
|
+
APP_ID="${1:-counter-jsx}"
|
|
69
|
+
DESTINATION="${2:-simulator}"
|
|
70
|
+
|
|
71
|
+
if [[ "$DESTINATION" != "simulator" && "$DESTINATION" != "device" ]]; then
|
|
72
|
+
echo "usage: targets/watchos/build-watchos.sh [app-id] [simulator|device]" >&2
|
|
73
|
+
exit 2
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
APP_INFO="$(node "$GEA_CLI" apps inspect "$APP_ID" --format shell)" || {
|
|
77
|
+
echo "Unknown app id: $APP_ID" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
IFS=$'\t' read -r APP_ROOT APP_ENTRY APP_RUNTIME APP_DISPLAY_NAME <<< "$APP_INFO"
|
|
82
|
+
if [[ "$APP_RUNTIME" != "gea" ]]; then
|
|
83
|
+
echo "watchOS target only supports runtime=gea apps: $APP_ID is runtime=$APP_RUNTIME" >&2
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
APP_NAME="$(node -e "
|
|
87
|
+
const raw = process.argv[1] || process.argv[2];
|
|
88
|
+
console.log(raw.replace(/(^|[-_\\s])([a-z])/g, (_, p, c) => c.toUpperCase()).replace(/[-_\\s]+/g, ''));
|
|
89
|
+
" "$APP_DISPLAY_NAME" "$APP_ID")"
|
|
90
|
+
BUNDLE_ID="${GEA_WATCHOS_BUNDLE_IDENTIFIER:-com.gea.watch.${APP_ID//[^A-Za-z0-9]/-}}"
|
|
91
|
+
# Output belongs to the app being built, never to this package (see build-ios.sh).
|
|
92
|
+
WATCHOS_OUTPUT_ROOT="${GEA_WATCHOS_OUTPUT_DIR:-$BUILD_INVOCATION_CWD/dist/watchos}"
|
|
93
|
+
case "$WATCHOS_OUTPUT_ROOT" in
|
|
94
|
+
/*) ;;
|
|
95
|
+
*) WATCHOS_OUTPUT_ROOT="$(pwd -P)/$WATCHOS_OUTPUT_ROOT" ;;
|
|
96
|
+
esac
|
|
97
|
+
GENERATED_DIR="$WATCHOS_OUTPUT_ROOT/.generated/$APP_ID"
|
|
98
|
+
PROJECT_PATH="$WATCHOS_OUTPUT_ROOT/$APP_ID/GeaWatch.xcodeproj"
|
|
99
|
+
DERIVED_DATA="$WATCHOS_OUTPUT_ROOT/.derived-data/$APP_ID-$DESTINATION"
|
|
100
|
+
CONFIGURATION="${GEA_WATCHOS_CONFIGURATION:-Debug}"
|
|
101
|
+
SKIP_LAUNCH="${GEA_WATCHOS_SKIP_LAUNCH:-0}"
|
|
102
|
+
|
|
103
|
+
mkdir -p "$GENERATED_DIR"
|
|
104
|
+
|
|
105
|
+
# How many physical pixels one CSS px covers. Apple Watch panels are the same
|
|
106
|
+
# class as the ESP32 watch boards (368x448, 410x502 ...), which declare 1.5, so
|
|
107
|
+
# an app looks the same size on either. An app overrides it the way the CLI's
|
|
108
|
+
# build config reads it: gea.targets.watchos.cssDevicePixelRatio, then
|
|
109
|
+
# gea.cssDevicePixelRatio.
|
|
110
|
+
CSS_DEVICE_PIXEL_RATIO="${GEA_WATCHOS_CSS_DEVICE_PIXEL_RATIO:-$(node -e '
|
|
111
|
+
const gea = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")).gea || {}
|
|
112
|
+
const target = gea.targets && typeof gea.targets.watchos === "object" ? gea.targets.watchos : {}
|
|
113
|
+
const ratio = Number(target.cssDevicePixelRatio || gea.cssDevicePixelRatio || 1.5)
|
|
114
|
+
process.stdout.write(String(ratio > 0 ? ratio : 1.5))
|
|
115
|
+
' "$APP_ROOT/package.json")}"
|
|
116
|
+
|
|
117
|
+
# Bake glyph atlases at the layout ratio, and give vw/vh-sized text the
|
|
118
|
+
# physical panel sizes of current watches (40mm SE .. 49mm Ultra 3).
|
|
119
|
+
build_font_args=(
|
|
120
|
+
--font-device-pixel-ratio "${GEA_WATCHOS_FONT_DEVICE_PIXEL_RATIOS:-$CSS_DEVICE_PIXEL_RATIO}"
|
|
121
|
+
--font-viewport-width "${GEA_WATCHOS_FONT_VIEWPORT_WIDTHS:-324,352,368,374,396,410,416,422}"
|
|
122
|
+
--font-viewport-height "${GEA_WATCHOS_FONT_VIEWPORT_HEIGHTS:-394,430,446,448,484,496,502,514}"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# watchOS has no UIView tree for the Apple SDK bindings to drive, so apps are
|
|
126
|
+
# compiled without them (no native bridge, no apple-native geatsc plugin).
|
|
127
|
+
args=(
|
|
128
|
+
--no-apple-native
|
|
129
|
+
--app-dir "$APP_ROOT"
|
|
130
|
+
--entry "$APP_ENTRY"
|
|
131
|
+
--out-dir "$GENERATED_DIR"
|
|
132
|
+
"${build_font_args[@]}"
|
|
133
|
+
)
|
|
134
|
+
if [[ -f "$APP_ROOT/watchos/geatsc-native-plugin.mjs" ]]; then
|
|
135
|
+
args+=(--extra-geatsc-plugin "$APP_ROOT/watchos/geatsc-native-plugin.mjs")
|
|
136
|
+
fi
|
|
137
|
+
node "$GEA_CORE/scripts/build-gea-vite-geatsc.mjs" "${args[@]}"
|
|
138
|
+
|
|
139
|
+
if [[ ! -f "$GENERATED_DIR/gea_runtime.cpp" ]]; then
|
|
140
|
+
echo "#include \"$GEA_COMPILER/dist/targets/cpp/runtime/runtime.cpp\"" > "$GENERATED_DIR/gea_runtime.cpp"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
GEA_CLI_BIN="$GEA_CLI" node "$WATCHOS_DIR/generate-xcode-project.mjs" \
|
|
144
|
+
--app-id "$APP_ID" \
|
|
145
|
+
--app-name "$APP_NAME" \
|
|
146
|
+
--display-name "$APP_DISPLAY_NAME" \
|
|
147
|
+
--bundle-id "$BUNDLE_ID" \
|
|
148
|
+
--css-device-pixel-ratio "$CSS_DEVICE_PIXEL_RATIO" \
|
|
149
|
+
--generated-dir "$GENERATED_DIR" \
|
|
150
|
+
--project-path "$PROJECT_PATH"
|
|
151
|
+
|
|
152
|
+
# Picks a booted Apple Watch simulator, else a mid-size Series model: the
|
|
153
|
+
# 40mm SE is smaller than most gea layouts are drawn for.
|
|
154
|
+
pick_simulator_device() {
|
|
155
|
+
local devices_json
|
|
156
|
+
devices_json="$(xcrun simctl list devices available --json 2>/dev/null || true)"
|
|
157
|
+
[[ -z "$devices_json" ]] && return 0
|
|
158
|
+
node -e "
|
|
159
|
+
const data = JSON.parse(require('fs').readFileSync(0, 'utf8'));
|
|
160
|
+
const watches = Object.entries(data.devices || {})
|
|
161
|
+
.filter(([runtime]) => /watchOS/.test(runtime))
|
|
162
|
+
.flatMap(([, list]) => list)
|
|
163
|
+
.filter((d) => d.isAvailable && /^Apple Watch/.test(d.name));
|
|
164
|
+
const preferred = watches.find((d) => d.state === 'Booted') || watches.find((d) => /Series/.test(d.name)) || watches[0];
|
|
165
|
+
if (preferred) console.log(preferred.udid);
|
|
166
|
+
" <<< "$devices_json"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
show_simulator_device() {
|
|
170
|
+
[[ "${GEA_WATCHOS_OPEN_SIMULATOR:-1}" == "1" ]] || return 0
|
|
171
|
+
# Only a convenience: the device boots, installs and launches without the
|
|
172
|
+
# GUI. Xcode 27 replaced Simulator.app with DeviceHub.app (bundle id
|
|
173
|
+
# com.apple.dt.Devices), which shows every booted simulator.
|
|
174
|
+
/usr/bin/open -a Simulator --args -CurrentDeviceUDID "$1" 2>/dev/null ||
|
|
175
|
+
/usr/bin/open -b com.apple.dt.Devices 2>/dev/null ||
|
|
176
|
+
echo "Could not open Simulator.app or DeviceHub.app; the simulator runs without a window." >&2
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
SDK="watchsimulator"
|
|
180
|
+
XCODE_DESTINATION="${GEA_WATCHOS_SIMULATOR_DESTINATION:-generic/platform=watchOS Simulator}"
|
|
181
|
+
SIMULATOR_DEVICE_ID="${GEA_WATCHOS_SIMULATOR_UDID:-}"
|
|
182
|
+
EXTRA_BUILD_SETTINGS=()
|
|
183
|
+
EXTRA_XCODEBUILD_ARGS=()
|
|
184
|
+
WATCH_DEVICE_ID="${GEA_WATCHOS_DEVICE_ID:-}"
|
|
185
|
+
if [[ "$DESTINATION" == "simulator" && "$SKIP_LAUNCH" != "1" && -z "$SIMULATOR_DEVICE_ID" ]]; then
|
|
186
|
+
SIMULATOR_DEVICE_ID="$(pick_simulator_device)"
|
|
187
|
+
if [[ -z "$SIMULATOR_DEVICE_ID" ]]; then
|
|
188
|
+
echo "No available Apple Watch simulator found. Add one in Xcode > Window > Devices and Simulators." >&2
|
|
189
|
+
exit 1
|
|
190
|
+
fi
|
|
191
|
+
fi
|
|
192
|
+
if [[ "$DESTINATION" == "simulator" && -n "$SIMULATOR_DEVICE_ID" && -z "${GEA_WATCHOS_SIMULATOR_DESTINATION:-}" ]]; then
|
|
193
|
+
XCODE_DESTINATION="platform=watchOS Simulator,id=$SIMULATOR_DEVICE_ID"
|
|
194
|
+
fi
|
|
195
|
+
if [[ "$DESTINATION" == "device" ]]; then
|
|
196
|
+
SDK="watchos"
|
|
197
|
+
XCODE_DESTINATION="${GEA_WATCHOS_DEVICE_DESTINATION:-generic/platform=watchOS}"
|
|
198
|
+
# A watch is reached through its paired iPhone, so there is no reliable way
|
|
199
|
+
# to pick one automatically: name it with GEA_WATCHOS_DEVICE_ID (the
|
|
200
|
+
# identifier `xcrun devicectl list devices` prints) to install and launch.
|
|
201
|
+
if [[ -z "$WATCH_DEVICE_ID" && "$SKIP_LAUNCH" != "1" ]]; then
|
|
202
|
+
echo "Set GEA_WATCHOS_DEVICE_ID to the watch's identifier from 'xcrun devicectl list devices' to install and launch," >&2
|
|
203
|
+
echo "or GEA_WATCHOS_SKIP_LAUNCH=1 to only build." >&2
|
|
204
|
+
exit 1
|
|
205
|
+
fi
|
|
206
|
+
DEVELOPMENT_TEAM="${GEA_WATCHOS_DEVELOPMENT_TEAM:-${GEA_IOS_DEVELOPMENT_TEAM:-}}"
|
|
207
|
+
if [[ -z "$DEVELOPMENT_TEAM" && "$SKIP_LAUNCH" != "1" ]]; then
|
|
208
|
+
if DEVELOPMENT_TEAM="$(node "$ROOT_DIR/targets/ios/detect-development-team.mjs")"; then
|
|
209
|
+
echo "Using Xcode development team $DEVELOPMENT_TEAM. Override with GEA_WATCHOS_DEVELOPMENT_TEAM." >&2
|
|
210
|
+
else
|
|
211
|
+
DEVELOPMENT_TEAM=""
|
|
212
|
+
fi
|
|
213
|
+
fi
|
|
214
|
+
if [[ -z "$DEVELOPMENT_TEAM" ]]; then
|
|
215
|
+
if [[ "$SKIP_LAUNCH" != "1" ]]; then
|
|
216
|
+
echo "Device builds require GEA_WATCHOS_DEVELOPMENT_TEAM for Xcode automatic signing." >&2
|
|
217
|
+
exit 1
|
|
218
|
+
fi
|
|
219
|
+
echo "GEA_WATCHOS_DEVELOPMENT_TEAM is not set; building an unsigned watchos binary." >&2
|
|
220
|
+
EXTRA_BUILD_SETTINGS+=("CODE_SIGNING_ALLOWED=NO" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGN_IDENTITY=")
|
|
221
|
+
else
|
|
222
|
+
EXTRA_BUILD_SETTINGS+=("DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM" "CODE_SIGN_STYLE=Automatic")
|
|
223
|
+
if [[ "${GEA_WATCHOS_ALLOW_PROVISIONING_UPDATES:-1}" == "1" ]]; then
|
|
224
|
+
EXTRA_XCODEBUILD_ARGS+=("-allowProvisioningUpdates")
|
|
225
|
+
fi
|
|
226
|
+
fi
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
xcodebuild \
|
|
230
|
+
${EXTRA_XCODEBUILD_ARGS[@]+"${EXTRA_XCODEBUILD_ARGS[@]}"} \
|
|
231
|
+
-project "$PROJECT_PATH" \
|
|
232
|
+
-scheme GeaWatch \
|
|
233
|
+
-configuration "$CONFIGURATION" \
|
|
234
|
+
-sdk "$SDK" \
|
|
235
|
+
-destination "$XCODE_DESTINATION" \
|
|
236
|
+
-derivedDataPath "$DERIVED_DATA" \
|
|
237
|
+
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID" \
|
|
238
|
+
${EXTRA_BUILD_SETTINGS[@]+"${EXTRA_BUILD_SETTINGS[@]}"} \
|
|
239
|
+
build
|
|
240
|
+
|
|
241
|
+
APP_PRODUCT="$DERIVED_DATA/Build/Products/$CONFIGURATION-$SDK/$APP_NAME.app"
|
|
242
|
+
echo "Built $APP_PRODUCT"
|
|
243
|
+
|
|
244
|
+
[[ "$SKIP_LAUNCH" == "1" ]] && exit 0
|
|
245
|
+
|
|
246
|
+
if [[ "$DESTINATION" == "simulator" ]]; then
|
|
247
|
+
show_simulator_device "$SIMULATOR_DEVICE_ID"
|
|
248
|
+
xcrun simctl boot "$SIMULATOR_DEVICE_ID" >/dev/null 2>&1 || true
|
|
249
|
+
xcrun simctl bootstatus "$SIMULATOR_DEVICE_ID" -b >/dev/null || true
|
|
250
|
+
xcrun simctl install "$SIMULATOR_DEVICE_ID" "$APP_PRODUCT"
|
|
251
|
+
xcrun simctl launch "$SIMULATOR_DEVICE_ID" "$BUNDLE_ID"
|
|
252
|
+
else
|
|
253
|
+
xcrun devicectl --timeout "${GEA_WATCHOS_DEVICECTL_TIMEOUT:-120}" device install app --device "$WATCH_DEVICE_ID" "$APP_PRODUCT"
|
|
254
|
+
xcrun devicectl --timeout "${GEA_WATCHOS_DEVICECTL_TIMEOUT:-120}" device process launch --terminate-existing --device "$WATCH_DEVICE_ID" "$BUNDLE_ID"
|
|
255
|
+
fi
|