前提条件
已经安装好 ruby、rubygems、bundler
已经安装了 Fastlane。如果没有安装,请参考FastLane
第一步
fastlane add_plugin pgyer
第二布
在使用 Fastlane 之前,我们首先需要在项目中初始化 Fastlane。首先进入 App 的开发目录,执行以下命令来初始化 Fastlane:
fastlane init
第三步
vim ./fastlane/Fastfile
第四步
lane :beta do
build_app(export_method: "ad-hoc")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e")
end
- 以上的
api_key
和user_key
,请开发者在自己账号下的应用管理
-App概述
-API
中可以找到,并替换到以上相应的位置。 - 在 Xcode 8.3 和 Xcode 8.3 以后的版本中,对于
build_app
的export_method
的值,需要根据开发者的打包类型进行设置,可选的值有:app-store
、ad-hoc
、development
、enterprise
。对于 Xcode 8.3 以下的版本,则不需要设置export_method
。
第五步
经过以上配置后,就可以使用 Fastlane 来打包 App,并自动上传到蒲公英了。在终端下,定位到项目所在目录,输入以下命令即可:
fastlane beta
然后会打印很长的log日志,打包、上传之后成功。
如果有多个target,会有一个选择,输入对应的序号即可继续
Select Scheme:
1. VenueLeague
2. VenueLeagueUITests
?
上传完成,9分钟,可以说是很快了
[10:41:18]: Start upload /Users/soulkey/Desktop/Pro/stadium-aliance-app-ios/VenueLeague/VenueLeague.ipa to pgyer...
[10:46:31]: Upload success. Visit this URL to see: https://www.pgyer.com/6vEU
+------+------------------+-------------+
| fastlane summary |
+------+------------------+-------------+
| Step | Action | Time (in s) |
+------+------------------+-------------+
| 1 | default_platform | 0 |
| 2 | build_app | 235 |
| 3 | pgyer | 313 |
+------+------------------+-------------+
[10:46:31]: fastlane.tools just saved you 9 minutes! 🎉
备注:
如果报这个错
[15:35:06]: RubyGems is not listed as your Gem source
[15:35:06]: You can run `gem sources` to see all your sources
[15:35:06]: Please run the following command to fix this:
[15:35:06]: $ gem sources --add https://rubygems.org
查看当前
gem sources
添加源
gem sources --add https://rubygems.org
然后gem sources查看确认一下是否添加成功,问题解决