iOS自动打包脚本

使用Xcodebuild和xcrun命令生成。具体参数可以自己配置。

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
#!/bin/bash
#Author hanliu

#Global declaration
SCHEMENAME="hongmeng"
#if use git
#BRANCHNAME = master

DATE=`date "+%Y%m%d"`
SOURCEPATH=$(CD "$(dirname $0)" && pwd)
BUILDPATH=$(dirname $(dirname $SOURCEPATH))/AutoBuildIPA
BUILDAPPPATH=$BUILDPATH/Build/Products/Debug-iphoneos
IPAPATH=$(dirname $(dirname $SOURCEPATH))/IPA
IPANAME=$SCHEMENAME_$DATE.ipa

echo "DATE is " $DATE
echo "SOURCEPATH:"$SOURCEPATH
echo "BUILDPATH:"$BUILDPATH
echo "IPAPATH:"$IPAPATH

echo "Press any key to continue!"
read -p "press any " c
if $c;then
xcodebuild -list
else
echo "ddd"
fi
#
#Information about project "xxxxx":
# Targets:
# xxxxxx
#
# Build Configurations:
# Debug
# Release
#
# If no build configuration is specified and -scheme is not passed then "Release" is used.
#
# Schemes:
# xxxxxx
#

#不指定configuration,打包为debug模式
#xcodebuild -workspace hongmeng.xcworkspace -scheme hongmeng -configuration Debug clean build -derivedDataPath $BUILDPATH

xcodebuild -workspace $SCHEMENAME.xcworkspace -scheme $SCHEMENAME -configuration Debug clean build -derivedDataPath $BUILDPATH
if [ -e $BUILDPATH ]; then
echo "xcodebuild Successful!"
else
echo "xcodebuild failure!"
exit 1
fi


#打包ipa
#xcrun -sdk iphoneos PackageApplication -v AutoBuildIPA/Build/Products/Debug-iphoneos/$SCHEMENAME.app -o $BUILDPATH/$SCHEMENAME_$DATE.ipa
xcrun -sdk iphoneos PackageApplication -v $BUILDAPPPATH/$SCHEMENAME.app -o $IPAPATH/$IPANAME

if [ -e $IPAPATH/$IPANAME ]; then
echo "\n--------------\n\n"
echo "Congratulations! Build Successful!"
open $IPAPATH
else
echo "Build failure!"
fi