-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_ipa_adhoc.sh
96 lines (79 loc) · 2.71 KB
/
build_ipa_adhoc.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
source trap_ctrlc.sh
# build_ipa_adhoc
# ENV : staging|production
# BUILD_NAME : (example 1.0.0)
# BUILD_NUMBER : (example 1)
# MODE : [obfuscate]
declare ENV=$1
declare BUILD_NAME=$2
declare BUILD_NUMBER=$3
declare MODE=$4
declare APP_NAME="Skybase"
if [ "$BUILD_NUMBER" == "i" ]
then
declare LAST_BUILD_NUMBER=`sed -n 's/FLUTTER_BUILD_NUMBER=//p' ios/Flutter/Generated.xcconfig`
BUILD_NUMBER=$(( LAST_BUILD_NUMBER + 1 ))
fi
# validate mode
if [ ! "$MODE" == "obfuscate" ]
then
MODE=
fi
# flutter build
echo "🟦 Starting Flutter build..."
echo "⬜️ Platform : iOS"
echo "⬜️ Env : $ENV"
echo "⬜️ Build name : $BUILD_NAME"
echo "⬜️ Build number : $BUILD_NUMBER"
echo "⬜️ Mode : $MODE"
if [ "$MODE" == "obfuscate" ]
then
flutter build ios -t "lib/main_$ENV.dart" --build-name="$BUILD_NAME" --build-number="$BUILD_NUMBER" --obfuscate --split-debug-info=.debug-info-ios --no-codesign
else
flutter build ios -t "lib/main_$ENV.dart" --build-name="$BUILD_NAME" --build-number="$BUILD_NUMBER" --no-codesign
fi
if [ ! $? == 0 ]
then
echo "🟥 build failed"
exit 1
fi
# sync build name and build number
sed -i '' 's|FLUTTER_BUILD_NAME=.*|FLUTTER_BUILD_NAME='"$BUILD_NAME"'|g' ios/Flutter/Generated.xcconfig
sed -i '' 's|FLUTTER_BUILD_NUMBER=.*|FLUTTER_BUILD_NUMBER='"$BUILD_NUMBER"'|g' ios/Flutter/Generated.xcconfig
declare BLDCODE="${APP_NAME}_${BUILD_NAME}_${BUILD_NUMBER}_$ENV"
declare ARCHIVE_PATH="${HOME}/Library/Developer/Xcode/Archives/${BLDCODE}.xcarchive"
# archiving
rm -rf "$ARCHIVE_PATH"
echo "🟦 Archiving...";
echo "⬜️ Archive path: $ARCHIVE_PATH";
echo "⬜️ Please wait...";
xcrun xcodebuild -configuration "Release" VERBOSE_SCRIPT_LOGGING=YES -workspace ios/Runner.xcworkspace -scheme "Runner" -sdk iphoneos FLUTTER_SUPPRESS_ANALYTICS=true COMPILER_INDEX_STORE_ENABLE=NO -archivePath "$ARCHIVE_PATH" archive > .build_ios_archive.log
if [ ! $? == 0 ]
then
echo "🟥 build failed"
exit 1
fi
declare EXPORT_PATH="build/ios/adhoc/Release"
declare OPT_PLIST="ExportOptions-adhoc.plist"
# exporting ipa
rm -rf "$EXPORT_PATH"
echo "🟦 Exporting ipa...";
echo "⬜️ Please wait...";
xcrun xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportPath "$EXPORT_PATH" -exportOptionsPlist "$OPT_PLIST"
if [ ! $? == 0 ]
then
echo "🟥 build failed"
exit 1
fi
# rename
ipa_file=(build/ios/adhoc/Release/*.ipa)
ipa_file=${ipa_file[0]}
mv "$ipa_file" "build/ios/adhoc/Release/release.ipa"
# backup dSYMs
declare DSYMS_BK_DIR=".build_ios_dsyms/${BLDCODE}"
mkdir -p "$DSYMS_BK_DIR"
cp -r "$ARCHIVE_PATH/dSYMs" "$DSYMS_BK_DIR"
# clean up
rm -rf "$ARCHIVE_PATH"
echo "⬜️ Export path: $EXPORT_PATH"
echo "🟩 Build done"