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