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安装和简单使用记录至此,方便日后查阅。

你可能感兴趣的:(iOS-安装Fastlane报错SSL verification error at depth 0: certificate has expired (10))