3
3
4
4
# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh
5
5
6
-
7
6
BUILD_DIR=./build
8
- DIST_PACKAGE_DIR=./dist
9
7
10
8
function createXcframework() {
11
- plist=$( cat << EOF
9
+ ios_plist=$(
10
+ cat << EOF
12
11
<?xml version="1.0" encoding="UTF-8"?>
13
12
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
14
13
<plist version="1.0">
@@ -34,26 +33,76 @@ function createXcframework() {
34
33
</dict>
35
34
</plist>
36
35
EOF
37
- )
36
+ )
37
+
38
+ watchos_plist=$(
39
+ cat << EOF
40
+ <?xml version="1.0" encoding="UTF-8"?>
41
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
42
+ <plist version="1.0">
43
+ <dict>
44
+ <key>CFBundleDevelopmentRegion</key>
45
+ <string>en</string>
46
+ <key>CFBundleExecutable</key>
47
+ <string>powersync-sqlite-core</string>
48
+ <key>CFBundleIdentifier</key>
49
+ <string>co.powersync.sqlitecore</string>
50
+ <key>CFBundleInfoDictionaryVersion</key>
51
+ <string>6.0</string>
52
+ <key>CFBundlePackageType</key>
53
+ <string>FMWK</string>
54
+ <key>CFBundleSignature</key>
55
+ <string>????</string>
56
+ <key>MinimumOSVersion</key>
57
+ <string>7.0</string>
58
+ <key>CFBundleVersion</key>
59
+ <string>0.3.12</string>
60
+ <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>
82
+ </dict>
83
+ </plist>
84
+ EOF
85
+ )
86
+
38
87
echo " ===================== create ios device framework ====================="
39
88
mkdir -p " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework"
40
- echo " ${plist } " > " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/Info.plist"
89
+ echo " ${ios_plist } " > " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/Info.plist"
41
90
cp -f " ./target/aarch64-apple-ios/release_apple/libpowersync.dylib" " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
42
91
install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
43
92
# Generate dSYM for iOS Device
44
93
dsymutil " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" -o " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework.dSYM"
45
94
46
95
echo " ===================== create ios simulator framework ====================="
47
96
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"
97
+ echo " ${ios_plist } " > " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
49
98
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"
50
99
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"
51
100
# Generate dSYM for iOS Simulator
52
101
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"
53
102
54
103
echo " ===================== create macos framework ====================="
55
104
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"
105
+ echo " ${ios_plist } " > " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
57
106
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"
58
107
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"
59
108
ln -sf A " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/Current"
62
111
# Generate dSYM for macOS
63
112
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"
64
113
114
+ 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.dylib" " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
118
+ install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
119
+ ln -sf A " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/Current"
120
+ ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
121
+ ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Resources"
122
+ # Generate dSYM for watchOS device
123
+ dsymutil " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" -o " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework.dSYM"
124
+
125
+ echo " ===================== create watchos simulator framework ====================="
126
+ mkdir -p " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources"
127
+ echo " ${watchos_plist} " > " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist"
128
+ cp -f " ./target/aarch64-apple-watchos-sim/release_apple/libpowersync.dylib" " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
129
+ install_name_tool -id " @rpath/powersync-sqlite-core.framework/powersync-sqlite-core" " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
130
+ ln -sf A " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/Current"
131
+ ln -sf Versions/Current/powersync-sqlite-core " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
132
+ ln -sf Versions/Current/Resources " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Resources"
133
+ # Generate dSYM for watchOS simulator
134
+ dsymutil " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" -o " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework.dSYM"
135
+
65
136
echo " ===================== create xcframework ====================="
66
137
rm -rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
67
- # "-debug-symbols" requires the absolute path
138
+ # Create iOS/macOS XCFramework
68
139
xcodebuild -create-xcframework \
69
140
-framework " ${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework" \
70
141
-debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64/powersync-sqlite-core.framework.dSYM" \
71
142
-framework " ${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
72
143
-debug-symbols " $( pwd -P) /${BUILD_DIR} /ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \
73
144
-framework " ${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework" \
74
145
-debug-symbols " $( pwd -P) /${BUILD_DIR} /macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \
75
- -output " ${BUILD_DIR} /powersync-sqlite-core.xcframework" \
146
+ -output " ${BUILD_DIR} /powersync-sqlite-core.xcframework"
76
147
148
+ # Create watchOS XCFramework
149
+ xcodebuild -create-xcframework \
150
+ -framework " ${BUILD_DIR} /watchos-arm64/powersync-sqlite-core.framework" \
151
+ -framework " ${BUILD_DIR} /watchos-arm64-simulator/powersync-sqlite-core.framework" \
152
+ -output " ${BUILD_DIR} /powersync-sqlite-core-watchos.xcframework"
153
+
154
+ # Copy the iOS/macOS XCFramework to the final location
77
155
cp -Rf " ${BUILD_DIR} /powersync-sqlite-core.xcframework" " powersync-sqlite-core.xcframework"
78
- zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework LICENSE README.md
156
+
157
+ # Create a zip file with both XCFrameworks
158
+ zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework powersync-sqlite-core-watchos.xcframework LICENSE README.md
79
159
rm -rf ${BUILD_DIR}
80
160
}
81
161
@@ -92,5 +172,16 @@ cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-
92
172
# macOS
93
173
cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-darwin -Zbuild-std
94
174
cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-darwin -Zbuild-std
175
+ # watchOS
176
+ export SDKROOT=$( xcrun --sdk watchos --show-sdk-path)
177
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_LINKER=$( xcrun --sdk watchos --find clang)
178
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_AR=$( xcrun --sdk watchos --find ar)
179
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_RANLIB=$( xcrun --sdk watchos --find ranlib)
180
+ cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos
181
+ export SDKROOT=$( xcrun --sdk watchsimulator --show-sdk-path)
182
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_LINKER=$( xcrun --sdk watchsimulator --find clang)
183
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_AR=$( xcrun --sdk watchsimulator --find ar)
184
+ export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_RANLIB=$( xcrun --sdk watchsimulator --find ranlib)
185
+ cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos-sim
95
186
96
187
createXcframework
0 commit comments