Skip to content

Commit

Permalink
feat: tvOS support wip
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Jun 26, 2024
1 parent 5088f5f commit 5662a39
Show file tree
Hide file tree
Showing 64 changed files with 1,721 additions and 17 deletions.
2 changes: 1 addition & 1 deletion NativeScript/NativeScript-Prefix.pch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NativeScript_Prefix_pch
#define NativeScript_Prefix_pch

#define NATIVESCRIPT_VERSION "8.7.2"
#define NATIVESCRIPT_VERSION "8.7.3"

#ifdef DEBUG
#define SIZEOF_OFF_T 8
Expand Down
Binary file added NativeScript/lib/arm64-appletvos/libcppgc_base.a
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libcrdtp.a
Binary file not shown.
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libffi.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libv8_bigint.a
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libv8_compiler.a
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions NativeScript/lib/arm64-appletvos/libv8_heap_base_headers.a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!<arch>
Binary file added NativeScript/lib/arm64-appletvos/libv8_libbase.a
Binary file not shown.
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libv8_snapshot.a
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvos/libzip.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvsimulator/libffi.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!<arch>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added NativeScript/lib/arm64-appletvsimulator/libzip.a
Binary file not shown.
10 changes: 10 additions & 0 deletions build_all_tvos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

rm -rf ./dist
./update_version.sh
./build_metadata_generator.sh
./build_nativescript.sh --no-catalyst --no-iphone --no-sim --no-xr
./build_tklivesync.sh --no-catalyst --no-iphone --no-sim --no-xr
./prepare_dSYMs.sh
./build_npm_tvos.sh
39 changes: 39 additions & 0 deletions build_nativescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
BUILD_TV=$(to_bool ${BUILD_TV:=true})
VERBOSE=$(to_bool ${VERBOSE:=false})

for arg in $@; do
Expand All @@ -39,6 +40,8 @@ for arg in $@; do
--no-iphone|--no-device) BUILD_IPHONE=false ;;
--xr|--vision) BUILD_VISION=true ;;
--no-xr|--no-vision) BUILD_VISION=false ;;
--tv|--appletv) BUILD_TV=true ;;
--no-tv|--no-appletv) BUILD_TV=false ;;
--verbose|-v) VERBOSE=true ;;
*) ;;
esac
Expand Down Expand Up @@ -131,6 +134,35 @@ xcodebuild archive -project v8ios.xcodeproj \
-archivePath $DIST/intermediates/NativeScript.xrsimulator.xcarchive
fi

if $BUILD_TV; then

checkpoint "Building NativeScript for Apple TV Device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=tvOS" \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
VALID_ARCHS=arm64 \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/NativeScript.tvos.xcarchive

checkpoint "Building NativeScript for Apple TV Simulators"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=tvOS Simulator" \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
VALID_ARCHS=arm64 \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/NativeScript.tvsimulator.xcarchive
fi

XCFRAMEWORKS=()
if $BUILD_CATALYST; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.maccatalyst.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
Expand All @@ -154,6 +186,13 @@ if $BUILD_VISION; then
-debug-symbols "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi

if $BUILD_TV; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.tvos.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.tvos.xcarchive/dSYMs/NativeScript.framework.dSYM" )
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.tvsimulator.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.tvsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi

checkpoint "Creating NativeScript.xcframework"
OUTPUT_DIR="$DIST/NativeScript.xcframework"
rm -rf $OUTPUT_DIR
Expand Down
36 changes: 36 additions & 0 deletions build_npm_tvos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e
source "$(dirname "$0")/build_utils.sh"

checkpoint "Preparing npm package for tvOS..."
OUTPUT_DIR="dist/npm"
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR/framework"
cp ./package.json "$OUTPUT_DIR"

cp -r "./project-template-ios/" "$OUTPUT_DIR/framework"

cp -r "dist/NativeScript.xcframework" "$OUTPUT_DIR/framework/internal"
cp -r "dist/TKLiveSync.xcframework" "$OUTPUT_DIR/framework/internal"

mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
cp -r "metadata-generator/dist/x86_64/." "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"

mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
cp -r "metadata-generator/dist/arm64/." "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"

# Add xcframeworks to .zip (NPM modules do not support symlinks, unzipping is done by {N} CLI)
(
set -e
cd $OUTPUT_DIR/framework/internal
zip -qr --symlinks XCFrameworks.zip *.xcframework
rm -rf *.xcframework
)

pushd "$OUTPUT_DIR"
npm pack
mv *.tgz ../
popd

checkpoint "npm package created."
33 changes: 33 additions & 0 deletions build_tklivesync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
BUILD_TV=$(to_bool ${BUILD_TV:=true})
VERBOSE=$(to_bool ${VERBOSE:=false})

for arg in $@; do
Expand All @@ -39,6 +40,8 @@ for arg in $@; do
--no-iphone|--no-device) BUILD_IPHONE=false ;;
--xr|--vision) BUILD_VISION=true ;;
--no-xr|--no-vision) BUILD_VISION=false ;;
--tv|--appletv) BUILD_TV=true ;;
--no-tv|--no-appletv) BUILD_TV=false ;;
--verbose|-v) VERBOSE=true ;;
*) ;;
esac
Expand Down Expand Up @@ -118,6 +121,29 @@ xcodebuild archive -project v8ios.xcodeproj \
-archivePath $DIST/intermediates/TKLiveSync.xros.xcarchive
fi

if $BUILD_TV; then

checkpoint "Building TKLiveSync for Apple TV Device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "TKLiveSync" \
-configuration Release \
-destination "generic/platform=tvOS" \
-quiet \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/TKLiveSync.tvos.xcarchive

checkpoint "Building TKLiveSync for Apple TV Simulators"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "TKLiveSync" \
-configuration Release \
-destination "generic/platform=tvOS Simulator" \
-quiet \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/TKLiveSync.tvsimulator.xcarchive
fi

#Creates directory for fat-library
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
rm -rf "${OUTPUT_PATH}"
Expand Down Expand Up @@ -161,6 +187,13 @@ if $BUILD_VISION; then
-debug-symbols "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

if $BUILD_TV; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.tvos.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.tvos.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.tvsimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.tvsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

checkpoint "Creating TKLiveSync.xcframework"
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
rm -rf $OUTPUT_DIR
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/ios",
"description": "NativeScript Runtime for iOS",
"name": "@nativescript/tvos",
"description": "NativeScript Runtime for tvOS",
"version": "8.7.3",
"keywords": [
"NativeScript",
Expand All @@ -24,6 +24,7 @@
"build-v8-source": "./build_v8_source.sh",
"build-v8-source-catalyst": "./build_v8_source_catalyst.sh",
"build-ios": "node prepare-target ios && ./build_all_ios.sh",
"build-tvos": "node prepare-target tvos && ./build_all_tvos.sh",
"build-vision": "node prepare-target visionos && ./build_all_vision.sh",
"setup-ci": "./build_metadata_generator.sh",
"update-version": "./update_version.sh",
Expand Down
14 changes: 12 additions & 2 deletions prepare-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ const path = require('path');
const fs = require('fs');

const cmdArgs = process.argv.slice(2);
const target = cmdArgs[0]; // ios or visionos
const target = cmdArgs[0]; // ios, tvos or visionos

const packagePath = path.join('package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath));

packageJson.name = `@nativescript/${target}`;
packageJson.description = `NativeScript Runtime for ${target === 'ios' ? 'iOS' : 'visionOS'}`;
let targetName = 'iOS';
switch (target) {
case 'tvos':
targetName = 'tvOS';
break;
case 'visionos':
targetName = 'visionOS';
break;

}
packageJson.description = `NativeScript Runtime for ${targetName}`;

fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
Loading

0 comments on commit 5662a39

Please sign in to comment.