-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshell.sh
executable file
·135 lines (111 loc) · 3.78 KB
/
shell.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#使用方法
#当前工程绝对路径
project_path=$(cd `dirname $0`; pwd)
#工程名 将XXX替换成自己的工程名
project_name=XXX
#scheme名 将XXX替换成自己的sheme名
scheme_name=XXX
#打包模式 Debug/Release
development_mode=Debug
#plist文件所在路径
exportOptionsPlistPath=${project_path}/exportTest.plist
#build文件夹路径
build_path=${project_path}/build
#导出.ipa文件所在路径
exportIpaPath=${project_path}/IPADir/${development_mode}
echo "请输入你想要输出的数字? [ 1:app-store 2:ad-hoc] "
##
read number
while([[ $number != 1 ]] && [[ $number != 2 ]])
do
echo "错误!只能输入1或者2!!!"
echo "输入你想要输出的数字? [ 1:app-store 2:ad-hoc] "
read number
done
if [ $number == 1 ];then
development_mode=Release
exportOptionsPlistPath=${project_path}/exportAppstore.plist
exportIpaPath=${project_path}/IPADir/${development_mode}
else
development_mode=Release
exportOptionsPlistPath=${project_path}/exportTest.plist
exportIpaPath=${project_path}/IPADir/${development_mode}
fi
# echo '======* 正在清理工程 *======'
# xcodebuild \
# clean -configuration ${development_mode} -quiet || exit
# echo ''
rm -r $exportIpaPath
path_info_plist="${project_path}/${project_name}/info.plist"
if [ -e $path_info_plist ]; then
echo "${path_info_plist}"
fi
echo "当前Version:\c"
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$path_info_plist"
echo "当前Build:\c"
/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$path_info_plist"
# 还没想好怎么更好
echo "请输入bundleVersion:"
read bundleVersion
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $bundleVersion" "$path_info_plist"
echo "请输入bundleBuild:"
read bundleBuild
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bundleBuild" "$path_info_plist"
echo "======* 正在编译工程:${development_mode} *======"
xcodebuild \
archive -workspace ${project_path}/${project_name}.xcworkspace \
-scheme ${scheme_name} \
-configuration ${development_mode} \
-archivePath ${build_path}/${project_name}.xcarchive -quiet || exit
echo ''
echo '======* 开始ipa打包 *======'
xcodebuild -exportArchive -archivePath ${build_path}/${project_name}.xcarchive \
-configuration ${development_mode} \
-exportPath ${exportIpaPath} \
-exportOptionsPlist ${exportOptionsPlistPath} \
-quiet || exit
if [ $number == 1 ];then
echo '======* 构建app并上传appStore成功 *======'
rm -r $build_path
exit 1
elif [ -e $exportIpaPath/$scheme_name.ipa ]; then
echo "======* ipa包已导出:$exportIpaPath/$scheme_name.ipa *======"
open $exportIpaPath
rm -r $build_path
else
echo '======* ipa包导出失败 *======'
exit 1
fi
#echo ''
#echo '======* 开始发布 *======'
#
#if [ $number == 1 ];then
#
#echo "请输入您的AppleId帐号:"
#read account
#
#echo "请输入您的AppleId密码:"
#read -s password
##验证并上传到App Store
#altoolPath="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool"
#"$altoolPath" --validate-app -f ${exportIpaPath}/${scheme_name}.ipa -u ${account} -p ${password} -t ios --output-format xml
#"$altoolPath" --upload-app -f ${exportIpaPath}/${scheme_name}.ipa -u ${account} -p ${password} -t ios --output-format xml
#else
#
##上传到Fir
##echo "+++++上传到Fir平台+++++"
## 将XXX替换成自己的Fir平台的token
##fir login -T XXX
##fir publish $exportIpaPath/$scheme_name.ipa
#
#
##上传到蒲公英
##将XXX替换成自己蒲公英上的User Key
#uKey="XXX"
##将XXX替换成自己蒲公英上的API Key
#apiKey="XXX"
##执行上传至蒲公英的命令
#echo "+++++上传到蒲公英平台+++++"
#curl -F "file=@${exportIpaPath}/${scheme_name}.ipa" -F "uKey=${uKey}" -F "_api_key=${apiKey}" http://www.pgyer.com/apiv1/app/upload
#fi
exit 0