Update the build scripts with destination-based instead of sdk-based

Which fix the issue on M1 Mac for x86_64 cross-build
This commit is contained in:
DreamPiggy 2023-09-11 16:33:50 +08:00
parent b231b2c55e
commit 99770368b5
2 changed files with 34 additions and 21 deletions

View File

@ -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
if [[ $CURRENT_PLATFORM == "macCatalyst" ]]; then
DESTINATION="generic/platform=macOS,variant=Mac Catalyst"
fi
else
xcodebuild archive -project "SDWebImage.xcodeproj" -sdk "${CURRENT_PLATFORM}" -scheme "SDWebImage" -configuration "Release" -archivePath "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive" SKIP_INSTALL=NO
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

View File

@ -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=""