-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_xcframeworks-staticFrameworks.sh
executable file
·50 lines (37 loc) · 2.01 KB
/
create_xcframeworks-staticFrameworks.sh
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
#!/bin/bash
set -x
rm -rf ./*-Sliced
rm -rf *.xcframework
find . -name '*.framework' | while read -r FRAMEWORK
do
FRAMEWORK_NAME="${FRAMEWORK%.*}"
FRAMEWORK_NAME="${FRAMEWORK_NAME//_iOS}"
FRAMEWORK_NAME="${FRAMEWORK_NAME//lib}"
FRAMEWORK_NAME="$(basename -- "${FRAMEWORK_NAME}")"
echo "Framework is ${FRAMEWORK_NAME}"
FRAMEWORK_THIN_FOLDER="${FRAMEWORK_NAME}-Sliced"
mkdir ${FRAMEWORK_THIN_FOLDER}
ARCHS="$(lipo -info "${FRAMEWORK}/${FRAMEWORK_NAME}" | rev | cut -d ':' -f1 | rev)"
SIM_ARCHS="i386 x86_64" #Only used to substract something
DEVICE_ARCHS="$(echo ${ARCHS[@]} ${SIM_ARCHS[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ' | xargs)"
SIM_ARCHS="$(echo ${ARCHS[@]} ${DEVICE_ARCHS[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ' | xargs)"
mkdir "${FRAMEWORK_THIN_FOLDER}/ios-${DEVICE_ARCHS// /_}"
cp -r ${FRAMEWORK} "${FRAMEWORK_THIN_FOLDER}/ios-${DEVICE_ARCHS// /_}"
mkdir "${FRAMEWORK_THIN_FOLDER}/ios-${SIM_ARCHS// /_}"
cp -r ${FRAMEWORK} "${FRAMEWORK_THIN_FOLDER}/ios-${SIM_ARCHS// /_}"
for ARCH in ${DEVICE_ARCHS}
do
echo "Removing ${ARCH} from ios-${SIM_ARCHS// /_} slice"
lipo -remove "${ARCH}" "${FRAMEWORK_THIN_FOLDER}/ios-${SIM_ARCHS// /_}/${FRAMEWORK}/${FRAMEWORK_NAME}" -o "${FRAMEWORK_THIN_FOLDER}/ios-${SIM_ARCHS// /_}/${FRAMEWORK}/${FRAMEWORK_NAME}"
done
for ARCH in ${SIM_ARCHS}
do
echo "Removing ${ARCH} from ios-${DEVICE_ARCHS// /_} slice"
lipo -remove "${ARCH}" "${FRAMEWORK_THIN_FOLDER}/ios-${DEVICE_ARCHS// /_}/${FRAMEWORK}/${FRAMEWORK_NAME}" -o "${FRAMEWORK_THIN_FOLDER}/ios-${DEVICE_ARCHS// /_}/${FRAMEWORK}/${FRAMEWORK_NAME}"
done
echo "Building XCFramework for ${FRAMEWORK} with Headers in /include"
xcodebuild -create-xcframework -framework "${FRAMEWORK_THIN_FOLDER}/ios-${SIM_ARCHS// /_}/${FRAMEWORK}" -framework "${FRAMEWORK_THIN_FOLDER}/ios-${DEVICE_ARCHS// /_}/${FRAMEWORK}" -output ${FRAMEWORK_NAME}.xcframework
done
# Cleaning Thin Folders
rm -rf ./*-Sliced
echo "DONEEEEEEEE"