2023-09-11 15:14:10 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-11 16:33:50 +08:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
2023-09-11 15:14:10 +08:00
|
|
|
XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')
|
|
|
|
XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')
|
2024-05-07 16:08:42 +08:00
|
|
|
XCODE_VERSION_MINOR=$(echo $XCODE_VERSION | awk -F '.' '{print $2}')
|
|
|
|
XCODE_VERSION_PATCH=$(echo $XCODE_VERSION | awk -F '.' '{print $3}')
|
2023-09-11 15:14:10 +08:00
|
|
|
if [ -z "$SRCROOT" ]
|
|
|
|
then
|
|
|
|
SRCROOT=$(pwd)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $XCODE_VERSION_MAJOR -lt 11 ]
|
|
|
|
then
|
|
|
|
echo "Xcode 10 does not support xcframework. You can still use the individual framework for each platform."
|
|
|
|
open -a Finder "${SRCROOT}/build/"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-09-11 16:33:50 +08:00
|
|
|
mkdir -p "${SRCROOT}/build"
|
|
|
|
PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator")
|
|
|
|
|
|
|
|
if [ $XCODE_VERSION_MAJOR -ge 11 ]
|
|
|
|
then
|
|
|
|
PLATFORMS+=("macCatalyst")
|
|
|
|
fi
|
2023-09-11 15:14:10 +08:00
|
|
|
|
2024-05-07 16:08:42 +08:00
|
|
|
if [[ ($XCODE_VERSION_MAJOR -gt 15) || ($XCODE_VERSION_MAJOR -eq 15 && $XCODE_VERSION_MINOR -ge 2) ]]
|
2023-09-11 15:14:10 +08:00
|
|
|
then
|
2023-09-11 16:33:50 +08:00
|
|
|
PLATFORMS+=("visionOS")
|
|
|
|
PLATFORMS+=("visionOSSimulator")
|
2023-09-11 15:14:10 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
COMMAND_ARGS=""
|
|
|
|
for CURRENT_PLATFORM in "${PLATFORMS[@]}"
|
|
|
|
do
|
|
|
|
COMMAND_ARGS="${COMMAND_ARGS} -framework ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Combine XCFramework
|
2024-05-07 16:07:18 +08:00
|
|
|
echo "Create XCFramework"
|
2023-09-11 15:14:10 +08:00
|
|
|
xcodebuild -create-xcframework $COMMAND_ARGS -output "${SRCROOT}/build/SDWebImage.xcframework"
|