forked from bq/ipa-packager
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpackage_ipa_setpath.sh
70 lines (56 loc) · 1.8 KB
/
package_ipa_setpath.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
APP="$1"
IPA="$2"
TEMP_IPA_BUILT="/tmp/ipabuild"
XCODE_PATH="$3"
if [ ! -d "${XCODE_PATH}" ]; then
echo "No developer directory found!"
exit 1
fi
if [ ! -d "${APP}" ]; then
echo "Usage: sh package_ipa.sh PATH_TO_SIGNED_APP OUTPUT_IPA_PATH"
exit 1
fi
echo "+ Packaging ${APP} into ${IPA}"
if [ -f "${IPA}" ];
then
/bin/rm "${IPA}"
fi
if [ -d "${TEMP_IPA_BUILT}" ];
then
rm -rf "${TEMP_IPA_BUILT}"
fi
echo "+ Preparing folder tree for IPA"
mkdir -p "${TEMP_IPA_BUILT}/Payload"
cp -Rp "${APP}" "${TEMP_IPA_BUILT}/Payload"
echo "+ Adding SWIFT support (if necessary)"
if [ -d "${APP}/Frameworks" ];
then
mkdir -p "${TEMP_IPA_BUILT}/SwiftSupport"
mkdir -p "${TEMP_IPA_BUILT}/SwiftSupport/iphoneos"
for SWIFT_LIB in $(ls -1 "${APP}/Frameworks" | grep libswift); do
echo "Copying ${SWIFT_LIB}"
SOURCE="${XCODE_PATH}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos/${SWIFT_LIB}"
SWIFT_LIB_FULL_PATH="${APP}/Frameworks/${SWIFT_LIB}"
ARC_TO_REMOVE=($(lipo "${SOURCE}" -archs))
ARC_APP=($(lipo "${SWIFT_LIB_FULL_PATH}" -archs))
for archApp in "${ARC_APP[@]}"; do
for i in "${!ARC_TO_REMOVE[@]}"; do
if [[ ${ARC_TO_REMOVE[i]} = "${archApp}" ]]; then
unset ARC_TO_REMOVE[i]
fi
done
done
ARGS=()
for i in "${!ARC_TO_REMOVE[@]}"; do
ARGS+=" -remove ${ARC_TO_REMOVE[i]}"
done
if [ ${#ARGS[@]} == 0 ]; then
ARGS+=" -create"
fi
lipo "${SOURCE}" ${ARGS} -output "${TEMP_IPA_BUILT}/SwiftSupport/iphoneos/${SWIFT_LIB}"
done
fi
echo "+ zip --symlinks --verbose --recurse-paths ${IPA} ."
cd "${TEMP_IPA_BUILT}"
zip --symlinks --verbose --recurse-paths "${IPA}" .