From 99770368b5b301533f40675a5ff4d19a01db5f5b Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 11 Sep 2023 16:33:50 +0800 Subject: [PATCH] Update the build scripts with destination-based instead of sdk-based Which fix the issue on M1 Mac for x86_64 cross-build --- Scripts/build-frameworks.sh | 40 +++++++++++++++++++---------------- Scripts/create-xcframework.sh | 15 ++++++++++--- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/Scripts/build-frameworks.sh b/Scripts/build-frameworks.sh index 60744f49..82a7dd32 100755 --- a/Scripts/build-frameworks.sh +++ b/Scripts/build-frameworks.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -e +set -o pipefail + XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}') XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}') if [ -z "$SRCROOT" ] @@ -8,32 +11,33 @@ then fi mkdir -p "${SRCROOT}/build" -declare -a PLATFORMS=("iphoneos" "iphonesimulator" "macosx" "appletvos" "appletvsimulator" "watchos" "watchsimulator" "maccatalyst") +PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator") + +if [ $XCODE_VERSION_MAJOR -ge 11 ] +then + PLATFORMS+=("macCatalyst") +fi if [ $XCODE_VERSION_MAJOR -ge 15 ] then - PLATFORMS+=("xros") - PLATFORMS+=("xrsimulator") + PLATFORMS+=("visionOS") + PLATFORMS+=("visionOSSimulator") fi for CURRENT_PLATFORM in "${PLATFORMS[@]}" do - if [[ $CURRENT_PLATFORM == *"simulator" ]]; then - xcodebuild build -project "SDWebImage.xcodeproj" -sdk "${CURRENT_PLATFORM}" -scheme "SDWebImage" -configuration "Debug" -derivedDataPath "${SRCROOT}/build/DerivedData" CONFIGURATION_BUILD_DIR="${SRCROOT}/build/${CURRENT_PLATFORM}/" - else + DESTINATION="generic/platform=${CURRENT_PLATFORM}" + # macOS Catalyst - if [[ $CURRENT_PLATFORM == "maccatalyst" ]]; then - if [[ $XCODE_VERSION_MAJOR -lt 11 ]]; then - # Xcode 10 does not support macOS Catalyst - continue - else - xcodebuild archive -project "SDWebImage.xcodeproj" -scheme "SDWebImage" -configuration "Release" -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -archivePath "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive" -derivedDataPath "${SRCROOT}/build/DerivedData" SKIP_INSTALL=NO - fi - else - xcodebuild archive -project "SDWebImage.xcodeproj" -sdk "${CURRENT_PLATFORM}" -scheme "SDWebImage" -configuration "Release" -archivePath "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive" SKIP_INSTALL=NO + if [[ $CURRENT_PLATFORM == "macCatalyst" ]]; then + DESTINATION="generic/platform=macOS,variant=Mac Catalyst" fi - mv "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/Products/Library/Frameworks/SDWebImage.framework" "${SRCROOT}/build/${CURRENT_PLATFORM}/" - mv "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/dSYMs/SDWebImage.framework.dSYM" "${SRCROOT}/build/${CURRENT_PLATFORM}/" - rm -rf "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/" + + # Simulator + if [[ $CURRENT_PLATFORM == *Simulator ]]; then + CURRENT_PLATFORM_OS=${CURRENT_PLATFORM%Simulator} + DESTINATION="generic/platform=${CURRENT_PLATFORM_OS} Simulator" fi + + xcodebuild build -project "SDWebImage.xcodeproj" -destination "${DESTINATION}" -scheme "SDWebImage" -configuration "Release" -derivedDataPath "${SRCROOT}/build/DerivedData" CONFIGURATION_BUILD_DIR="${SRCROOT}/build/${CURRENT_PLATFORM}/" done diff --git a/Scripts/create-xcframework.sh b/Scripts/create-xcframework.sh index c6905ea0..660b6d64 100755 --- a/Scripts/create-xcframework.sh +++ b/Scripts/create-xcframework.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -e +set -o pipefail + XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}') XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}') if [ -z "$SRCROOT" ] @@ -14,12 +17,18 @@ then exit 0 fi -declare -a PLATFORMS=("iphoneos" "iphonesimulator" "macosx" "appletvos" "appletvsimulator" "watchos" "watchsimulator") +mkdir -p "${SRCROOT}/build" +PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator") + +if [ $XCODE_VERSION_MAJOR -ge 11 ] +then + PLATFORMS+=("macCatalyst") +fi if [ $XCODE_VERSION_MAJOR -ge 15 ] then - PLATFORMS+=("xros") - PLATFORMS+=("xrsimulator") + PLATFORMS+=("visionOS") + PLATFORMS+=("visionOSSimulator") fi COMMAND_ARGS=""