From 56f6d127e0cbc32afec9ebd7116fc56d6392992a Mon Sep 17 00:00:00 2001 From: Teo Stocco Date: Sat, 10 May 2025 20:55:15 -0600 Subject: [PATCH 1/2] feat: add watchos support --- .cargo/config.toml | 16 ++++- .github/workflows/ios.yml | 6 +- .github/workflows/release.yml | 6 +- Cargo.toml | 1 + crates/shell/Cargo.toml | 17 +++++- crates/shell/build.rs | 19 ++++-- crates/shell/src/main.rs | 1 - crates/sqlite/Cargo.toml | 12 ++++ crates/sqlite/build.rs | 18 ++++-- powersync-sqlite-core.podspec | 6 +- sqlite-rs-embedded | 2 +- tool/build_xcframework.sh | 111 +++++++++++++++++++++++++++++++--- 12 files changed, 183 insertions(+), 32 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index caa816c..ddb98b3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,4 +1,3 @@ - # Previously we added this to rustflags for all linux builds: # "-C", "link-arg=-lgcc_eh" # It was to fix this error when loading the loadable extension: @@ -86,3 +85,18 @@ rustflags = [ rustflags = [ "-C", "link-arg=-Wl,-soname,libpowersync.so", ] + +[target.aarch64-apple-watchos] +rustflags = [ + "-C", "link-arg=-mwatchos-version-min=7.0", +] + +[target.aarch64-apple-watchos-sim] +rustflags = [ + "-C", "link-arg=-mwatchsimulator-version-min=7.0", +] + +[target.x86_64-apple-watchos] +rustflags = [ + "-C", "link-arg=-mwatchos-version-min=7.0", +] diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index aebd68e..98a1c6e 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -21,8 +21,10 @@ jobs: aarch64-apple-darwin \ aarch64-apple-ios \ aarch64-apple-ios-sim \ - x86_64-apple-ios - + x86_64-apple-ios \ + aarch64-apple-watchos \ + aarch64-apple-watchos-sim \ + x86_64-apple-watchos - name: setup-cocoapods uses: maxim-lobanov/setup-cocoapods@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36028f3..17d9231 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,8 +91,10 @@ jobs: aarch64-apple-darwin \ aarch64-apple-ios \ aarch64-apple-ios-sim \ - x86_64-apple-ios - + x86_64-apple-ios \ + aarch64-apple-watchos \ + aarch64-apple-watchos-sim \ + x86_64-apple-watchos - name: setup-cocoapods uses: maxim-lobanov/setup-cocoapods@v1 with: diff --git a/Cargo.toml b/Cargo.toml index 3506783..2cb7266 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,3 +39,4 @@ repository = "https://github.com/powersync-ja/powersync-sqlite-core" [workspace.dependencies] sqlite_nostd = { path="./sqlite-rs-embedded/sqlite_nostd" } + diff --git a/crates/shell/Cargo.toml b/crates/shell/Cargo.toml index eb8200f..28527f8 100644 --- a/crates/shell/Cargo.toml +++ b/crates/shell/Cargo.toml @@ -8,12 +8,23 @@ license.workspace = true authors.workspace = true keywords.workspace = true +[lib] +name = "powersync_sqlite" +path = "src/main.rs" +crate-type = ["staticlib"] + +[[bin]] +name = "powersync_sqlite" +path = "src/main.rs" +required-features = ["shell"] + [dependencies] -powersync_core = { path="../core" } -sqlite_nostd = { workspace=true } +powersync_core = { path="../core", default-features = false, features = ["static", "omit_load_extension"] } +sqlite_nostd = { workspace=true, features = ["static", "omit_load_extension"] } [features] -default = ["powersync_core/static", "powersync_core/omit_load_extension", "sqlite_nostd/static", "sqlite_nostd/omit_load_extension"] +default = [] +shell = [] [build-dependencies] cc = "1.0.46" diff --git a/crates/shell/build.rs b/crates/shell/build.rs index f753d36..e696125 100644 --- a/crates/shell/build.rs +++ b/crates/shell/build.rs @@ -1,10 +1,10 @@ - fn main() { let mut cfg = cc::Build::new(); + let target = std::env::var("TARGET").unwrap(); + let is_watchos = target.contains("watchos") || target.contains("watchsimulator"); // Compile the SQLite source cfg.file("../sqlite/sqlite/sqlite3.c"); - cfg.file("../sqlite/sqlite/shell.c"); cfg.include("../sqlite/sqlite"); // General SQLite options @@ -14,8 +14,17 @@ fn main() { // Call core_init() in main.rs cfg.define("SQLITE_EXTRA_INIT", Some("core_init")); - // Compile with readline support (also requires -lreadline / cargo:rustc-link-lib=readline below) - cfg.define("HAVE_READLINE", Some("1")); + if is_watchos { + // For watchOS, don't build the shell and disable readline + cfg.define("HAVE_READLINE", Some("0")); + cfg.define("HAVE_EDITLINE", Some("0")); + cfg.define("SQLITE_OMIT_SYSTEM", Some("1")); + } else { + // For other platforms, build the shell with readline + cfg.file("../sqlite/sqlite/shell.c"); + cfg.define("HAVE_READLINE", Some("1")); + println!("cargo:rustc-link-lib=readline"); + } // Silence warnings generated for SQLite cfg.flag("-Wno-implicit-fallthrough"); @@ -23,6 +32,4 @@ fn main() { cfg.flag("-Wno-null-pointer-subtraction"); cfg.compile("sqlite-ps"); - - println!("cargo:rustc-link-lib=readline"); } diff --git a/crates/shell/src/main.rs b/crates/shell/src/main.rs index 6a6d8af..b55f707 100644 --- a/crates/shell/src/main.rs +++ b/crates/shell/src/main.rs @@ -28,7 +28,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { #[lang = "eh_personality"] extern "C" fn eh_personality() {} - #[no_mangle] pub extern "C" fn core_init(_dummy: *mut c_char) -> c_int { powersync_init_static() diff --git a/crates/sqlite/Cargo.toml b/crates/sqlite/Cargo.toml index 5e6b0d0..09e28ba 100644 --- a/crates/sqlite/Cargo.toml +++ b/crates/sqlite/Cargo.toml @@ -8,9 +8,21 @@ license.workspace = true authors.workspace = true keywords.workspace = true +[lib] +name = "sqlite3" +path = "src/main.rs" +crate-type = ["staticlib"] + +[[bin]] +name = "sqlite3" +path = "src/main.rs" +required-features = ["shell"] + [dependencies] [features] +default = [] +shell = [] [build-dependencies] cc = "1.0.46" diff --git a/crates/sqlite/build.rs b/crates/sqlite/build.rs index 20b2953..713d6c9 100644 --- a/crates/sqlite/build.rs +++ b/crates/sqlite/build.rs @@ -1,17 +1,27 @@ fn main() { let mut cfg = cc::Build::new(); + let target = std::env::var("TARGET").unwrap(); + let is_watchos = target.contains("watchos") || target.contains("watchsimulator"); // Compile the SQLite source cfg.file("./sqlite/sqlite3.c"); - cfg.file("./sqlite/shell.c"); cfg.include("./sqlite"); // General SQLite options cfg.define("SQLITE_THREADSAFE", Some("0")); cfg.define("SQLITE_ENABLE_BYTECODE_VTAB", Some("1")); - // Compile with readline support (also requires -lreadline / cargo:rustc-link-lib=readline below) - cfg.define("HAVE_READLINE", Some("1")); + if is_watchos { + // For watchOS, don't build the shell and disable readline + cfg.define("HAVE_READLINE", Some("0")); + cfg.define("HAVE_EDITLINE", Some("0")); + cfg.define("SQLITE_OMIT_SYSTEM", Some("1")); + } else { + // For other platforms, build the shell with readline + cfg.file("./sqlite/shell.c"); + cfg.define("HAVE_READLINE", Some("1")); + println!("cargo:rustc-link-lib=readline"); + } // Silence warnings generated for SQLite cfg.flag("-Wno-implicit-fallthrough"); @@ -19,6 +29,4 @@ fn main() { cfg.flag("-Wno-null-pointer-subtraction"); cfg.compile("sqlite"); - - println!("cargo:rustc-link-lib=readline"); } diff --git a/powersync-sqlite-core.podspec b/powersync-sqlite-core.podspec index 44f4f95..1f033a2 100644 --- a/powersync-sqlite-core.podspec +++ b/powersync-sqlite-core.podspec @@ -13,7 +13,11 @@ PowerSync extension for SQLite. s.source = { :http => "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v#{s.version}/powersync-sqlite-core.xcframework.zip" } s.vendored_frameworks = 'powersync-sqlite-core.xcframework' - s.ios.deployment_target = '11.0' s.osx.deployment_target = '10.13' + s.watchos.deployment_target = '7.0' + + # Ensure no asset catalogs are included for watchOS + s.watchos.resource_bundles = {} + s.watchos.resources = [] end diff --git a/sqlite-rs-embedded b/sqlite-rs-embedded index 5d35c28..b0ced62 160000 --- a/sqlite-rs-embedded +++ b/sqlite-rs-embedded @@ -1 +1 @@ -Subproject commit 5d35c2883d9889f01dee010223d94570c70039b7 +Subproject commit b0ced62a9dfe4d9eecfd7f1a22136dccf3d75198 diff --git a/tool/build_xcframework.sh b/tool/build_xcframework.sh index 2a6334d..74211dc 100755 --- a/tool/build_xcframework.sh +++ b/tool/build_xcframework.sh @@ -3,12 +3,11 @@ set -e # Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh - BUILD_DIR=./build -DIST_PACKAGE_DIR=./dist function createXcframework() { - plist=$(cat << EOF + ios_plist=$( + cat < @@ -34,10 +33,60 @@ function createXcframework() { EOF -) + ) + + watchos_plist=$( + cat < + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + powersync-sqlite-core + CFBundleIdentifier + co.powersync.sqlitecore + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + MinimumOSVersion + 7.0 + CFBundleVersion + 0.3.12 + CFBundleShortVersionString + 0.3.12 + UIDeviceFamily + + 4 + + DTSDKName + watchos + DTPlatformName + watchos + DTPlatformVersion + 7.0 + DTXcode + 1500 + DTXcodeBuild + 15A240d + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 21R355 + BuildMachineOSBuild + 23D60 + + +EOF + ) + echo "===================== create ios device framework =====================" mkdir -p "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework" - echo "${plist}" > "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/Info.plist" + echo "${ios_plist}" >"${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/Info.plist" cp -f "./target/aarch64-apple-ios/release_apple/libpowersync.dylib" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" # Generate dSYM for iOS Device @@ -45,7 +94,7 @@ EOF echo "===================== create ios simulator framework =====================" mkdir -p "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" - echo "${plist}" > "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist" + echo "${ios_plist}" >"${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist" 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" 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" # Generate dSYM for iOS Simulator @@ -53,7 +102,7 @@ EOF echo "===================== create macos framework =====================" mkdir -p "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources" - echo "${plist}" > "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" + echo "${ios_plist}" >"${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" 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" 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" ln -sf A "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/Current" @@ -62,9 +111,31 @@ EOF # Generate dSYM for macOS 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" + echo "===================== create watchos device framework =====================" + mkdir -p "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources" + echo "${watchos_plist}" >"${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" + cp -f "./target/aarch64-apple-watchos/release_apple/libpowersync.dylib" "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" + 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" + ln -sf A "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/Current" + ln -sf Versions/Current/powersync-sqlite-core "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" + ln -sf Versions/Current/Resources "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Resources" + # Generate dSYM for watchOS device + dsymutil "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" -o "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework.dSYM" + + echo "===================== create watchos simulator framework =====================" + mkdir -p "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources" + echo "${watchos_plist}" >"${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" + 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" + 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" + ln -sf A "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/Current" + ln -sf Versions/Current/powersync-sqlite-core "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core" + ln -sf Versions/Current/Resources "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Resources" + # Generate dSYM for watchOS simulator + 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" + echo "===================== create xcframework =====================" rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" - # "-debug-symbols" requires the absolute path + # Create iOS/macOS XCFramework xcodebuild -create-xcframework \ -framework "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework" \ -debug-symbols "$(pwd -P)/${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework.dSYM" \ @@ -72,10 +143,19 @@ EOF -debug-symbols "$(pwd -P)/${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework.dSYM" \ -framework "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework" \ -debug-symbols "$(pwd -P)/${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \ - -output "${BUILD_DIR}/powersync-sqlite-core.xcframework" \ + -output "${BUILD_DIR}/powersync-sqlite-core.xcframework" + # Create watchOS XCFramework + xcodebuild -create-xcframework \ + -framework "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework" \ + -framework "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework" \ + -output "${BUILD_DIR}/powersync-sqlite-core-watchos.xcframework" + + # Copy the iOS/macOS XCFramework to the final location cp -Rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" "powersync-sqlite-core.xcframework" - zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework LICENSE README.md + + # Create a zip file with both XCFrameworks + zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework powersync-sqlite-core-watchos.xcframework LICENSE README.md rm -rf ${BUILD_DIR} } @@ -92,5 +172,16 @@ cargo build -p powersync_loadable --profile release_apple --target x86_64-apple- # macOS cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-darwin -Zbuild-std cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-darwin -Zbuild-std +# watchOS +export SDKROOT=$(xcrun --sdk watchos --show-sdk-path) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_LINKER=$(xcrun --sdk watchos --find clang) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_AR=$(xcrun --sdk watchos --find ar) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_RANLIB=$(xcrun --sdk watchos --find ranlib) +cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos +export SDKROOT=$(xcrun --sdk watchsimulator --show-sdk-path) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_LINKER=$(xcrun --sdk watchsimulator --find clang) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_AR=$(xcrun --sdk watchsimulator --find ar) +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_RANLIB=$(xcrun --sdk watchsimulator --find ranlib) +cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos-sim createXcframework From 0931ec7f1059e8cc3319b74e0756631b19da013c Mon Sep 17 00:00:00 2001 From: Teo Stocco Date: Sat, 10 May 2025 21:49:25 -0600 Subject: [PATCH 2/2] cleanup --- .cargo/config.toml | 2 +- .github/workflows/ios.yml | 2 +- .github/workflows/release.yml | 2 +- crates/shell/Cargo.toml | 17 +++-------------- crates/sqlite/Cargo.toml | 12 ------------ powersync-sqlite-core.podspec | 4 ---- sqlite-rs-embedded | 2 +- tool/build_xcframework.sh | 33 ++++++--------------------------- 8 files changed, 13 insertions(+), 61 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ddb98b3..4065216 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -96,7 +96,7 @@ rustflags = [ "-C", "link-arg=-mwatchsimulator-version-min=7.0", ] -[target.x86_64-apple-watchos] +[target.x86_64-apple-watchos-sim] rustflags = [ "-C", "link-arg=-mwatchos-version-min=7.0", ] diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 98a1c6e..b7dfad5 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -24,7 +24,7 @@ jobs: x86_64-apple-ios \ aarch64-apple-watchos \ aarch64-apple-watchos-sim \ - x86_64-apple-watchos + x86_64-apple-watchos-sim - name: setup-cocoapods uses: maxim-lobanov/setup-cocoapods@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17d9231..ff28632 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,7 +94,7 @@ jobs: x86_64-apple-ios \ aarch64-apple-watchos \ aarch64-apple-watchos-sim \ - x86_64-apple-watchos + x86_64-apple-watchos-sim - name: setup-cocoapods uses: maxim-lobanov/setup-cocoapods@v1 with: diff --git a/crates/shell/Cargo.toml b/crates/shell/Cargo.toml index 28527f8..eb8200f 100644 --- a/crates/shell/Cargo.toml +++ b/crates/shell/Cargo.toml @@ -8,23 +8,12 @@ license.workspace = true authors.workspace = true keywords.workspace = true -[lib] -name = "powersync_sqlite" -path = "src/main.rs" -crate-type = ["staticlib"] - -[[bin]] -name = "powersync_sqlite" -path = "src/main.rs" -required-features = ["shell"] - [dependencies] -powersync_core = { path="../core", default-features = false, features = ["static", "omit_load_extension"] } -sqlite_nostd = { workspace=true, features = ["static", "omit_load_extension"] } +powersync_core = { path="../core" } +sqlite_nostd = { workspace=true } [features] -default = [] -shell = [] +default = ["powersync_core/static", "powersync_core/omit_load_extension", "sqlite_nostd/static", "sqlite_nostd/omit_load_extension"] [build-dependencies] cc = "1.0.46" diff --git a/crates/sqlite/Cargo.toml b/crates/sqlite/Cargo.toml index 09e28ba..5e6b0d0 100644 --- a/crates/sqlite/Cargo.toml +++ b/crates/sqlite/Cargo.toml @@ -8,21 +8,9 @@ license.workspace = true authors.workspace = true keywords.workspace = true -[lib] -name = "sqlite3" -path = "src/main.rs" -crate-type = ["staticlib"] - -[[bin]] -name = "sqlite3" -path = "src/main.rs" -required-features = ["shell"] - [dependencies] [features] -default = [] -shell = [] [build-dependencies] cc = "1.0.46" diff --git a/powersync-sqlite-core.podspec b/powersync-sqlite-core.podspec index 1f033a2..d8c522e 100644 --- a/powersync-sqlite-core.podspec +++ b/powersync-sqlite-core.podspec @@ -16,8 +16,4 @@ PowerSync extension for SQLite. s.ios.deployment_target = '11.0' s.osx.deployment_target = '10.13' s.watchos.deployment_target = '7.0' - - # Ensure no asset catalogs are included for watchOS - s.watchos.resource_bundles = {} - s.watchos.resources = [] end diff --git a/sqlite-rs-embedded b/sqlite-rs-embedded index b0ced62..5d35c28 160000 --- a/sqlite-rs-embedded +++ b/sqlite-rs-embedded @@ -1 +1 @@ -Subproject commit b0ced62a9dfe4d9eecfd7f1a22136dccf3d75198 +Subproject commit 5d35c2883d9889f01dee010223d94570c70039b7 diff --git a/tool/build_xcframework.sh b/tool/build_xcframework.sh index 74211dc..e23d30f 100755 --- a/tool/build_xcframework.sh +++ b/tool/build_xcframework.sh @@ -114,28 +114,22 @@ EOF echo "===================== create watchos device framework =====================" mkdir -p "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources" echo "${watchos_plist}" >"${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" - cp -f "./target/aarch64-apple-watchos/release_apple/libpowersync.dylib" "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" - 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" + cp -f "./target/aarch64-apple-watchos/release_apple/libpowersync.a" "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" ln -sf A "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/Current" ln -sf Versions/Current/powersync-sqlite-core "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" ln -sf Versions/Current/Resources "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Resources" - # Generate dSYM for watchOS device - dsymutil "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core" -o "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework.dSYM" echo "===================== create watchos simulator framework =====================" mkdir -p "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources" echo "${watchos_plist}" >"${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/A/Resources/Info.plist" - 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" - 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" + 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" ln -sf A "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Versions/Current" ln -sf Versions/Current/powersync-sqlite-core "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core" ln -sf Versions/Current/Resources "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework/Resources" - # Generate dSYM for watchOS simulator - 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" echo "===================== create xcframework =====================" rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" - # Create iOS/macOS XCFramework + xcodebuild -create-xcframework \ -framework "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework" \ -debug-symbols "$(pwd -P)/${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework.dSYM" \ @@ -145,17 +139,9 @@ EOF -debug-symbols "$(pwd -P)/${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \ -output "${BUILD_DIR}/powersync-sqlite-core.xcframework" - # Create watchOS XCFramework - xcodebuild -create-xcframework \ - -framework "${BUILD_DIR}/watchos-arm64/powersync-sqlite-core.framework" \ - -framework "${BUILD_DIR}/watchos-arm64-simulator/powersync-sqlite-core.framework" \ - -output "${BUILD_DIR}/powersync-sqlite-core-watchos.xcframework" - - # Copy the iOS/macOS XCFramework to the final location - cp -Rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" "powersync-sqlite-core.xcframework" + # how to create a watchOS XCFramework with static libraries, possible? - # Create a zip file with both XCFrameworks - zip -r --symlinks powersync-sqlite-core.xcframework.zip powersync-sqlite-core.xcframework powersync-sqlite-core-watchos.xcframework LICENSE README.md + 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 rm -rf ${BUILD_DIR} } @@ -173,15 +159,8 @@ cargo build -p powersync_loadable --profile release_apple --target x86_64-apple- cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-darwin -Zbuild-std cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-darwin -Zbuild-std # watchOS -export SDKROOT=$(xcrun --sdk watchos --show-sdk-path) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_LINKER=$(xcrun --sdk watchos --find clang) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_AR=$(xcrun --sdk watchos --find ar) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_RANLIB=$(xcrun --sdk watchos --find ranlib) cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos -export SDKROOT=$(xcrun --sdk watchsimulator --show-sdk-path) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_LINKER=$(xcrun --sdk watchsimulator --find clang) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_AR=$(xcrun --sdk watchsimulator --find ar) -export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_RANLIB=$(xcrun --sdk watchsimulator --find ranlib) cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target aarch64-apple-watchos-sim +cargo build -p powersync_loadable --profile release_apple -Zbuild-std=std,panic_abort --target x86_64-apple-watchos-sim createXcframework