Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 17, 2024
1 parent fef27cd commit cf95398
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 41 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
- name: Install just
run: cargo install just

- name: Install deps
run: brew install xz

- name: Build Swift Package
working-directory: bindings/nostr-sdk-ffi
run: just swift
Expand Down
8 changes: 3 additions & 5 deletions bindings/nostr-sdk-ffi/swift/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.swiftpm/
.build/
*.xcodeproj
*.podspec
Sources/NostrSDK/NostrSDK.swift
**/nostr_sdkFFI.h
**/nostr_sdkFFI
**/nostr_sdkFFI.modulemap
Sources/
**/Headers/*.h
**/nostr_sdkFFI.a
3 changes: 2 additions & 1 deletion bindings/nostr-sdk-ffi/swift/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ let package = Package(
name: "nostr-sdk-swift",
platforms: [
.macOS(.v12),
.iOS(.v15),
.iOS(.v14),
],
products: [
.library(name: "NostrSDK", targets: ["nostr_sdkFFI", "NostrSDK"]),
],
dependencies: [],
targets: [
.binaryTarget(name: "nostr_sdkFFI", path: "./nostr_sdkFFI.xcframework"),
.target(name: "NostrSDK", dependencies: ["nostr_sdkFFI"]),
Expand Down
22 changes: 14 additions & 8 deletions bindings/nostr-sdk-ffi/swift/build-xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

set -exuo pipefail

export MACOSX_DEPLOYMENT_TARGET=12.0

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET_DIR="${SCRIPT_DIR}/../../../target"
SOURCES_DIR="${SCRIPT_DIR}/Sources"
Expand Down Expand Up @@ -43,21 +45,25 @@ mkdir -p "${SOURCES_DIR}/NostrSDK"
# Generate Swift bindings
cargo run -p uniffi-bindgen generate --library "${TARGET_DIR}/aarch64-apple-ios/release/${STATIC_LIB}" --no-format --language swift --out-dir "${SOURCES_DIR}/NostrSDK"

# Display the contents of the Sources dir
echo "Contents of ${SOURCES_DIR}/NostrSDK:"
ls -la "${SOURCES_DIR}/NostrSDK"

# Rename Swift bindings
mv "${SOURCES_DIR}/NostrSDK/nostr_sdk.swift" "${SOURCES_DIR}/NostrSDK/NostrSDK.swift"

# Remove modulemap
rm "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.modulemap"
rm -f "${SOURCES_DIR}/NostrSDK/*.modulemap"

# Copy headers
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/ios-arm64/${LIB_NAME}.framework/Headers"
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/ios-arm64_x86_64-simulator/${LIB_NAME}.framework/Headers"
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/macos-arm64_x86_64/${LIB_NAME}.framework/Headers"
rm "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h"
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/ios-arm64/Headers"
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/ios-arm64_x86_64-simulator/Headers"
cp "${SOURCES_DIR}/NostrSDK/${LIB_NAME}.h" "${XCFRAMEWORK_DIR}/macos-arm64_x86_64/Headers"
rm -f "${SOURCES_DIR}/NostrSDK/*.h"

# Copy static libraries
cp "${TARGET_DIR}/aarch64-apple-ios/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/ios-arm64/${LIB_NAME}.framework/${LIB_NAME}"
cp "${TARGET_DIR}/ios-universal-sim/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/ios-arm64_x86_64-simulator/${LIB_NAME}.framework/${LIB_NAME}"
cp "${TARGET_DIR}/darwin-universal/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/macos-arm64_x86_64/${LIB_NAME}.framework/${LIB_NAME}"
cp "${TARGET_DIR}/aarch64-apple-ios/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/ios-arm64/${LIB_NAME}.a"
cp "${TARGET_DIR}/ios-universal-sim/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/ios-arm64_x86_64-simulator/${LIB_NAME}.a"
cp "${TARGET_DIR}/darwin-universal/release/${STATIC_LIB}" "${XCFRAMEWORK_DIR}/macos-arm64_x86_64/${LIB_NAME}.a"

echo "Done!"
12 changes: 9 additions & 3 deletions bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>nostr_sdkFFI.framework</string>
<string>nostr_sdkFFI.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -18,10 +20,12 @@
<string>macos</string>
</dict>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>nostr_sdkFFI.framework</string>
<string>nostr_sdkFFI.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -33,10 +37,12 @@
<string>simulator</string>
</dict>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>nostr_sdkFFI.framework</string>
<string>nostr_sdkFFI.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module nostr_sdkFFI {
header "nostr_sdkFFI.h"
export *
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module nostr_sdkFFI {
header "nostr_sdkFFI.h"
export *
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module nostr_sdkFFI {
header "nostr_sdkFFI.h"
export *
}

This file was deleted.

This file was deleted.

0 comments on commit cf95398

Please sign in to comment.