Fastlane自動(dòng)化打包---安裝篇
Fastlane自動(dòng)化打包---配置篇
參考文檔:
3. 打包上傳蒲公英
3.1 配置Fastlane插件
補(bǔ)充:我是在上傳到蒲公英的時(shí)候報(bào)錯(cuò)了才知道需要安裝插件秕重,所以退回來(lái)配置了幾個(gè)插件
安裝過(guò)插件之后Gemfile
文件中就會(huì)生成插件的路徑在fastlane文件下生成了一個(gè)Pluginfile文件
Gemfile文件
Pluginfile文件
這里我安裝了三個(gè)插件檀训。也可參考Fastlane官網(wǎng)插件安裝
3.1.1 安裝fir
插件
$ cd 項(xiàng)目目錄
$ bundle exec fastlane add_plugin fir
參考安裝fir插件圖文教程中分析了遇到的錯(cuò)誤肄满,我沒(méi)有遇到直接就過(guò)了
如下
$ cd 項(xiàng)目目錄
$ bundle exec fastlane add_plugin fir
[?] ??
[13:50:25]: It seems like you wanted to load some plugins, however they couldn't be loaded
[13:50:25]: Please follow the troubleshooting guide: https://docs.fastlane.tools/plugins/plugins-troubleshooting/
[13:50:30]: Plugin 'fastlane-plugin-fir' was added to './fastlane/Pluginfile'
[13:50:30]: It looks like fastlane plugins are not yet set up for this project.
[13:50:30]: fastlane will modify your existing Gemfile at path 'Gemfile路徑'
[13:50:30]: This change is necessary for fastlane plugins to work
[13:50:30]: Should fastlane modify the Gemfile at path
'Gemfile路徑' for you? (y/n)
y
[13:50:46]: Successfully modified 'Gemfile路徑'
[13:50:46]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Successfully installed plugins
3.1.2 安裝蒲公英pgyer
插件
$ cd 項(xiàng)目目錄
$ bundle exec fastlane add_plugin pgyer
$ bundle exec fastlane add_plugin pgyer
[?] ??
+-----------------------+---------+--------+
| Used plugins |
+-----------------------+---------+--------+
| Plugin | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.1 | pgyer |
| fastlane-plugin-fir | 0.3.0 | fir |
+-----------------------+---------+--------+
[13:56:19]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Successfully installed plugins
3.1.3 安裝versioning
插件
$ cd 項(xiàng)目目錄
$ bundle exec fastlane add_plugin versioning
$ bundle exec fastlane add_plugin versioning
[?] ??
+-----------------------+---------+--------+
| Used plugins |
+-----------------------+---------+--------+
| Plugin | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.1 | pgyer |
| fastlane-plugin-fir | 0.3.0 | fir |
+-----------------------+---------+--------+
[13:56:34]: Plugin 'fastlane-plugin-versioning' was added to './fastlane/Pluginfile'
[13:56:34]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Successfully installed plugins
3.2 增加上傳到蒲公英的lane
- 在
Fastfile
文件中新增lane -
以下是官方給的 api_key 和 user_key 都是蒲公英的配置
參考蒲公英
lane :beta do
build_app(export_method: "ad-hoc")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e")
end
我貼出我自己找的,修改的行疏,其中有一些坑
desc "打包上傳到蒲公英"
lane :do_pgyer do #|options|
# 打包命令 gym和build_app都是build_ios_app的別名
# 自動(dòng)代碼簽名
#enable_automatic_code_signing
gym(
clean:true, #打包前clean項(xiàng)目
export_method: "ad-hoc", #導(dǎo)出方式
scheme:"FastlaneDev", #scheme
# configuration: "Debug",#環(huán)境
output_directory: "./Ipa",#ipa的存放目錄
output_name: get_version_number_from_plist() + "_" + Time.new.strftime("%Y-%m-%d %H-%M-%S") #輸出ipa的文件名為當(dāng)前的build號(hào)和創(chuàng)建的時(shí)間
export_options: {
#手動(dòng)配置代碼簽名
provisioningProfiles: {
"項(xiàng)目的Bundle identifier": "證書(shū)名稱(chēng)",
}
}
)
# 上傳命令
pgyer(
api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e"
)
end
3.3 上傳包到蒲公英
[15:07:48]: Successfully exported and compressed dSYM file
[15:07:48]: Successfully exported and signed the ipa file:
[15:07:48]: `包的存放路徑+`_2018-07-24 15:05:40.ipa
[15:07:48]: -------------------
[15:07:48]: --- Step: pgyer ---
[15:07:48]: -------------------
[15:07:48]: The pgyer plugin is working.
[15:07:48]: build_file: `包的存放路徑+`_2018-07-24 15:05:40.ipa
[15:07:48]: Start upload `包的存放路徑+`_2018-07-24 15:05:40.ipa to pgyer...
[15:07:59]: Upload success. Visit this URL to see: https://www.pgyer.com/Zz1I
+------+------------------+-------------+
| fastlane summary |
+------+------------------+-------------+
| Step | Action | Time (in s) |
+------+------------------+-------------+
| 1 | default_platform | 0 |
| 2 | get_build_number | 0 |
| 3 | gym | 128 |
| 4 | pgyer | 10 |
+------+------------------+-------------+
[15:07:59]: fastlane.tools finished successfully ??