Skip to content

Commit 6b82de4

Browse files
committed
feat(tvos): support current V8 runtime and source-built reviewer setup
1 parent f7e3382 commit 6b82de4

33 files changed

Lines changed: 994 additions & 31 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ NativeScript/inspector/absl/
9393
#AI agents
9494
.claude/*
9595
!.claude/settings.json
96+
97+
NativeScript/lib/arm64-appletvos/
98+
NativeScript/lib/arm64-appletvsimulator/
99+
NativeScript/lib/.tvos-v8-version

NativeScript/runtime/NativeScriptException.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,11 @@ static void ShowErrorModalSynchronously(const std::string& title, const std::str
14421442
alpha:1.0]; // Terminal green
14431443
stackTraceTextView.backgroundColor = [UIColor clearColor];
14441444
stackTraceTextView.font = [UIFont fontWithName:@"Menlo" size:16]; // Monospace
1445+
#if !TARGET_OS_TV
1446+
// tvOS UITextView is never editable/selectable; the properties do not exist there.
14451447
stackTraceTextView.editable = NO;
14461448
stackTraceTextView.selectable = YES;
1449+
#endif
14471450
stackTraceTextView.scrollEnabled = YES;
14481451
stackTraceTextView.contentInset = UIEdgeInsetsMake(15, 15, 15, 15);
14491452
stackTraceTextView.translatesAutoresizingMaskIntoConstraints = NO;

build_all_tvos.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# tvOS archives must be built for this runtime's pinned V8 version.
5+
./scripts/install-tvos-v8.sh "${V8_TVOS_BUILD:?Set V8_TVOS_BUILD to the built v8-buildscripts checkout}"
6+
# Keep the matching source-built headers and inspector sources.
7+
export V8_SKIP_DOWNLOAD=1
8+
git submodule update --init libffi
9+
./build_libffi.sh --install arm64-appletvos arm64-appletvsimulator
10+
./tools/update-xcode-env.sh
11+
rm -rf ./dist
12+
./update_version.sh
13+
./build_metadata_generator.sh
14+
./build_nativescript.sh --no-catalyst --no-iphone --no-sim --no-vision --tvos
15+
./build_tklivesync.sh --no-catalyst --no-iphone --no-sim --no-vision --tvos
16+
./prepare_dSYMs.sh
17+
./build_npm_tvos.sh

build_libffi.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ALL_SLICES=(
2929
x86_64-maccatalyst
3030
)
3131

32+
TVOS_MIN=13.0
3233
IOS_MIN=13.0
3334
XROS_MIN=2.0
3435
CATALYST_MIN=13.3
@@ -41,6 +42,8 @@ Builds libffi from the ./libffi submodule for the given slices
4142
(default: all of ${ALL_SLICES[*]}).
4243
4344
Options:
45+
tvOS slices: arm64-appletvos arm64-appletvsimulator
46+
4447
--install also copy the built libraries and generated headers into
4548
NativeScript/lib/<slice>/ and NativeScript/include/libffi/<arch>/
4649
--jobs N parallel make jobs (default: number of CPUs)
@@ -98,6 +101,12 @@ slice_config() {
98101
arm64-iphonesimulator)
99102
echo "iphonesimulator|aarch64-apple-darwin|-arch arm64 -mios-simulator-version-min=$IOS_MIN"
100103
;;
104+
arm64-appletvos)
105+
echo "appletvos|aarch64-apple-darwin|-target arm64-apple-tvos$TVOS_MIN"
106+
;;
107+
arm64-appletvsimulator)
108+
echo "appletvsimulator|aarch64-apple-darwin|-target arm64-apple-tvos$TVOS_MIN-simulator"
109+
;;
101110
arm64-xros)
102111
echo "xros|aarch64-apple-darwin|-target arm64-apple-xros$XROS_MIN"
103112
;;

build_nativescript.sh

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
3131
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
3232
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
3333
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
34+
BUILD_TVOS=$(to_bool ${BUILD_TVOS:=false})
3435
VERBOSE=$(to_bool ${VERBOSE:=false})
3536

3637
for arg in $@; do
@@ -43,6 +44,8 @@ for arg in $@; do
4344
--no-iphone|--no-device) BUILD_IPHONE=false ;;
4445
--xr|--vision) BUILD_VISION=true ;;
4546
--no-xr|--no-vision) BUILD_VISION=false ;;
47+
--tv|--tvos) BUILD_TVOS=true ;;
48+
--no-tv|--no-tvos) BUILD_TVOS=false ;;
4649
--verbose|-v) VERBOSE=true ;;
4750
*) ;;
4851
esac
@@ -60,14 +63,14 @@ mkdir -p $DIST
6063
mkdir -p $DIST/intermediates
6164

6265
checkpoint "Cleanup NativeScript"
63-
xcodebuild -project v8ios.xcodeproj \
66+
xcodebuild SYMROOT="$DIST/build" -project v8ios.xcodeproj \
6467
-target "NativeScript" \
6568
-configuration Release clean \
6669
$QUIET
6770

6871
if $BUILD_CATALYST; then
6972
checkpoint "Building NativeScript for Mac Catalyst"
70-
xcodebuild archive -project v8ios.xcodeproj \
73+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
7174
-scheme "NativeScript" \
7275
-configuration Release \
7376
-destination "platform=macOS,variant=Mac Catalyst" \
@@ -81,7 +84,7 @@ fi
8184

8285
if $BUILD_SIMULATOR; then
8386
checkpoint "Building NativeScript for iphone simulators (multi-arch)"
84-
xcodebuild archive -project v8ios.xcodeproj \
87+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
8588
-scheme "NativeScript" \
8689
-configuration Release \
8790
-destination "generic/platform=iOS Simulator" \
@@ -96,7 +99,7 @@ fi
9699

97100
if $BUILD_IPHONE; then
98101
checkpoint "Building NativeScript for ARM64 device"
99-
xcodebuild archive -project v8ios.xcodeproj \
102+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
100103
-scheme "NativeScript" \
101104
-configuration Release \
102105
-destination "generic/platform=iOS" \
@@ -111,7 +114,7 @@ fi
111114

112115
if $BUILD_CATALYST; then
113116
checkpoint "Building NativeScript for Mac Catalyst"
114-
xcodebuild archive -project v8ios.xcodeproj \
117+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
115118
-scheme "NativeScript" \
116119
-configuration Release \
117120
-destination "generic/platform=macOS,variant=Mac Catalyst" \
@@ -125,7 +128,7 @@ fi
125128
if $BUILD_VISION; then
126129

127130
checkpoint "Building NativeScript for visionOS Device"
128-
xcodebuild archive -project v8ios.xcodeproj \
131+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
129132
-scheme "NativeScript" \
130133
-configuration Release \
131134
-destination "generic/platform=visionOS" \
@@ -138,7 +141,7 @@ xcodebuild archive -project v8ios.xcodeproj \
138141
-archivePath $DIST/intermediates/NativeScript.xros.xcarchive
139142

140143
checkpoint "Building NativeScript for visionOS Simulators"
141-
xcodebuild archive -project v8ios.xcodeproj \
144+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
142145
-scheme "NativeScript" \
143146
-configuration Release \
144147
-destination "generic/platform=visionOS Simulator" \
@@ -151,6 +154,35 @@ xcodebuild archive -project v8ios.xcodeproj \
151154
-archivePath $DIST/intermediates/NativeScript.xrsimulator.xcarchive
152155
fi
153156

157+
if $BUILD_TVOS; then
158+
159+
checkpoint "Building NativeScript for tvOS Device"
160+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
161+
-scheme "NativeScript" \
162+
-configuration Release \
163+
-destination "generic/platform=tvOS" \
164+
$QUIET \
165+
EXCLUDED_ARCHS="i386 x86_64" \
166+
VALID_ARCHS=arm64 \
167+
DEVELOPMENT_TEAM=$DEV_TEAM \
168+
SKIP_INSTALL=NO \
169+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
170+
-archivePath $DIST/intermediates/NativeScript.appletvos.xcarchive
171+
172+
checkpoint "Building NativeScript for tvOS Simulators"
173+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
174+
-scheme "NativeScript" \
175+
-configuration Release \
176+
-destination "generic/platform=tvOS Simulator" \
177+
$QUIET \
178+
EXCLUDED_ARCHS="i386 x86_64" \
179+
VALID_ARCHS=arm64 \
180+
DEVELOPMENT_TEAM=$DEV_TEAM \
181+
SKIP_INSTALL=NO \
182+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
183+
-archivePath $DIST/intermediates/NativeScript.appletvsimulator.xcarchive
184+
fi
185+
154186
XCFRAMEWORKS=()
155187
if $BUILD_CATALYST; then
156188
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.maccatalyst.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
@@ -174,6 +206,13 @@ if $BUILD_VISION; then
174206
-debug-symbols "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
175207
fi
176208

209+
if $BUILD_TVOS; then
210+
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.appletvos.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
211+
-debug-symbols "$DIST/intermediates/NativeScript.appletvos.xcarchive/dSYMs/NativeScript.framework.dSYM" )
212+
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.appletvsimulator.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
213+
-debug-symbols "$DIST/intermediates/NativeScript.appletvsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
214+
fi
215+
177216
checkpoint "Creating NativeScript.xcframework"
178217
OUTPUT_DIR="$DIST/NativeScript.xcframework"
179218
rm -rf $OUTPUT_DIR

build_npm_tvos.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e
3+
source "$(dirname "$0")/build_utils.sh"
4+
5+
checkpoint "Preparing npm package for tvOS..."
6+
OUTPUT_DIR="dist/npm"
7+
rm -rf "$OUTPUT_DIR"
8+
mkdir -p "$OUTPUT_DIR"
9+
mkdir -p "$OUTPUT_DIR/framework"
10+
cp ./package.json "$OUTPUT_DIR"
11+
12+
# Keep the template and runtime linkage in step with upstream iOS.
13+
cp -r "./project-template-ios/." "$OUTPUT_DIR/framework/"
14+
swift scripts/prepare-tvos-template.swift "$OUTPUT_DIR/framework"
15+
LOCAL_SPM_DIR="$OUTPUT_DIR/framework/internal/local-spm"
16+
mkdir -p "$LOCAL_SPM_DIR"
17+
cp spm-templates/local-spm-tvos/Package.swift "$LOCAL_SPM_DIR/"
18+
for framework in NativeScript TKLiveSync; do
19+
(cd dist && zip -qr --symlinks "npm/framework/internal/local-spm/$framework.xcframework.zip" "$framework.xcframework")
20+
done
21+
22+
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
23+
cp -r "metadata-generator/dist/x86_64/." "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
24+
25+
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
26+
cp -r "metadata-generator/dist/arm64/." "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
27+
28+
pushd "$OUTPUT_DIR"
29+
# Publish as @nativescript/tvos (same version as the iOS runtime it is built from) and drop the husky
30+
# "prepare" hook, which must not run for the published tarball.
31+
node -e 'const fs=require("fs");const p=JSON.parse(fs.readFileSync("package.json"));p.name="@nativescript/tvos";p.description="NativeScript Runtime for tvOS";delete p.scripts.prepare;fs.writeFileSync("package.json",JSON.stringify(p,null,2));'
32+
npm pack
33+
mv *.tgz ../
34+
popd
35+
36+
checkpoint "npm package created."

build_tklivesync.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
2727
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
2828
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
2929
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
30+
BUILD_TVOS=$(to_bool ${BUILD_TVOS:=false})
3031
VERBOSE=$(to_bool ${VERBOSE:=false})
3132

3233
for arg in $@; do
@@ -39,6 +40,8 @@ for arg in $@; do
3940
--no-iphone|--no-device) BUILD_IPHONE=false ;;
4041
--xr|--vision) BUILD_VISION=true ;;
4142
--no-xr|--no-vision) BUILD_VISION=false ;;
43+
--tv|--tvos) BUILD_TVOS=true ;;
44+
--no-tv|--no-tvos) BUILD_TVOS=false ;;
4245
--verbose|-v) VERBOSE=true ;;
4346
*) ;;
4447
esac
@@ -51,15 +54,15 @@ mkdir -p $DIST/intermediates
5154

5255
#cleanup
5356
checkpoint "Cleanup TKLiveSync"
54-
xcodebuild -project v8ios.xcodeproj \
57+
xcodebuild SYMROOT="$DIST/build" -project v8ios.xcodeproj \
5558
-target TKLiveSync \
5659
-configuration Release clean \
5760
-quiet
5861

5962
if $BUILD_SIMULATOR; then
6063
# generates library for simulator targets (usually includes arm64, x86_64)
6164
checkpoint "Building TKLiveSync for iphone simulators (multi-arch)"
62-
xcodebuild archive -project v8ios.xcodeproj \
65+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
6366
-scheme TKLiveSync \
6467
-configuration Release \
6568
-destination "generic/platform=iOS Simulator" \
@@ -72,7 +75,7 @@ fi
7275
if $BUILD_IPHONE; then
7376
#generates library for device target
7477
checkpoint "Building TKLiveSync for ARM64 device"
75-
xcodebuild archive -project v8ios.xcodeproj \
78+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
7679
-scheme TKLiveSync \
7780
-configuration Release \
7881
-destination "generic/platform=iOS" \
@@ -85,7 +88,7 @@ fi
8588
if $BUILD_CATALYST; then
8689
#generates library for Mac Catalyst target
8790
checkpoint "Building TKLiveSync for Mac Catalyst"
88-
xcodebuild archive -project v8ios.xcodeproj \
91+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
8992
-scheme TKLiveSync \
9093
-configuration Release \
9194
-destination "generic/platform=macOS,variant=Mac Catalyst" \
@@ -98,7 +101,7 @@ fi
98101
if $BUILD_VISION; then
99102
#generates library for visionOS targets
100103
checkpoint "Building TKLiveSync for visionOS Simulators"
101-
xcodebuild archive -project v8ios.xcodeproj \
104+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
102105
-scheme "TKLiveSync" \
103106
-configuration Release \
104107
-destination "generic/platform=visionOS Simulator" \
@@ -108,7 +111,7 @@ xcodebuild archive -project v8ios.xcodeproj \
108111
-archivePath $DIST/intermediates/TKLiveSync.xrsimulator.xcarchive
109112

110113
checkpoint "Building TKLiveSync for visionOS Device"
111-
xcodebuild archive -project v8ios.xcodeproj \
114+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
112115
-scheme "TKLiveSync" \
113116
-configuration Release \
114117
-destination "generic/platform=visionOS" \
@@ -118,6 +121,28 @@ xcodebuild archive -project v8ios.xcodeproj \
118121
-archivePath $DIST/intermediates/TKLiveSync.xros.xcarchive
119122
fi
120123

124+
if $BUILD_TVOS; then
125+
checkpoint "Building TKLiveSync for tvOS Simulators"
126+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
127+
-scheme "TKLiveSync" \
128+
-configuration Release \
129+
-destination "generic/platform=tvOS Simulator" \
130+
-quiet \
131+
SKIP_INSTALL=NO \
132+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
133+
-archivePath $DIST/intermediates/TKLiveSync.appletvsimulator.xcarchive
134+
135+
checkpoint "Building TKLiveSync for tvOS Device"
136+
xcodebuild archive -derivedDataPath "$DIST/DerivedData" -project v8ios.xcodeproj \
137+
-scheme "TKLiveSync" \
138+
-configuration Release \
139+
-destination "generic/platform=tvOS" \
140+
-quiet \
141+
SKIP_INSTALL=NO \
142+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
143+
-archivePath $DIST/intermediates/TKLiveSync.appletvos.xcarchive
144+
fi
145+
121146
#Creates directory for fat-library
122147
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
123148
rm -rf "${OUTPUT_PATH}"
@@ -161,6 +186,13 @@ if $BUILD_VISION; then
161186
-debug-symbols "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
162187
fi
163188

189+
if $BUILD_TVOS; then
190+
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.appletvos.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
191+
-debug-symbols "$DIST/intermediates/TKLiveSync.appletvos.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
192+
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.appletvsimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
193+
-debug-symbols "$DIST/intermediates/TKLiveSync.appletvsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
194+
fi
195+
164196
checkpoint "Creating TKLiveSync.xcframework"
165197
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
166198
rm -rf $OUTPUT_DIR

metadata-generator/build-step-metadata-generator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import re
45
import shlex
56
import subprocess
67
import sys
@@ -66,17 +67,20 @@ def map_and_list(func, iterable):
6667
elif effective_platform_name == "-appletvos":
6768
docset_platform = "tvOS"
6869
default_deployment_target_flag_name = "-mappletvos-version-min"
69-
default_deployment_target_clang_env_name = "APPLETVOS_DEPLOYMENT_TARGET"
70+
default_deployment_target_clang_env_name = "TVOS_DEPLOYMENT_TARGET"
7071
elif effective_platform_name == "-appletvsimulator":
7172
docset_platform = "tvOS"
7273
default_deployment_target_flag_name = "-mappletvsimulator-version-min"
73-
default_deployment_target_clang_env_name = "APPLETVOS_DEPLOYMENT_TARGET"
74+
default_deployment_target_clang_env_name = "TVOS_DEPLOYMENT_TARGET"
7475
elif effective_platform_name == "-iphoneos":
7576
default_deployment_target_flag_name = "-miphoneos-version-min"
7677

7778
sdk_version = env("SDK_VERSION") or "13.0"
7879
llvm_target_triple_suffix = env_or_empty("LLVM_TARGET_TRIPLE_SUFFIX")
79-
llvm_target_triple_os_version = "ios{}".format(sdk_version)
80+
# The OS part of the triple ("ios", "tvos", ...) comes from Xcode's LLVM_TARGET_TRIPLE_OS_VERSION
81+
# (e.g. "tvos16.0"); its version is the deployment target, so the SDK version is substituted instead.
82+
llvm_target_triple_os = re.sub(r"[0-9.]+$", "", env_or_empty("LLVM_TARGET_TRIPLE_OS_VERSION")) or "ios"
83+
llvm_target_triple_os_version = "{}{}".format(llvm_target_triple_os, sdk_version)
8084
# env("LLVM_TARGET_TRIPLE_OS_VERSION") is the deployment target, so doesn't have all APIs
8185
# usually it's ios9.0 for NativeScript projects
8286
llvm_target_triple_vendor = env("LLVM_TARGET_TRIPLE_VENDOR") or "apple"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"setup-ci": "./build_metadata_generator.sh",
3131
"update-version": "./update_version.sh",
3232
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
33-
"version": "npm run changelog && git add CHANGELOG.md"
33+
"version": "npm run changelog && git add CHANGELOG.md",
34+
"build-tvos": "node prepare-target tvos && ./build_all_tvos.sh"
3435
},
3536
"license": "Apache-2.0",
3637
"devDependencies": {

0 commit comments

Comments
 (0)