xcodebuild和xcrun自动化编译ipa包

来源:互联网 发布:云南旅发委数据 编辑:程序博客网 时间:2024/05/07 18:04

打包过程

xcodebuild负责将工程源文件编译成xxx.app

xcrun负责给xxx.app(签名并)打包成xxx.ipa


第一步清理:xcodebuild  clean

第二步编译:xcodebuild

第三步打包:xcrun -sdk iphoneos PackageApplication -v path/To/xxx.app -o xxx.ipa


bash shell入门:

http://www.aka.org.cn/Lectures/002/Lecture-2.1.2/index.html

使用getopts命令使用

:表示有参数需要值

[html] view plaincopy
  1. #!/bin/bash  
  2. while getopts h:ms option  
  3. do   
  4.     case "$option" in  
  5.         h)  
  6.             echo "option:h, value $OPTARG"  
  7.             echo "next arg index:$OPTIND";;  
  8.         m)  
  9.             echo "option:m"  
  10.             echo "next arg index:$OPTIND";;  
  11.         s)  
  12.             echo "option:s"  
  13.             echo "next arg index:$OPTIND";;  
  14.         \?)  
  15.             echo "Usage: args [-h n] [-m] [-s]"  
  16.             echo "-h means hours"  
  17.             echo "-m means minutes"  
  18.             echo "-s means seconds"  
  19.             exit 1;;  
  20.     esac  
  21. done  

在使用getopts命令的时候,shell会自动产生两个变量OPTIND和OPTARG。OPTIND初始值为1,其含义是下一个待处理的参数的索引。只要存在,getopts命令返回true,所以一般getopts命令使用while循环;

在while循环中判断 

[html] view plaincopy
  1. if getopts $param_pattern optname ;then  
  2.             echo  "Error argument value for option $tmp_optname"  
  3.             exit 2  
  4.         fi  
可以判断参数值是否是下个参数名称,如果是,就退出

[html] view plaincopy
  1. #判断输入参数是否大与0  
  2. if [ $# -lt 1 ];then  
  3.     echo "Error! Should enter the root directory of xcode project after the ipa-build command."  
  4.     exit 2  
  5. fi  
  6.   
  7. #判断第一个参数是否是目录  
  8. if [ ! -d $1 ];then  
  9.     echo "Error! The first param must be a directory."  
  10.     exit 2  
  11. fi  

xcodebuild使用

[html] view plaincopy
  1. sage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [<buildsetting>=<value>]... [<buildaction>]...  
  2.        xcodebuild -workspace <workspacename> -scheme <schemeName> [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [<buildsetting>=<value>]... [<buildaction>]...  
  3.        xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]  
  4.        xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]]  
  5.        xcodebuild -showsdks  
  6. Options:  
  7.     -usage                print full usage  
  8.     -verbose              provide additional status output  
  9.     -project NAME         build the project NAME  
  10.     -target NAME          build the target NAME  
  11.     -alltargets           build all targets  
  12.     -workspace NAME       build the workspace NAME  
  13.     -scheme NAME          build the scheme NAME  
  14.     -configuration NAME   use the build configuration NAME for building each target  
  15.     -xcconfig PATH        apply the build settings defined in the file at PATH as overrides  
  16.     -arch ARCH            build each target for the architecture ARCH; this will override architectures defined in the project  
  17.     -sdk SDK              use SDK as the name or path of the base SDK when building the project  
  18.     -parallelizeTargets   build independent targets in parallel  
  19.     -jobs NUMBER          specify the maximum number of concurrent build operations  
  20.     -showsdks             display a compact list of the installed SDKs  
  21.     -list                 lists the targets and configurations in a project, or the schemes in a workspace  
  22.     -find BINARY          display the full path to BINARY in the provided SDK  
  23.     -version              display the version of Xcode; with -sdk will display info about one or all installed SDKs  
0 0