Fastlane自动化打包---安装篇
Fastlane自动化打包---配置篇
参考文档:
3. 打包上传蒲公英
3.1 配置Fastlane插件
Gemfile文件
补充:我是在上传到蒲公英的时候报错了才知道需要安装插件,所以退回来配置了几个插件
安装过插件之后Gemfile
文件中就会生成插件的路径在fastlane文件下生成了一个Pluginfile文件
Pluginfile文件
这里我安装了三个插件。也可参考Fastlane官网插件安装
3.1.1 安装fir
插件
$ cd 项目目录
$ bundle exec fastlane add_plugin fir
参考安装fir插件图文教程中分析了遇到的错误,我没有遇到直接就过了
如下
$ cd 项目目录
$ 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 项目目录
$ 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 项目目录
$ 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的别名
# 自动代码签名
#enable_automatic_code_signing
gym(
clean:true, #打包前clean项目
export_method: "ad-hoc", #导出方式
scheme:"FastlaneDev", #scheme
# configuration: "Debug",#环境
output_directory: "./Ipa",#ipa的存放目录
output_name: get_version_number_from_plist() + "_" + Time.new.strftime("%Y-%m-%d %H-%M-%S") #输出ipa的文件名为当前的build号和创建的时间
export_options: {
#手动配置代码签名
provisioningProfiles: {
"项目的Bundle identifier": "证书名称",
}
}
)
# 上传命令
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 🎉
网友评论