iOS-安装Fastlane报错SSL verification error at depth 0: certificate has expired (10)

Fastlane 是一款为 iOS 和 Android 开发者提供的自动化构建工具,它可以帮助开发者将 App 打包、签名、测试、发布、信息整理、提交 App Store 等工作完整的连接起来,实现完全自动化的工作流,如果使用得当,可以显著的提高开发者的开发效率。

安装Fastlane

1.检查有没有ruby环境

ruby --version

2.安装Xcode命令行工具

xcode-select --install

安装完成后效果如下所示:

001.jpg
002.jpg

注意:如果未安装,终端会开始安装,如果报错误:command line tools are already installed, use "Software Update" to install updates.代表已经安装。

3.以上依赖配置好之后就可以通过 rubygem 进行安装了:

sudo gem install fastlane

安心等待一会,fastlane就安装完成了,如图所示

005.jpg

注意!此时可能会报错:SSL verification error at depth 0: certificate has expired (10)

004.jpg

解决办法:

(1).查看当前镜像环境 : gem sources -l
(2).移除淘宝镜像: gem sources --remove https://rubygems.org/
(3).添加ruby-chian镜像:gem sources --add https://gems.ruby-china.com/

003.jpg

Fastlane使用

1.初始化Fastlane

cd到你都工程目录下执行,然后执行 fastlane init

allisondeMacBook-Pro:BDFCountyEdit allison$ fastlane init
[⠧] 🚀 /Users/allison/.rvm/gems/ruby-2.4.1@global/gems/fastlane-2.125.2/spaceship/lib/spaceship/test_flight/build.rb:91: warning: already initialized constant Spaceship::TestFlight::Build::BUILD_STATES
/Users/allison/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/fastlane-2.125.2/spaceship/lib/spaceship/test_flight/build.rb:91: warning: previous definition of BUILD_STATES was here
[✔] 🚀 
/Users/allison/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/fastlane-2.125.2/credentials_manager/lib/credentials_manager/account_manager.rb:8: warning: already initialized constant CredentialsManager::AccountManager::DEFAULT_PREFIX
/Users/allison/.rvm/gems/ruby-2.4.1@global/gems/fastlane-2.125.2/credentials_manager/lib/credentials_manager/account_manager.rb:8: warning: previous definition of DEFAULT_PREFIX was here
[11:09:37]: Sending anonymous analytics information
[11:09:37]: Learn more at https://docs.fastlane.tools/#metrics
[11:09:37]: No personal or sensitive data is sent.
[11:09:37]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[✔] Looking for iOS and Android projects in current directory...
[11:09:38]: Created new folder './fastlane'.
[11:09:38]: Detected an iOS/macOS project in the current directory: 'CountyEdit.xcworkspace'
/Users/allison/.rvm/gems/ruby-2.4.1@global/gems/fastlane-2.125.2/spaceship/lib/spaceship/portal/certificate.rb:155: warning: already initialized constant Spaceship::Portal::Certificate::IOS_CERTIFICATE_TYPE_IDS

...... //省略无用信息

[11:09:38]: -----------------------------
[11:09:38]: --- Welcome to fastlane 🚀 ---
[11:09:38]: -----------------------------
[11:09:38]: fastlane can help you with all kinds of automation for your mobile app
[11:09:38]: We recommend automating one task first, and then gradually automating more over time
[11:09:38]: What would you like to use fastlane for?
1. 📸  Automate screenshots
2. 👩‍✈️  Automate beta distribution to TestFlight
3. 🚀  Automate App Store distribution
4. 🛠  Manual setup - manually setup your project to automate
your tasks
?  
Ambiguous choice.  Please choose one of [1, 2, 3, 4, 📸  Automate
screenshots, 👩‍✈️  Automate beta distribution to TestFlight, 🚀 
Automate App Store distribution, 🛠  Manual setup - manually
setup your project to automate your tasks].
?  4
[11:10:33]: ---------------------------------------------------------
[11:10:33]: Setting up fastlane so you can manually configure it
[11:10:33]: ---------------------------------------------------------
[11:10:33]: Installing dependencies for you...
[11:10:33]: $ bundle update
[11:20:46]: --------------------------------------------------------
[11:20:46]: --- ✅  Successfully generated fastlane configuration ---
[11:20:46]: --------------------------------------------------------
[11:20:46]: Generated Fastfile at path `./fastlane/Fastfile`
[11:20:46]: Generated Appfile at path `./fastlane/Appfile`
[11:20:46]: Gemfile and Gemfile.lock at path `Gemfile`
[11:20:46]: Please check the newly generated configuration files into git along with your project
[11:20:46]: This way everyone in your team can benefit from your fastlane setup
[11:20:46]: Continue by pressing Enter ⏎

[11:27:51]: fastlane will collect the number of errors for each action to detect integration issues
[11:27:51]: No sensitive/private information will be uploaded, more information: https://docs.fastlane.tools/#metrics
[11:27:51]: ----------------------
[11:27:51]: --- fastlane lanes ---
[11:27:51]: ----------------------
[11:27:51]: fastlane uses a `Fastfile` to store the automation configuration
[11:27:51]: Within that, you'll see different lanes.
[11:27:51]: Each is there to automate a different task, like screenshots, code signing, or pushing new releases
[11:27:51]: Continue by pressing Enter ⏎

[11:27:52]: --------------------------------------
[11:27:52]: --- How to customize your Fastfile ---
[11:27:52]: --------------------------------------
[11:27:52]: Use a text editor of your choice to open the newly created Fastfile and take a look
[11:27:52]: You can now edit the available lanes and actions to customize the setup to fit your needs
[11:27:52]: To get a list of all the available actions, open https://docs.fastlane.tools/actions
[11:27:52]: Continue by pressing Enter ⏎

[11:27:57]: ------------------------------
[11:27:57]: --- Where to go from here? ---
[11:27:57]: ------------------------------
[11:27:57]: 📸  Learn more about how to automatically generate localized App Store screenshots:
[11:27:57]:         https://docs.fastlane.tools/getting-started/ios/screenshots/
[11:27:57]: 👩‍✈️  Learn more about distribution to beta testing services:
[11:27:57]:         https://docs.fastlane.tools/getting-started/ios/beta-deployment/
[11:27:57]: 🚀  Learn more about how to automate the App Store release process:
[11:27:57]:         https://docs.fastlane.tools/getting-started/ios/appstore-deployment/
[11:27:57]: 👩‍⚕️  Learn more about how to setup code signing with fastlane
[11:27:57]:         https://docs.fastlane.tools/codesigning/getting-started/
[11:27:57]: 
[11:27:57]: To try your new fastlane setup, just enter and run
[11:27:57]: $ fastlane custom_lane
allisondeMacBook-Pro:BDFCountyEdit Allison$ 

注意:选择配置方式,根据提示完成配置 ,这里我选择的是第四个

006.jpg

2.等待初始化完成之后,工程目录下就多了一个 fastlane目录,其内容如下:
007.jpg
3.配置Appfile文件以及FastFile文件

Appfile:存储App公共信息

008.png

关于Appfile的信息请阅读 https://docs.fastlane.tools/advanced/#appfile

Fastfile:包含了要对你app操作的所有信息, 如:
在Fastfile中加入蒲公英插件的配置信息。例如:

009.png
010.png

注意:
1.以上的 api_key 和 user_key,请开发者在自己账号下的 应用管理 - App概述 - API 中可以找到,并替换到以上相应的位置。
2.在 Xcode 8.3 和 Xcode 8.3 以后的版本中,对于 build_app 的 export_method 的值,需要根据开发者的打包类型进行设置,可选的值有:app-store、ad-hoc、development、enterprise。对于 Xcode 8.3 以下的版本,则不需要设置 export_method。

详情可参考: 使用 Fastlane 上传 App 到蒲公英 文章.

打包并自动上传 App 到蒲公英

经过以上配置后,就可以使用 Fastlane 来打包 App,并自动上传到蒲公英了。在终端下,定位到项目所在目录,执行fastlane beta命令即可。

allisondeMacBook-Pro:BDFCountyEdit allison$ fastlane beta
[⠦] 🚀 /Users/allison/.rvm/gems/ruby-2.4.1@global/gems/fastlane-2.125.2/spaceship/lib/spaceship/test_flight/build.rb:91: warning: already initialized constant Spaceship::TestFlight::Build::BUILD_STATES
/Users/allison/.rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/fastlane-2.125.2/spaceship/lib/spaceship/test_flight/build.rb:91: warning: previous definition of BUILD_STATES was here
[✔] 🚀 

......//省略无用的信息

[13:51:17]: Start upload /Users/allison/Desktop/BDFMobileDistrictCountyEditing/BDFCountyEdit/CountyEdit.ipa to pgyer...
[13:53:22]: Upload success. Visit this URL to see: https://www.pgyer.com/5gX0

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | build_app        | 578         |
| 3    | pgyer            | 125         |
+------+------------------+-------------+

[13:53:22]: fastlane.tools just saved you 12 minutes! 🎉

至此,fastlane打包完成,可到 https://www.pgyer.com/5gX0 网址下扫码安装最新的IPA包.

注意:如果出现下面的错误,一定要好好检查fastlane-->Fastfile文件,看是否遗漏一对括号,或者build_app 和pgyer关键词是否写错,最好直接copy 😄

[!] Syntax error in your Fastfile on line 24: Fastfile:24: syntax error, unexpected keyword_end, expecting ')'
  end
     ^
012.jpg

Fastlane安装和简单使用记录至此,方便日后查阅。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,126评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,254评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,445评论 0 341
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,185评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,178评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,970评论 1 284
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,276评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,927评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,400评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,883评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,997评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,646评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,213评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,204评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,423评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,423评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,722评论 2 345

推荐阅读更多精彩内容