xcodebuild自動打包,發(fā)布應(yīng)用

簡介

在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ù)制出來即可

DEA480DF-1E62-427E-92A3-2D8556D5D63A.png

描述文件UUID:
首先到描述文件路徑:

/Users/用戶名/Library/MobileDevice/Provisioning Profiles 

在終端下解密描述文件

security cms -D -i xxxx.mobileprovision

可以找到TeamName,UUID,等對應(yīng)的value值,注意要 在CODE_SIGN_IDENTITY,PROVISIONING_PROFILE賦值時要加“”號

DBD1245A-4FE3-4459-A548-3DAEE83916E9.png

導(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ù),我的如下:

image.png

我的命令:

350A6141-A444-473F-8968-D0E00B0BF3EF.png

使用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)存在這個包的錯誤提示

屏幕快照 2017-08-29 下午2.46.35.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,182評論 6 543
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,489評論 3 429
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,290評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,776評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 72,510評論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,866評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,860評論 3 447
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 43,036評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,585評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 41,331評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,536評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,058評論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,754評論 3 349
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,154評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,469評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,273評論 3 399
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 48,505評論 2 379

推薦閱讀更多精彩內(nèi)容