-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathcreate-xcframework.sh
More file actions
executable file
·56 lines (48 loc) · 1.61 KB
/
create-xcframework.sh
File metadata and controls
executable file
·56 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
set -o pipefail
if [[ -z "$XCODE_VERSION_MAJOR" ]]
then
XCODE_VERSION_MAJOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MAJOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
fi
if [[ -z "$XCODE_VERSION_MINOR" ]]
then
XCODE_VERSION_MINOR=$(xcodebuild -showBuildSettings | awk -F= '/XCODE_VERSION_MINOR/{x=$NF; gsub(/[^0-9]/,"",x); print int(x)}')
fi
XCODE_MAJOR=$(($XCODE_VERSION_MAJOR / 100))
XCODE_MINOR=$(($XCODE_VERSION_MINOR / 10))
XCODE_MINOR=$(($XCODE_MINOR % 10))
echo "XCODE_MAJOR=$XCODE_MAJOR"
echo "XCODE_MINOR=$XCODE_MINOR"
if [ -z "$SRCROOT" ]
then
SRCROOT=$(pwd)
fi
if [ $XCODE_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
mkdir -p "${SRCROOT}/build"
PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator")
if [ $XCODE_MAJOR -ge 11 ]
then
PLATFORMS+=("macCatalyst")
fi
if [[ ($XCODE_MAJOR -gt 15) || ($XCODE_MAJOR -eq 15 && $XCODE_MINOR -ge 2) ]]
then
PLATFORMS+=("visionOS")
PLATFORMS+=("visionOSSimulator")
fi
COMMAND_ARGS=""
for CURRENT_PLATFORM in "${PLATFORMS[@]}"
do
COMMAND_ARGS="${COMMAND_ARGS} -framework ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework"
if [[ $MACH_O_TYPE != "staticlib" ]]; then
COMMAND_ARGS="${COMMAND_ARGS} -debug-symbols ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework.dSYM"
fi
done
# Combine XCFramework
echo "Create XCFramework"
xcodebuild -create-xcframework $COMMAND_ARGS -output "${SRCROOT}/build/SDWebImage.xcframework"