From c10961f06847fa315bc6c00170e26afb94a48d71 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 30 Jun 2022 17:29:35 +0300 Subject: [PATCH 1/5] chore: sdk-ffi apple - remove mac catalyst target support --- bindings/apple/build_xcframework.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/bindings/apple/build_xcframework.sh b/bindings/apple/build_xcframework.sh index c0d2919e9..0199fceef 100755 --- a/bindings/apple/build_xcframework.sh +++ b/bindings/apple/build_xcframework.sh @@ -27,10 +27,6 @@ cargo build -p matrix-sdk-ffi ${REL_FLAG} --target "x86_64-apple-darwin" cargo build -p matrix-sdk-ffi ${REL_FLAG} --target "aarch64-apple-ios-sim" cargo build -p matrix-sdk-ffi ${REL_FLAG} --target "x86_64-apple-ios" -# Mac Catalyst -cargo +nightly build -Z build-std -p matrix-sdk-ffi ${REL_FLAG} --target "aarch64-apple-ios-macabi" -cargo +nightly build -Z build-std -p matrix-sdk-ffi ${REL_FLAG} --target "x86_64-apple-ios-macabi" - # Lipo together the libraries for the same platform # MacOS @@ -45,12 +41,6 @@ lipo -create \ "${TARGET_DIR}/aarch64-apple-ios-sim/${REL_TYPE_DIR}/libmatrix_sdk_ffi.a" \ -output "${GENERATED_DIR}/libmatrix_sdk_ffi_iossimulator.a" -# Mac Catalyst -lipo -create \ - "${TARGET_DIR}/x86_64-apple-ios-macabi/${REL_TYPE_DIR}/libmatrix_sdk_ffi.a" \ - "${TARGET_DIR}/aarch64-apple-ios-macabi/${REL_TYPE_DIR}/libmatrix_sdk_ffi.a" \ - -output "${GENERATED_DIR}/libmatrix_sdk_ffi_maccatalyst.a" - # Generate uniffi files uniffi-bindgen generate "${SRC_ROOT}/bindings/matrix-sdk-ffi/src/api.udl" --language swift --out-dir ${GENERATED_DIR} @@ -75,8 +65,6 @@ xcodebuild -create-xcframework \ -headers ${HEADERS_DIR} \ -library "${GENERATED_DIR}/libmatrix_sdk_ffi_iossimulator.a" \ -headers ${HEADERS_DIR} \ - -library "${GENERATED_DIR}/libmatrix_sdk_ffi_maccatalyst.a" \ - -headers ${HEADERS_DIR} \ -library "${TARGET_DIR}/aarch64-apple-ios/${REL_TYPE_DIR}/libmatrix_sdk_ffi.a" \ -headers ${HEADERS_DIR} \ -output "${GENERATED_DIR}/MatrixSDKFFI.xcframework" @@ -85,5 +73,4 @@ xcodebuild -create-xcframework \ if [ -f "${GENERATED_DIR}/libmatrix_sdk_ffi_macos.a" ]; then rm -rf "${GENERATED_DIR}/libmatrix_sdk_ffi_macos.a"; fi if [ -f "${GENERATED_DIR}/libmatrix_sdk_ffi_iossimulator.a" ]; then rm -rf "${GENERATED_DIR}/libmatrix_sdk_ffi_iossimulator.a"; fi -if [ -f "${GENERATED_DIR}/libmatrix_sdk_ffi_maccatalyst.a" ]; then rm -rf "${GENERATED_DIR}/libmatrix_sdk_ffi_maccatalyst.a"; fi if [ -d ${HEADERS_DIR} ]; then rm -rf ${HEADERS_DIR}; fi From a73b104c59d31a6915766cf7dbfe0d1f9e43e0f5 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 30 Jun 2022 17:30:37 +0300 Subject: [PATCH 2/5] chore: sdk-ffi apple - rename `modulemap` to `module.modulemap` as per xcframework specifications --- bindings/apple/build_xcframework.sh | 5 ++++- bindings/apple/debug_build_xcframework.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bindings/apple/build_xcframework.sh b/bindings/apple/build_xcframework.sh index 0199fceef..d98438747 100755 --- a/bindings/apple/build_xcframework.sh +++ b/bindings/apple/build_xcframework.sh @@ -49,7 +49,10 @@ uniffi-bindgen generate "${SRC_ROOT}/bindings/matrix-sdk-ffi/src/api.udl" --lang HEADERS_DIR=${GENERATED_DIR}/headers mkdir -p ${HEADERS_DIR} -mv ${GENERATED_DIR}/*.h ${GENERATED_DIR}/*.modulemap ${HEADERS_DIR} +mv ${GENERATED_DIR}/*.h ${HEADERS_DIR} + +# Rename and move modulemap to the right place +mv ${GENERATED_DIR}/*.modulemap ${HEADERS_DIR}/module.modulemap SWIFT_DIR="${GENERATED_DIR}/swift" mkdir -p ${SWIFT_DIR} diff --git a/bindings/apple/debug_build_xcframework.sh b/bindings/apple/debug_build_xcframework.sh index 975e62cf7..9639b74a0 100755 --- a/bindings/apple/debug_build_xcframework.sh +++ b/bindings/apple/debug_build_xcframework.sh @@ -39,7 +39,10 @@ uniffi-bindgen generate "${SRC_ROOT}/bindings/matrix-sdk-ffi/src/api.udl" --lang HEADERS_DIR=${GENERATED_DIR}/headers mkdir -p ${HEADERS_DIR} -mv ${GENERATED_DIR}/*.h ${GENERATED_DIR}/*.modulemap ${HEADERS_DIR} +mv ${GENERATED_DIR}/*.h ${HEADERS_DIR} + +# Rename and move modulemap to the right place +mv ${GENERATED_DIR}/*.modulemap ${HEADERS_DIR}/module.modulemap SWIFT_DIR="${GENERATED_DIR}/swift" mkdir -p ${SWIFT_DIR} From c61dbb657ebeca2775ea383a90ba18117a5e67cd Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 30 Jun 2022 17:31:58 +0300 Subject: [PATCH 3/5] chore: sdk-ffi apple - drop sample project deployment target to iOS 15 and macOS 12, disable catalyst. --- bindings/apple/MatrixRustSDK.xcodeproj/project.pbxproj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bindings/apple/MatrixRustSDK.xcodeproj/project.pbxproj b/bindings/apple/MatrixRustSDK.xcodeproj/project.pbxproj index 38cc51514..4021f5c5d 100644 --- a/bindings/apple/MatrixRustSDK.xcodeproj/project.pbxproj +++ b/bindings/apple/MatrixRustSDK.xcodeproj/project.pbxproj @@ -307,7 +307,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.2; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -362,7 +363,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.2; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -397,7 +399,7 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = org.matrix.MatrixRustSDK; PRODUCT_NAME = "$(TARGET_NAME)"; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OBJC_BRIDGING_HEADER = "MatrixRustSDK/MatrixRustSDK-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -431,7 +433,7 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = org.matrix.MatrixRustSDK; PRODUCT_NAME = "$(TARGET_NAME)"; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OBJC_BRIDGING_HEADER = "MatrixRustSDK/MatrixRustSDK-Bridging-Header.h"; SWIFT_VERSION = 5.0; From 399bbc25e990a565bfc1a67dbbc4e195dd6a5e88 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 30 Jun 2022 17:32:27 +0300 Subject: [PATCH 4/5] chore: sdk-ffi apple - run the CI build script from the Xcode project and only for the active architecture --- .github/workflows/bindings_ci.yml | 3 -- .../xcschemes/MatrixRustSDK.xcscheme | 30 ++++++++------ bindings/apple/debug_build_xcframework.sh | 39 +++++++++++++------ 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/.github/workflows/bindings_ci.yml b/.github/workflows/bindings_ci.yml index 30fcefc11..1768109a7 100644 --- a/.github/workflows/bindings_ci.yml +++ b/.github/workflows/bindings_ci.yml @@ -161,9 +161,6 @@ jobs: # keep in sync with uniffi dependency in Cargo.toml's args: uniffi_bindgen --version ^0.18 - - name: Generate .xcframework - run: sh bindings/apple/debug_build_xcframework.sh ci - - name: Run XCTests run: | xcodebuild test \ diff --git a/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme b/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme index 6644a0efe..9d3179964 100644 --- a/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme +++ b/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme @@ -1,10 +1,28 @@ + version = "1.7"> + + + + + + + + + + - - - - Date: Fri, 1 Jul 2022 07:39:01 +0300 Subject: [PATCH 5/5] chore: sdk-ffi apple - try building the framework on x86_64 outside of Xcode --- .github/workflows/bindings_ci.yml | 3 +++ .../xcshareddata/xcschemes/MatrixRustSDK.xcscheme | 2 +- bindings/apple/debug_build_xcframework.sh | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bindings_ci.yml b/.github/workflows/bindings_ci.yml index 1768109a7..0798ef17c 100644 --- a/.github/workflows/bindings_ci.yml +++ b/.github/workflows/bindings_ci.yml @@ -161,6 +161,9 @@ jobs: # keep in sync with uniffi dependency in Cargo.toml's args: uniffi_bindgen --version ^0.18 + - name: Generate .xcframework + run: sh bindings/apple/debug_build_xcframework.sh x86_64 ci + - name: Run XCTests run: | xcodebuild test \ diff --git a/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme b/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme index 9d3179964..fe527d24f 100644 --- a/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme +++ b/bindings/apple/MatrixRustSDK.xcodeproj/xcshareddata/xcschemes/MatrixRustSDK.xcscheme @@ -10,7 +10,7 @@ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> + scriptText = "#PATH=~/.cargo/bin:${PATH} echo $ARCHS #sh $PROJECT_DIR/debug_build_xcframework.sh "$ARCHS" CI ">