自动打渠道包的shell命令

来源:互联网 发布:淘宝好评卡模板 编辑:程序博客网 时间:2024/05/16 12:58

如题,现在的商业项目,特别是要在国内推广的,难免要和一些渠道商合作,这就需要我们攻城师为指定的渠道打特定的包。

 

以前我都是手动改build configureation,生成不同的包。

 

后来觉得麻烦 ,在网上学习了一下,弄了这个东西,大家看看,拿去修改修改就能用了。

1    #!/bin/sh

3    #  build.Script.sh
4    #  xxxx
5    #
6    #  Created by michael on 12-1-16.
7    #  Copyright (c) 2012年 xxxx. All rights reserved.
8   
9  
10  distDir="/Users/michael/Desktop/dist"
11  releaseDir="./build/"
12  version="1_5_0"                                                 #发布的版本号
13  rm -rdf "$distDir"
14  mkdir "$distDir"
15  rm -rdf "$releaseDir"
16  for line in $(cat channel)                                  #读取所有渠道号channel文件 如:  appstore:10001 {渠道名:渠道号}
17  do
18  ipafilename=`echo $line|cut -f1 -d':'`                 #渠道名
19  sourceid=`echo $line|cut -f2 -d':'`                      #渠道号
20  xcodebuild clean -configuration "Distribution_${ipafilename}"      #clean项目
21  echo "ipafilename=$ipafilename"
22  echo "sourceid=$sourceid"
23  targetName="xxxx"                                       #项目名称(xcode左边列表中显示的项目名称)
24 
25 
26  ipapath="${distDir}/${targetName}_${version}_for_${sourceid}.ipa"
27 
28  echo "***开始build app文件***"
29  xcodebuild -project xxxx.xcodeproj -target "$targetName" -configuration "Distribution_${ipafilename}"  -sdk   iphoneos5.0 build
30appfile="${releaseDir}Distribution_${ipafilename}-iphoneos/${targetName}.app"
31  cd ${releaseDir}Distribution_${ipafilename}-iphoneos/
32  zip -r "${targetName}_${ipafilename}_${version}.zip" "${targetName}.app"
33  cd ..
34  cd ..
35  echo "***开始打ipa渠道包****"
36  /usr/bin/xcrun -sdk iphoneos5.0 PackageApplication -v "$appfile" -o "$ipapath" --sign "iPhone Distribution: xxxxx company"
37  done


(转:http://www.cocoachina.com/macdev/tips/2013/0222/5704.html)