xcode升级8.3后发现以前所用的xcode自动打包基本没法使用,所以在网上零碎找到些资料,将以前的脚本简化。这次脚本是基于xcode证书配置进行打包(以前是指定描述文件、相对繁琐)。所以代码较为简单使用。html
自动打包是基于xcodebuild工具进行打包(xcode自己也是基于此打包)。在终端咱们能够经过 man xcodebuild
指令查看了解xcodebuild工具git
接着经过xcodebuild --help
可直接获得其使用示例github
非cocoapods管理项目,只须要对单个工程进行打包处理,使用以下方法shell
xcodebuild [-project <projectname>] -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
因为笔者使用cocoapods管理第三方库,所以直接使用进行打包xcode
xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
当打包完成后只须要对压缩包解压便可获得对应的ipa安装包app
xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <plistpath>
#清理工程 xcodebuild clean -configuration ${development_mode} -quiet || exit #编译工程 xcodebuild archive -workspace ${project_name}.xcworkspace -scheme ${scheme_name} -configuration ${development_mode} -archivePath build/${project_name}.xcarchive -quiet || exit #打包 xcodebuild -exportArchive -archivePath build/${project_name}.xcarchive -configuration ${development_mode} -exportPath ${exportFilePath} -exportOptionsPlist ${exportOptionsPlistPath} -quiet || exit //todo ..应用上传分发操做 参数说明 cleaen 清理工程 quiet 不输出警告或错误 exit 命令未完成退出shell脚本 projectname 工程名 workspacename 工程名 schemeName 通常也为工程名(我的理解为应用调起标示) configuration 打包模式(Debug/Release) exportOptionsPlist ipa导出方式(分为app-store、ad-hoc、enterprise、development) 此项由plist文件构成的字典key:method, value:development(上述四个其中一个)
自动打包脚本已上传至github有须要的朋友可自行下载自动打包脚本文件连接工具
上述若有不妥之处请指正参考连接ui