簡介
在iOS持續(xù)集成的過程中,簽名打包這一部分,就是對原生指令進(jìn)行了封裝, 將常用的參數(shù)名簡化, 支持全部的自帶參數(shù)及設(shè)置, 同時輸出符號表 dSYM 文件, 并且支持直接從相關(guān) repo 直接編譯打包.因此熟悉一下xcodebuild還是很有必要的。
在終端輸入man xcodebuild,可以看到Description里面有介紹用法。
打包流程
Archive包
xcodebuild archive -workspace 項目名稱.xcworkspace
-scheme 項目名稱
-configuration 構(gòu)建配置
-archivePath archive包存儲路徑
CODE_SIGN_IDENTITY=證書
PROVISIONING_PROFILE=描述文件UUID
在這里證書,和描述文件的字段,可要可不要,它會根據(jù)xcode去匹配
證書對應(yīng)內(nèi)容:
在鑰匙串找到對應(yīng)證書把加粗部分的標(biāo)題復(fù)制出來即可
描述文件UUID:
首先到描述文件路徑:
/Users/用戶名/Library/MobileDevice/Provisioning Profiles
在終端下解密描述文件
security cms -D -i xxxx.mobileprovision
可以找到TeamName,UUID,等對應(yīng)的value值,注意要 在CODE_SIGN_IDENTITY,PROVISIONING_PROFILE賦值時要加“”號
導(dǎo)出ipa包
xcodebuild -exportArchive -archivePath archive文件的地址.xcarchive
-exportPath 導(dǎo)出的文件夾地址
-exportOptionsPlist exprotOptionsPlist.plist
CODE_SIGN_IDENTITY=證書
PROVISIONING_PROFILE=描述文件UUID
同樣的,證書和描述文件的參數(shù)可要可不要,exportOptionsPlist是plist文件,我們可以用xcode創(chuàng)建一個,在里面可以配置參數(shù),我的如下:
我的命令:
使用xcodebuild exportOptionsPlist -h 查看plist可寫參數(shù)
Available keys for -exportOptionsPlist:
compileBitcode : Bool
For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.
embedOnDemandResourcesAssetPacksInBundle : Bool
For non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified.
iCloudContainerEnvironment
For non-App Store exports, if the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. Available options: Development and Production. Defaults to Development.
manifest : Dictionary
For non-App Store exports, users can download your app over the web by opening your distribution manifest file in a web browser. To generate a distribution manifest, the value of this key should be a dictionary with three sub-keys: appURL, displayImageURL, fullSizeImageURL. The additional sub-key assetPackManifestURL is required when using on demand resources.
method : String
Describes how Xcode should export the archive. Available options: app-store, package, ad-hoc, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to development.
onDemandResourcesAssetPacksBaseURL : String
For non-App Store exports, if the app uses On Demand Resources and embedOnDemandResourcesAssetPacksInBundle isn't YES, this should be a base URL specifying where asset packs are going to be hosted. This configures the app to download asset packs from the specified URL.
teamID : String
The Developer Portal team to use for this export. Defaults to the team used to build the archive.
thinning : String
For non-App Store exports, should Xcode thin the package for one or more device variants? Available options: <none> (Xcode produces a non-thinned universal app), <thin-for-all-variants> (Xcode produces a universal app and all available thinned variants), or a model identifier for a specific device (e.g. "iPhone7,1"). Defaults to <none>.
uploadBitcode : Bool
For App Store exports, should the package include bitcode? Defaults to YES.
uploadSymbols : Bool
For App Store exports, should the package include symbols? Defaults to YES.
上傳
1.測試包:
可以上傳到fir,蒲公英等網(wǎng)站,以fir為例,
首先需要一個注冊一個fir賬號,從里面可以獲取一個apitoken
安裝fir(fir命令參考)
ruby -v // > 1.9.3
gem install fir-cli
登錄fir
fir login //此時會讓你輸入apitoken
fir me //獲取賬號信息
發(fā)布應(yīng)用到fir
fir publish ipa包全路徑
發(fā)布成功后,終端會輸出一個路徑,這個就是應(yīng)用發(fā)布后的路徑,復(fù)制訪問即可.
2.正式包
altool:Application Loader的命令行工具用來驗證并上傳你的應(yīng)用程序二進(jìn)制文件到App Store
altool工具路徑:
/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool
設(shè)置別名
在~/.bash_profile 中設(shè)置別名
alias altool='/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool'
設(shè)置別名后在終端
輸入 source ~/.bash_profile
再輸入 altool 就會有它的一些用法提示,否則就是設(shè)置別名失敗了
altool用法
驗證 ipa
altool --validate-app -f file -u username [-p password] [--output- format xml]
上傳 ipa
altool --upload-app -f file -u username [-p password] [--output- format xml]
具體參數(shù):
--validate-app
您要驗證的應(yīng)用程序。
--upload-app
您要上傳的應(yīng)用程序。
-f file
您正在驗證或上傳的應(yīng)用程序的路徑和文件名。
-u username
您的用戶名。
-p password
您的用戶密碼。
--output-format [xml | normal]
您要 Application Loader 以結(jié)構(gòu)化的 XML 格式還是非結(jié)構(gòu)化的文本格式返回輸出信息。Application Loader 默認(rèn)以文本格式返回輸出信息。
我的驗證命令如下:
altool -validate-app -f 路徑.ipa -u 用戶名 -p 密碼 -t ios
不出意外就可以得到一個成功的驗證結(jié)果,我用的是以前上架過的包,得到的驗證是已經(jīng)存在這個包的錯誤提示