fastlane 自動(dòng)化03----構(gòu)建稿蹲、編譯

傳送門:

fastlane 自動(dòng)化01----初識(shí)
fastlane 自動(dòng)化02----證書簽名
fastlane 自動(dòng)化03----構(gòu)建择葡、編譯
fastlane 自動(dòng)化04----分發(fā)、上傳(未完待續(xù)函匕。千诬。耍目。)

先看一下官方給 的codesign相關(guān)的有哪些action.

Action Description Supported Platforms
gym Alias for the build_ios_app action ios, mac
cocoapods Runs pod install for the project ios, mac
gradle All gradle related actions, including building and testing your Android app ios, android
clear_derived_data Deletes the Xcode Derived Data ios, mac
adb Run ADB Actions android
xcversion Select an Xcode to use by version specifier ios, mac
xcodebuild Use the xcodebuild command to build and sign your app ios, mac
carthage Runs carthage for your project ios, mac
xcode_select Change the xcode-path to use. Useful for beta versions of Xcode ios, mac
ensure_xcode_version Ensure the right version of Xcode is used ios, mac
clean_cocoapods_cache Remove the cache for pods ios, mac
verify_xcode Verifies that the Xcode installation is properly signed by Apple ios, mac
xcode_install Make sure a certain version of Xcode is installed ios, mac
verify_pod_keys Verifies all keys referenced from the Podfile are non-empty ios, mac
xcclean Cleans the project using xcodebuild ios, mac
build_android_app Alias for the gradle action ios, android
xcexport Exports the project using xcodebuild ios, mac
xcarchive Archives the project using xcodebuild ios, mac
build_app Alias for the build_ios_app action ios, mac
build_ios_app Easily build and sign your app (via gym) ios, mac
xctest Runs tests on the given simulator ios, mac
xcbuild Builds the project using xcodebuild ios, mac
spm Runs Swift Package Manager on your project ios, android, mac

好了,知道你也不想看徐绑,其實(shí)這里面最重要也就是那個(gè)gymcocoapods制妄。cocoapods比較簡(jiǎn)單,用來(lái)在簽名前先把pods上的三方庫(kù)拉到本地泵三,gym就是用來(lái)構(gòu)建和簽名app用的,他的功能最為豐富.

Action具體用法
1.cocoapods三方庫(kù)管理工具

先來(lái)看看cocoapods有哪些參數(shù)

#查看cocoapods有哪些參數(shù)
$ fastlane action cocoapods 

use the cocoapods integration to run pod install before building your app.
所以這個(gè)action的作用就是pod install衔掸。

Key Description Default
repo_update 相當(dāng)于 pod install --repo-update命令
clean_install 忽略本地緩存 (PS:我測(cè)試時(shí)烫幕,該參數(shù)不能被識(shí)別,先用廢棄的clean參數(shù)代替) false
silent 靜默執(zhí)行 false
verbose 詳細(xì)輸出 false
ansi 允許終端輸出展示富文本(如輸入不同顏色敞映、背景的文字) true
use_bundle_exec 有g(shù)emfile文件則執(zhí)行命令為: bundle exec + your_command较曼,如$ bundle exec fastlane action cocoapods true
podfile 設(shè)置fastlane文件夾相對(duì)包含podfile文件夾的相對(duì)路徑
error_callback 出錯(cuò)后回調(diào)
try_repo_update_on_error 當(dāng)失敗后,嘗試更新索引 false
deployment install期間忽略podfile的更改 false

eg.

  cocoapods(
    podfile:"./", #此時(shí)podfile和fastlane文件夾在同一目錄下
    verbose: true,
    clean: "true",
  )
2.gym 編譯構(gòu)建簽名

老規(guī)矩振愿,先來(lái)看看gym有哪些參數(shù):

$ fastlane action gym

Parameters

Key Description Default
workspace ?? Path to the workspace file
project?? Path to the project file
scheme?? The project's scheme. Make sure it's marked as Shared捷犹,注意一定要在mange scheme中設(shè)置shared 為勾選狀態(tài)
clean Should the project be cleaned before building it? false
output_directory ?? The directory in which the ipa file should be stored in .
output_name?? The name of the resulting ipa file
configuration?? The configuration to use when building the app. Defaults to 'Release' *
silent Hide all information that's not necessary while building false
codesigning_identity The name of the code signing identity to use. It has to match the name exactly. e.g. 'iPhone Distribution: SunApps GmbH'
skip_package_ipa Should we skip packaging the ipa? false
include_symbols Should the ipa file include symbols?
include_bitcode?? Should the ipa file include bitcode?
export_method?? Method used to export the archive. Valid values are: app-store, ad-hoc, package, enterprise, development, developer-id
export_options ?? Path to an export options plist or a hash with export options. Use 'xcodebuild -help' to print the full set of available options
export_xcargs 測(cè)試無(wú)用弛饭,可以用xcargs來(lái)代替,Pass additional arguments to xcodebuild for the package phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS="-ObjC -lstdc++"
skip_build_archive Export ipa from previously built xcarchive. Uses archive_path as source
skip_archive After building, don't archive, effectively not including -archivePath param
skip_codesigning Build without codesigning
build_path The directory in which the archive should be stored in
archive_path The path to the created archive
derived_data_path The directory where built products and other derived data will go
result_bundle Should an Xcode result bundle be generated in the output directory false
result_bundle_path Path to the result bundle directory to create. Ignored if result_bundle if false
buildlog_path The directory where to store the build log *
sdk The SDK that should be used for building the application
toolchain The toolchain that should be used for building the application (e.g. com.apple.dt.toolchain.Swift_2_3, org.swift.30p620160816a)
destination Use a custom destination for building the app
export_team_id Optional: Sometimes you need to specify a team id when exporting the ipa file
xcargs?? Pass additional arguments to xcodebuild for the build phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS="-ObjC -lstdc++"
xcconfig Use an extra XCCONFIG file to build your app
suppress_xcode_output Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path
disable_xcpretty Disable xcpretty formatting of build output
xcpretty_test_format Use the test (RSpec style) format for build output
xcpretty_formatter A custom xcpretty formatter to use
xcpretty_report_junit Have xcpretty create a JUnit-style XML report at the provided path
xcpretty_report_html Have xcpretty create a simple HTML report at the provided path
xcpretty_report_json Have xcpretty create a JSON compilation database at the provided path
analyze_build_time Analyze the project build time and store the output in 'culprits.txt' file
xcpretty_utf Have xcpretty use unicode encoding when reporting builds
skip_profile_detection Do not try to build a profile mapping from the xcodeproj. Match or a manually provided mapping should be used false

上面參數(shù),常用的我已經(jīng)用??標(biāo)明萍歉。其中workspace侣颂、project只需要設(shè)置其中任何一個(gè)即可,否則打包過(guò)程會(huì)報(bào)錯(cuò)枪孩,這里重點(diǎn)說(shuō)一下export_optionsxcargs.

  • export_options

這個(gè)是xcodebuild命令的可用選項(xiàng)憔晒,可以在終端中用$ xcodebuild -help來(lái)查看相關(guān)命令,當(dāng)你的fastlane中沒(méi)有使用match 配合gym打包時(shí)蔑舞,可以指定一個(gè)hash map來(lái)決定使用的那個(gè)證書來(lái)簽名拒担,如:

    export_options: {
        compileBitcode: false,
        provisioningProfiles: {
          "com.LSJ.Fastlane" => "match Development com.LSJ.Fastlane", 
       }
    }
// hashmap的 key為bundleID,value為對(duì)應(yīng)的provison profile
  • xcargs

這個(gè)也是在執(zhí)行xcodebuild命令的時(shí)添加參數(shù)攻询。比如生活Debug模式添加幾宏DEBUG=1 TEST=1从撼,設(shè)置OTHER_LDFLAGS="-ObjC -lstdc++ 等等...類似于如下結(jié)構(gòu):

    xcargs: {
        :GCC_PREPROCESSOR_DEFINITIONS => "DEBUG=1 TEST=1", #設(shè)置宏定義
        :OTHER_LDFLAGS => "-ObjC -lstdc++" #設(shè)置link flags
    },

像上面的OTHER_LDFLAGS"-ObjC -lstdc++"這種xcargs參數(shù)key和value如何確定呢?

當(dāng)我們?cè)诠こ痰腷uild setting里設(shè)置了other link Flags相關(guān)參數(shù)钧栖,如下圖


這時(shí)工程就會(huì)生成對(duì)應(yīng)的字段去記錄低零。打開XXXX.xcproject文件所在的目錄,右擊XXXX.xcproject => 顯示包內(nèi)容 => 打開project.pbxproj,這個(gè)project.pbxproj就是來(lái)記錄工程設(shè)置的文件桐经,
打開文件后搜索你設(shè)置的value值毁兆,如-Objc,然后定位到相關(guān)位置如下圖:

other link Flagsxcodebuild 命令中的參數(shù)值就是OTHER_LDFLAGS阴挣,如果value值有多個(gè)數(shù)值气堕,則中間通過(guò)空格分隔開,所以是 OTHER_LDFLAGS => "-Objc -lstdc++".

上代碼:

 gym(
    workspace: "AutoUploadProject.xcworkspace", 
    configuration: "Debug", #Debug Release DailyBuild 編譯環(huán)境
    export_method: "development", #用development開發(fā)證書簽名
    #project: "AutoUploadProject.xcodeproj", 
    scheme: "AutoUploadProject", #必須勾選為shared
    clean: true,  //每次編譯前先clean
    export_xcargs: "-allowProvisioningUpdates", #允許訪問(wèn)證書
    output_name: "my-app.ipa", #輸出名稱
    xcargs: {
        :GCC_PREPROCESSOR_DEFINITIONS => other_flags,
        #"GCC_PREPROCESSOR_DEFINITIONS" => "DEBUG=1 TEST=1"
    },
    #export_team_id: "66L654578N", #teamID在生產(chǎn)畔咧、測(cè)試證書中是不同的茎芭。
    #export_xcargs: "GCC_PREPROCESSOR_DEFINITIONS='MYCODE'",
    export_options: {
        compileBitcode: false,
       # provisioningProfiles: {
       #     "com.LSJ.Fastlane" => "match Development com.LSJ.Fastlane",
       # } #如果跟`match`連用,則不用設(shè)置設(shè)置bundleID=>provision profiles的對(duì)應(yīng)關(guān)系誓沸。
    }
  )
  end
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末梅桩,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子拜隧,更是在濱河造成了極大的恐慌宿百,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,589評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件洪添,死亡現(xiàn)場(chǎng)離奇詭異垦页,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)干奢,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,615評(píng)論 3 396
  • 文/潘曉璐 我一進(jìn)店門痊焊,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事薄啥≡穑” “怎么了?”我有些...
    開封第一講書人閱讀 165,933評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵垄惧,是天一觀的道長(zhǎng)刁愿。 經(jīng)常有香客問(wèn)我,道長(zhǎng)赘艳,這世上最難降的妖魔是什么酌毡? 我笑而不...
    開封第一講書人閱讀 58,976評(píng)論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮蕾管,結(jié)果婚禮上枷踏,老公的妹妹穿的比我還像新娘。我一直安慰自己掰曾,他們只是感情好旭蠕,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,999評(píng)論 6 393
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著旷坦,像睡著了一般掏熬。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上秒梅,一...
    開封第一講書人閱讀 51,775評(píng)論 1 307
  • 那天旗芬,我揣著相機(jī)與錄音,去河邊找鬼捆蜀。 笑死疮丛,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的辆它。 我是一名探鬼主播誊薄,決...
    沈念sama閱讀 40,474評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼锰茉!你這毒婦竟也來(lái)了呢蔫?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,359評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤飒筑,失蹤者是張志新(化名)和其女友劉穎片吊,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體协屡,經(jīng)...
    沈念sama閱讀 45,854評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡俏脊,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,007評(píng)論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了著瓶。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,146評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖材原,靈堂內(nèi)的尸體忽然破棺而出沸久,到底是詐尸還是另有隱情,我是刑警寧澤余蟹,帶...
    沈念sama閱讀 35,826評(píng)論 5 346
  • 正文 年R本政府宣布卷胯,位于F島的核電站,受9級(jí)特大地震影響威酒,放射性物質(zhì)發(fā)生泄漏窑睁。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,484評(píng)論 3 331
  • 文/蒙蒙 一葵孤、第九天 我趴在偏房一處隱蔽的房頂上張望担钮。 院中可真熱鬧,春花似錦尤仍、人聲如沸箫津。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,029評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)苏遥。三九已至,卻和暖如春赡模,著一層夾襖步出監(jiān)牢的瞬間田炭,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,153評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工漓柑, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留教硫,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,420評(píng)論 3 373
  • 正文 我出身青樓欺缘,卻偏偏與公主長(zhǎng)得像栋豫,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子谚殊,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,107評(píng)論 2 356

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