33
44# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh
55
6-
76BUILD_DIR=./build
8- DIST_PACKAGE_DIR=./dist
7+ TARGETS=(
8+ # iOS and simulator
9+ aarch64-apple-ios
10+ aarch64-apple-ios-sim
11+ x86_64-apple-ios
912
10- function createXcframework() {
11- plist=$( cat << EOF
13+ # macOS
14+ aarch64-apple-darwin
15+ x86_64-apple-darwin
16+
17+ # watchOS and simulator
18+ aarch64-apple-watchos
19+ aarch64-apple-watchos-sim
20+ x86_64-apple-watchos-sim
21+ arm64_32-apple-watchos
22+ )
23+ VERSION=0.4.0
24+
25+ function generatePlist() {
26+ min_os_version=0
27+ additional_keys=" "
28+ # We support versions 11.0 or later for iOS and macOS. For watchOS, we need 9.0 or later.
29+ case $1 in
30+ * " watchos" * )
31+ additional_keys=$( cat << EOF
32+ <key>CFBundleSupportedPlatforms</key>
33+ <array>
34+ <string>WatchOS</string>
35+ </array>
36+ <key>UIDeviceFamily</key>
37+ <array>
38+ <integer>4</integer>
39+ </array>
40+ EOF
41+ )
42+ min_os_version=" 9.0" ;;
43+ * )
44+ min_os_version=" 11.0" ;;
45+ esac
46+
47+ cat << EOF
1248<?xml version="1.0" encoding="UTF-8"?>
1349<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1450<plist version="1.0">
@@ -26,34 +62,41 @@ function createXcframework() {
2662 <key>CFBundleSignature</key>
2763 <string>????</string>
2864 <key>MinimumOSVersion</key>
29- <string>11.0 </string>
65+ <string>$min_os_version </string>
3066 <key>CFBundleVersion</key>
31- <string>0.4.0 </string>
67+ <string>$VERSION </string>
3268 <key>CFBundleShortVersionString</key>
33- <string>0.4.0</string>
69+ <string>$VERSION </string>
70+ $additional_keys
3471</dict>
3572</plist>
3673EOF
37- )
74+ }
75+
76+ function createXcframework() {
77+ ios_plist=$( generatePlist " ios" )
78+ macos_plist=$( generatePlist " macos" )
79+ watchos_plist=$( generatePlist " watchos" )
80+
3881 echo " ===================== create ios device framework ====================="
3982 mkdir -p " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework"
40- echo " ${plist } " > " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/Info.plist"
83+ echo " ${ios_plist } " > " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/Info.plist"
4184 cp -f " ./target/aarch64-apple-ios/release_apple/libpowersync.dylib" " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
4285 install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
4386 # Generate dSYM for iOS Device
4487 dsymutil " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" -o " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework.dSYM"
4588
4689 echo " ===================== create ios simulator framework ====================="
4790 mkdir -p " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework"
48- echo " ${plist } " > " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
91+ echo " ${ios_plist } " > " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
4992 lipo ./target/aarch64-apple-ios-sim/release_apple/libpowersync.dylib ./target/x86_64-apple-ios/release_apple/libpowersync.dylib -create -output " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
5093 install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
5194 # Generate dSYM for iOS Simulator
5295 dsymutil " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core" -o " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM"
5396
5497 echo " ===================== create macos framework ====================="
5598 mkdir -p " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources"
56- echo " ${plist } " > " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
99+ echo " ${ios_plist } " > " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
57100 lipo ./target/x86_64-apple-darwin/release_apple/libpowersync.dylib ./target/aarch64-apple-darwin/release_apple/libpowersync.dylib -create -output " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
58101 install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
59102 ln -sf A " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/Current"
62105 # Generate dSYM for macOS
63106 dsymutil " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" -o " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM"
64107
108+ echo " ===================== create watchos device framework ====================="
109+ mkdir -p " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/Versions/A/Resources"
110+ echo " ${watchos_plist} " > " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
111+ lipo ./target/aarch64-apple-watchos/release_apple/libpowersync.a ./target/arm64_32-apple-watchos/release_apple/libpowersync.a -create -output " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
112+ # install_name_tool isn't necessary, we use a statically-linked library
113+ ln -sf A " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/Versions/Current"
114+ ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/powersync-sqlite-core"
115+ ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework/Resources"
116+
117+ echo " ===================== create watchos simulator framework ====================="
118+ mkdir -p " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/Versions/A/Resources"
119+ echo " ${watchos_plist} " > " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
120+ 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/Versions/A/powersync-sqlite-core"
121+ # install_name_tool isn't necessary, we use a statically-linked library
122+ ln -sf A " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/Versions/Current"
123+ ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
124+ ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework/Resources"
125+
65126 echo " ===================== create xcframework ====================="
66127 rm -rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
67- # "-debug-symbols" requires the absolute path
128+
68129 xcodebuild -create-xcframework \
69130 -framework " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework" \
70131 -debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework.dSYM" \
71132 -framework " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
72133 -debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \
73134 -framework " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework" \
74135 -debug-symbols " $( pwd -P) /${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \
75- -output " ${BUILD_DIR} /powersync-sqlite-core.xcframework" \
136+ -framework " ${BUILD_DIR} /watchos-arm64_arm64_32_armv7k/powersync-sqlite-core.framework" \
137+ -framework " ${BUILD_DIR} /watchos-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
138+ -output " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
76139
77140 cp -Rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework" " powersync-sqlite-core.xcframework"
78141 zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework LICENSE README.md
84147
85148rm -rf powersync-sqlite-core.xcframework
86149
87- # iOS
88- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios -Zbuild-std
89- # Simulator
90- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios-sim -Zbuild-std
91- cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-ios -Zbuild-std
92- # macOS
93- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-darwin -Zbuild-std
94- cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-darwin -Zbuild-std
150+ for TARGET in ${TARGETS[@]} ; do
151+ echo " Building PowerSync loadable extension for $TARGET "
152+
153+ if [[ $TARGET == * " watchos" * ]]; then
154+ cargo build \
155+ -p powersync_static \
156+ --profile release_apple \
157+ --target $TARGET \
158+ -Zbuild-std
159+ else
160+ cargo build -p powersync_loadable --profile release_apple --target $TARGET -Zbuild-std
161+ fi
162+ done
95163
96164createXcframework
0 commit comments