From 33be11f810a0a40eb0e55be788966541798a265c Mon Sep 17 00:00:00 2001 From: Marcel Schnelle Date: Mon, 26 Aug 2024 08:36:49 +0900 Subject: [PATCH] Only build the XCFramework for the current configuration from Xcode This prevents release frameworks from being built during debug, and vice versa. --- build_xcframework_with_xcode_environment_variable.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build_xcframework_with_xcode_environment_variable.sh b/build_xcframework_with_xcode_environment_variable.sh index ad1a78475..60154c3df 100755 --- a/build_xcframework_with_xcode_environment_variable.sh +++ b/build_xcframework_with_xcode_environment_variable.sh @@ -6,8 +6,9 @@ if [ -z "$SDK_NAME" ] || [ -z "$ARCHS" ]; then exit 1 fi -# Initialize the target architecture +# Initialize the target architecture and configuration (debug vs. release) target_arch="" +target_configuration="" # Determine the target architecture based on SDK_NAME and ARCHS if [[ "$SDK_NAME" == *"simulator"* ]]; then @@ -20,6 +21,13 @@ elif [[ "$SDK_NAME" == *"iphoneos"* ]] && [[ "$ARCHS" == *"arm64"* ]]; then target_arch="arm64" fi +# Assign the correct framework to build based on Xcode's configuration (or build all on unknown values) +if [[ "$CONFIGURATION" == *"Debug"* ]]; then + target_configuration="Debug" +elif [[ "$CONFIGURATION" == *"Release"* ]]; then + target_configuration="Release" +fi + # Check if a valid target architecture was determined if [ -z "$target_arch" ]; then echo "Error: Unable to determine target architecture from SDK_NAME=$SDK_NAME and ARCHS=$ARCHS" @@ -28,6 +36,6 @@ fi # Execute Gradle command with the determined architecture echo "Building for architecture: $target_arch" -./gradlew assembleSharedXCFramework --no-configuration-cache -Papp.ios.shared.arch=$target_arch +./gradlew assembleShared${target_configuration}XCFramework --no-configuration-cache -Papp.ios.shared.arch=$target_arch echo "Build completed for $target_arch"