Skip to content

Commit 89f4790

Browse files
authored
Include tvOS targets in XCFramework (#107)
1 parent 2606c8b commit 89f4790

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tool/build_xcframework.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ TARGETS=(
1919
aarch64-apple-watchos-sim
2020
x86_64-apple-watchos-sim
2121
arm64_32-apple-watchos
22+
23+
# tvOS and simulator
24+
aarch64-apple-tvos
25+
aarch64-apple-tvos-sim
26+
x86_64-apple-tvos
2227
)
2328
VERSION=0.4.2
2429

@@ -40,6 +45,19 @@ function generatePlist() {
4045
EOF
4146
)
4247
min_os_version="9.0";;
48+
*"tvos"*)
49+
additional_keys=$(cat <<EOF
50+
<key>CFBundleSupportedPlatforms</key>
51+
<array>
52+
<string>AppleTVOS</string>
53+
</array>
54+
<key>UIDeviceFamily</key>
55+
<array>
56+
<integer>3</integer>
57+
</array>
58+
EOF
59+
)
60+
min_os_version="13.0";;
4361
*)
4462
min_os_version="11.0";;
4563
esac
@@ -77,6 +95,7 @@ function createXcframework() {
7795
ios_plist=$(generatePlist "ios")
7896
macos_plist=$(generatePlist "macos")
7997
watchos_plist=$(generatePlist "watchos")
98+
tvos_plist=$(generatePlist "tvos")
8099

81100
echo "===================== create ios device framework ====================="
82101
mkdir -p "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework"
@@ -117,6 +136,22 @@ function createXcframework() {
117136
lipo ./target/aarch64-apple-watchos-sim/release_apple/libpowersync.a ./target/x86_64-apple-watchos-sim/release_apple/libpowersync.a -create -output "${BUILD_DIR}/watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
118137
# install_name_tool isn't necessary, we use a statically-linked library
119138

139+
echo "===================== create tvos device framework ====================="
140+
mkdir -p "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework"
141+
echo "${tvos_plist}" > "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework/Info.plist"
142+
cp -f "./target/aarch64-apple-tvos/release_apple/libpowersync.dylib" "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
143+
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
144+
# Generate dSYM for tvOS Device
145+
dsymutil "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" -o "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework.dSYM"
146+
147+
echo "===================== create tvos simulator framework ====================="
148+
mkdir -p "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework"
149+
echo "${tvos_plist}" > "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
150+
lipo ./target/aarch64-apple-tvos-sim/release_apple/libpowersync.dylib ./target/x86_64-apple-tvos/release_apple/libpowersync.dylib -create -output "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
151+
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
152+
# Generate dSYM for tvOS Simulator
153+
dsymutil "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core" -o "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM"
154+
120155
echo "===================== create xcframework ====================="
121156
rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework"
122157

@@ -129,6 +164,10 @@ function createXcframework() {
129164
-debug-symbols "$(pwd -P)/${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \
130165
-framework "${BUILD_DIR}/watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework" \
131166
-framework "${BUILD_DIR}/watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
167+
-framework "${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework" \
168+
-debug-symbols "$(pwd -P)/${BUILD_DIR}/tvos-arm64/powersync-sqlite-core.framework.dSYM" \
169+
-framework "${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
170+
-debug-symbols "$(pwd -P)/${BUILD_DIR}/tvos-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \
132171
-output "${BUILD_DIR}/powersync-sqlite-core.xcframework"
133172

134173
cp -Rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" "powersync-sqlite-core.xcframework"

0 commit comments

Comments
 (0)