Skip to content

Commit

Permalink
Add debug symbols and dysm for ios and macos builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mugikhan committed Dec 18, 2024
1 parent 44dac47 commit 18e0e57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ strip = true
opt-level = "z"
lto = true

[profile.release_apple]
inherits = "release"
strip = false
debug = true

[profile.wasm]
inherits = "release"

Expand Down
34 changes: 22 additions & 12 deletions tool/build_xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,41 @@ 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"
cp -f "./target/aarch64-apple-ios/release/libpowersync.dylib" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
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
dsymutil "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core" -o "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework.dSYM"

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"
lipo ./target/aarch64-apple-ios-sim/release/libpowersync.dylib ./target/x86_64-apple-ios/release/libpowersync.dylib -create -output "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
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
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"

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"
lipo ./target/x86_64-apple-darwin/release/libpowersync.dylib ./target/aarch64-apple-darwin/release/libpowersync.dylib -create -output "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/A/powersync-sqlite-core"
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 -s A "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/Current"
ln -s Versions/Current/powersync-sqlite-core "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/powersync-sqlite-core"
ln -s Versions/Current/Resources "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Resources"
ln -sf A "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Versions/Current"
ln -sf Versions/Current/powersync-sqlite-core "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/powersync-sqlite-core"
ln -sf Versions/Current/Resources "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Resources"
# 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 xcframework ====================="
rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework"
# "-debug-symbols" requires the absolute path
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" \
-framework "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
-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" \
-output "${BUILD_DIR}/powersync-sqlite-core.xcframework"
-debug-symbols "$(pwd -P)/${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework.dSYM" \
-output "${BUILD_DIR}/powersync-sqlite-core.xcframework" \

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
Expand All @@ -75,12 +85,12 @@ EOF
rm -rf powersync-sqlite-core.xcframework

# iOS
cargo build -p powersync_loadable --release --target aarch64-apple-ios -Zbuild-std
cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios -Zbuild-std
# Simulator
cargo build -p powersync_loadable --release --target aarch64-apple-ios-sim -Zbuild-std
cargo build -p powersync_loadable --release --target x86_64-apple-ios -Zbuild-std
cargo build -p powersync_loadable --profile release_apple --target aarch64-apple-ios-sim -Zbuild-std
cargo build -p powersync_loadable --profile release_apple --target x86_64-apple-ios -Zbuild-std
# macOS
cargo build -p powersync_loadable --release --target aarch64-apple-darwin -Zbuild-std
cargo build -p powersync_loadable --release --target x86_64-apple-darwin -Zbuild-std
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

createXcframework

0 comments on commit 18e0e57

Please sign in to comment.