4
4
# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh
5
5
6
6
BUILD_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>
35
40
EOF
36
- )
41
+ )
42
+ min_os_version=" 9.0" ;;
43
+ * )
44
+ min_os_version=" 11.0" ;;
45
+ esac
37
46
38
- watchos_plist=$(
39
- cat << EOF
47
+ cat << EOF
40
48
<?xml version="1.0" encoding="UTF-8"?>
41
49
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
42
50
<plist version="1.0">
54
62
<key>CFBundleSignature</key>
55
63
<string>????</string>
56
64
<key>MinimumOSVersion</key>
57
- <string>7.0 </string>
65
+ <string>$min_os_version </string>
58
66
<key>CFBundleVersion</key>
59
- <string>0.3.12 </string>
67
+ <string>$VERSION </string>
60
68
<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
82
71
</dict>
83
72
</plist>
84
73
EOF
85
- )
74
+ }
75
+
76
+ function createXcframework() {
77
+ ios_plist=$( generatePlist " ios" )
78
+ macos_plist=$( generatePlist " macos" )
79
+ watchos_plist=$( generatePlist " watchos" )
86
80
87
81
echo " ===================== create ios device framework ====================="
88
82
mkdir -p " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework"
@@ -112,20 +106,22 @@ EOF
112
106
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"
113
107
114
108
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"
121
116
122
117
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"
129
125
130
126
echo " ===================== create xcframework ====================="
131
127
rm -rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
@@ -137,11 +133,11 @@ EOF
137
133
-debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \
138
134
-framework " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework" \
139
135
-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" \
140
138
-output " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
141
139
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
145
141
rm -rf ${BUILD_DIR}
146
142
}
147
143
150
146
151
147
rm -rf powersync-sqlite-core.xcframework
152
148
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
165
153
166
154
createXcframework
0 commit comments