44# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh
55
66BUILD_DIR=./build
7-
8- function createXcframework() {
9- ios_plist=$(
10- cat << EOF
11- <?xml version="1.0" encoding="UTF-8"?>
12- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
13- <plist version="1.0">
14- <dict>
15- <key>CFBundleDevelopmentRegion</key>
16- <string>en</string>
17- <key>CFBundleExecutable</key>
18- <string>powersync-sqlite-core</string>
19- <key>CFBundleIdentifier</key>
20- <string>co.powersync.sqlitecore</string>
21- <key>CFBundleInfoDictionaryVersion</key>
22- <string>6.0</string>
23- <key>CFBundlePackageType</key>
24- <string>FMWK</string>
25- <key>CFBundleSignature</key>
26- <string>????</string>
27- <key>MinimumOSVersion</key>
28- <string>11.0</string>
29- <key>CFBundleVersion</key>
30- <string>0.4.0</string>
31- <key>CFBundleShortVersionString</key>
32- <string>0.4.0</string>
33- </dict>
34- </plist>
7+ TARGETS=(
8+ # iOS and simulator
9+ aarch64-apple-ios
10+ aarch64-apple-ios-sim
11+ x86_64-apple-ios
12+
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>
3540EOF
36- )
41+ )
42+ min_os_version=" 9.0" ;;
43+ * )
44+ min_os_version=" 11.0" ;;
45+ esac
3746
38- watchos_plist=$(
39- cat << EOF
47+ cat << EOF
4048<?xml version="1.0" encoding="UTF-8"?>
4149<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4250<plist version="1.0">
5462 <key>CFBundleSignature</key>
5563 <string>????</string>
5664 <key>MinimumOSVersion</key>
57- <string>7.0 </string>
65+ <string>$min_os_version </string>
5866 <key>CFBundleVersion</key>
59- <string>0.3.12 </string>
67+ <string>$VERSION </string>
6068 <key>CFBundleShortVersionString</key>
61- <string>0.3.12</string>
62- <key>UIDeviceFamily</key>
63- <array>
64- <integer>4</integer>
65- </array>
66- <key>DTSDKName</key>
67- <string>watchos</string>
68- <key>DTPlatformName</key>
69- <string>watchos</string>
70- <key>DTPlatformVersion</key>
71- <string>7.0</string>
72- <key>DTXcode</key>
73- <string>1500</string>
74- <key>DTXcodeBuild</key>
75- <string>15A240d</string>
76- <key>DTCompiler</key>
77- <string>com.apple.compilers.llvm.clang.1_0</string>
78- <key>DTPlatformBuild</key>
79- <string>21R355</string>
80- <key>BuildMachineOSBuild</key>
81- <string>23D60</string>
69+ <string>$VERSION </string>
70+ $additional_keys
8271</dict>
8372</plist>
8473EOF
85- )
74+ }
75+
76+ function createXcframework() {
77+ ios_plist=$( generatePlist " ios" )
78+ macos_plist=$( generatePlist " macos" )
79+ watchos_plist=$( generatePlist " watchos" )
8680
8781 echo " ===================== create ios device framework ====================="
8882 mkdir -p " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework"
@@ -112,20 +106,22 @@ EOF
112106 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"
113107
114108 echo " ===================== create watchos device framework ====================="
115- mkdir -p " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources"
116- echo " ${watchos_plist} " > " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
117- cp -f " ./target/aarch64-apple-watchos/release_apple/libpowersync.a" " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
118- ln -sf A " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/Current"
119- ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
120- ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Resources"
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"
121116
122117 echo " ===================== create watchos simulator framework ====================="
123- mkdir -p " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources"
124- echo " ${watchos_plist} " > " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
125- 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-simulator/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
126- ln -sf A " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/Current"
127- ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
128- ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Resources"
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"
129125
130126 echo " ===================== create xcframework ====================="
131127 rm -rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
@@ -137,11 +133,11 @@ EOF
137133 -debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \
138134 -framework " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework" \
139135 -debug-symbols " $( pwd -P) /${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \
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" \
140138 -output " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
141139
142- # how to create a watchOS XCFramework with static libraries, possible?
143-
144- zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/libpowersync.a" " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/libpowersync.a" LICENSE README.md
140+ zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework LICENSE README.md
145141 rm -rf ${BUILD_DIR}
146142}
147143
150146
151147rm -rf powersync-sqlite-core.xcframework
152148
153- # iOS
154- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios -Zbuild-std
155- # Simulator
156- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios-sim -Zbuild-std
157- cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-ios -Zbuild-std
158- # macOS
159- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-darwin -Zbuild-std
160- cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-darwin -Zbuild-std
161- # watchOS
162- cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos
163- cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos-sim
164- cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target x86_64-apple-watchos-sim
149+ for TARGET in ${TARGETS[@]} ; do
150+ echo " Building PowerSync loadable extension for $TARGET "
151+ # cargo build -p powersync_loadable --profile release_apple --target $TARGET -Zbuild-std
152+ done
165153
166154createXcframework
0 commit comments