diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index 3fecf0997..460f1da5a 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -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 diff --git a/bindings/nostr-sdk-ffi/swift/.gitignore b/bindings/nostr-sdk-ffi/swift/.gitignore index 3c5eabbb7..9db48504d 100644 --- a/bindings/nostr-sdk-ffi/swift/.gitignore +++ b/bindings/nostr-sdk-ffi/swift/.gitignore @@ -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 diff --git a/bindings/nostr-sdk-ffi/swift/Package.swift b/bindings/nostr-sdk-ffi/swift/Package.swift index 66d636806..6402f78c2 100644 --- a/bindings/nostr-sdk-ffi/swift/Package.swift +++ b/bindings/nostr-sdk-ffi/swift/Package.swift @@ -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"]), diff --git a/bindings/nostr-sdk-ffi/swift/build-xcframework.sh b/bindings/nostr-sdk-ffi/swift/build-xcframework.sh index 72fcaefef..c0948cddb 100644 --- a/bindings/nostr-sdk-ffi/swift/build-xcframework.sh +++ b/bindings/nostr-sdk-ffi/swift/build-xcframework.sh @@ -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" @@ -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!" diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist index 0d20856d4..1b1b174ec 100644 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist +++ b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/Info.plist @@ -5,10 +5,12 @@ AvailableLibraries + HeadersPath + Headers LibraryIdentifier macos-arm64_x86_64 LibraryPath - nostr_sdkFFI.framework + nostr_sdkFFI.a SupportedArchitectures arm64 @@ -18,10 +20,12 @@ macos + HeadersPath + Headers LibraryIdentifier ios-arm64_x86_64-simulator LibraryPath - nostr_sdkFFI.framework + nostr_sdkFFI.a SupportedArchitectures arm64 @@ -33,10 +37,12 @@ simulator + HeadersPath + Headers LibraryIdentifier ios-arm64 LibraryPath - nostr_sdkFFI.framework + nostr_sdkFFI.a SupportedArchitectures arm64 diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/Headers/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/Headers/module.modulemap new file mode 100644 index 000000000..8b9cbe6bb --- /dev/null +++ b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/Headers/module.modulemap @@ -0,0 +1,4 @@ +module nostr_sdkFFI { + header "nostr_sdkFFI.h" + export * +} diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h deleted file mode 100644 index dfe1f5549..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h +++ /dev/null @@ -1 +0,0 @@ -#import "nostr_sdkFFI.h" diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Modules/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Modules/module.modulemap deleted file mode 100644 index d6eeb611a..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64/nostr_sdkFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module nostr_sdkFFI { - umbrella header "nostr_sdkFFI-umbrella.h" - - export * - module * { export * } -} diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap new file mode 100644 index 000000000..8b9cbe6bb --- /dev/null +++ b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap @@ -0,0 +1,4 @@ +module nostr_sdkFFI { + header "nostr_sdkFFI.h" + export * +} diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h deleted file mode 100644 index dfe1f5549..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h +++ /dev/null @@ -1 +0,0 @@ -#import "nostr_sdkFFI.h" diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Modules/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Modules/module.modulemap deleted file mode 100644 index d6eeb611a..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/ios-arm64_x86_64-simulator/nostr_sdkFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module nostr_sdkFFI { - umbrella header "nostr_sdkFFI-umbrella.h" - - export * - module * { export * } -} diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap new file mode 100644 index 000000000..8b9cbe6bb --- /dev/null +++ b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap @@ -0,0 +1,4 @@ +module nostr_sdkFFI { + header "nostr_sdkFFI.h" + export * +} diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h deleted file mode 100644 index dfe1f5549..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Headers/nostr_sdkFFI-umbrella.h +++ /dev/null @@ -1 +0,0 @@ -#import "nostr_sdkFFI.h" diff --git a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Modules/module.modulemap b/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Modules/module.modulemap deleted file mode 100644 index d6eeb611a..000000000 --- a/bindings/nostr-sdk-ffi/swift/nostr_sdkFFI.xcframework/macos-arm64_x86_64/nostr_sdkFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module nostr_sdkFFI { - umbrella header "nostr_sdkFFI-umbrella.h" - - export * - module * { export * } -}