-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework Swift Package script Signed-off-by: Yuki Kishimoto <[email protected]>
- Loading branch information
Showing
10 changed files
with
70 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
# Inspired by https://github.com/bitcoindevkit/bdk-ffi/blob/014504ee8b6c12234592b68628ab0be888099d45/bdk-swift/build-xcframework.sh | ||
|
||
set -exuo pipefail | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
TARGET_DIR="${SCRIPT_DIR}/../../../target" | ||
TEMP_FFI_DIR="${SCRIPT_DIR}/../ffi/swift" | ||
CDY_LIB="libnostr_sdk_ffi.dylib" | ||
STATIC_LIB="libnostr_sdk_ffi.a" | ||
|
||
# Install and targets | ||
rustup target add aarch64-apple-ios # iOS arm64 | ||
rustup target add x86_64-apple-ios # iOS x86_64 | ||
rustup target add aarch64-apple-ios-sim # simulator mac M1 | ||
rustup target add aarch64-apple-darwin # mac M1 | ||
rustup target add x86_64-apple-darwin # mac x86_64 | ||
|
||
# Build for apple targets | ||
cargo build -p nostr-sdk-ffi --release --target x86_64-apple-darwin | ||
cargo build -p nostr-sdk-ffi --release --target aarch64-apple-darwin | ||
cargo build -p nostr-sdk-ffi --release --target x86_64-apple-ios | ||
cargo build -p nostr-sdk-ffi --release --target aarch64-apple-ios | ||
cargo build -p nostr-sdk-ffi --release --target aarch64-apple-ios-sim | ||
|
||
# Make Sources dir | ||
mkdir -p Sources/NostrSDK | ||
|
||
# build bdk-ffi Swift bindings and put in bdk-swift Sources | ||
cargo run -p uniffi-bindgen generate --library "${TARGET_DIR}/aarch64-apple-ios/release/${CDY_LIB}" --no-format --language swift --out-dir Sources/NostrSDK | ||
|
||
# Make universal dirs | ||
mkdir -p "${TARGET_DIR}/darwin-universal/release" # macOS | ||
mkdir -p "${TARGET_DIR}/ios-universal/release" # iOS | ||
mkdir -p "${TARGET_DIR}/ios-universal-sim/release" # iOS Simulator | ||
|
||
# Combine static libs for aarch64 and x86_64 targets via lipo | ||
lipo -create -output "${TARGET_DIR}/darwin-universal/release/${STATIC_LIB}" \ | ||
"${TARGET_DIR}/aarch64-apple-darwin/release/${STATIC_LIB}" \ | ||
"${TARGET_DIR}/x86_64-apple-darwin/release/${STATIC_LIB}" # macOS | ||
lipo -create -output "${TARGET_DIR}/ios-universal-sim/release/${STATIC_LIB}" \ | ||
"${TARGET_DIR}/aarch64-apple-ios-sim/release/${STATIC_LIB}" \ | ||
"${TARGET_DIR}/x86_64-apple-ios/release/${STATIC_LIB}" # iOS Simulator | ||
|
||
# Move static lib header files to temporary directory | ||
mkdir -p "${TEMP_FFI_DIR}" | ||
mv "Sources/NostrSDK/nostr_sdkFFI.h" "${TEMP_FFI_DIR}/nostr_sdkFFI.h" | ||
mv "Sources/NostrSDK/nostr_sdkFFI.modulemap" "${TEMP_FFI_DIR}/module.modulemap" | ||
|
||
# Remove old xcframework dir | ||
rm -rf "nostr_sdkFFI.xcframework" | ||
|
||
# Create new xcframework directory from static libs and headers | ||
xcodebuild -create-xcframework \ | ||
-library "${TARGET_DIR}/darwin-universal/release/${STATIC_LIB}" \ | ||
-headers "${TEMP_FFI_DIR}" \ | ||
-library "${TARGET_DIR}/aarch64-apple-ios/release/${STATIC_LIB}" \ | ||
-headers "${TEMP_FFI_DIR}" \ | ||
-library "${TARGET_DIR}/ios-universal-sim/release/${STATIC_LIB}" \ | ||
-headers "${TEMP_FFI_DIR}" \ | ||
-output "nostr_sdkFFI.xcframework" |
53 changes: 0 additions & 53 deletions
53
bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
.../swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...amework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...FI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...FFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...str_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.