设备环境:macOS Big Sur 版本 11.1 Beta版
所需条件:
1、OS X 11.1以上 2、Ruby 2.7 及以上 3、Xcode 12.2 4、苹果开发者账号一个
接下来将一步一步走进Fastlane的世界
1、Xcode安装
如果没有Xcode,就先安装一个Xcode吧。
2、更新ruby版本
curl -L get.rvm.io | bash -s stable # 安装 rvm -v # 测试是否安装正常 rvm list known # 列出已知ruby版本 rvm install ruby-xxxxx # 安装一个最新ruby版本 注:此处xxxxx为list中的最新版本号
如果报错的话
brew install openssl reinstall|install ruby-xxxxx # 注意修改xxxxxx
以上所需的ruby环境基本配置好了
3、选择ruby 源
当前使用的ruby源:https://gems.ruby-china.com/
#查看gem源 gem sources # 删除默认的gem源 gem sources --remove https://rubygems.org/ # 增加taobao作为gem源 gem sources -a https://gems.ruby-china.com/ # 查看当前的gem源 gem sources *** CURRENT SOURCES *** https://gems.ruby-china.com/ # 清空源缓存 gem sources -c # 更新源缓存 gem sources -u
4、Fastlane安装
4.1、安装xcode-select
xcode-select --install # 如果 Xcode CLT 已经安装,则会报如下错误 # command line tools are already installed, use "Software Update" to install updates. # 如果未安装,终端会开始安装 CL
4.2、fastlane安装
sudo gem install fastlane --verbose # 如果报错:ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/commander sudo gem install -n /usr/local/bin fastlane # 等待着安装完毕....coffee or tea # 安装结束后,查看版本(2021.02我的版本是2.172.0) fastlane --version # 如果目前安装的fastlane并不是最新版本,还需要更新,怎么更新呢,看下面 # cd到项目文件夹 cd xxxxx fastlane init # 需要按照提示输入 AppID以及密码, 这个是你项目的开发者帐号,下边要输入项目的bundleIdentifier,然后出现了提示 ######################################################################## # fastlane 2.172.0 is available. You are on 2.170.0. # It is recommended to use the latest version. # Update using 'sudo gem update fastlane'. ####################################################################### # 更新最新版本 sudo gem install -n /usr/local/bin/ fastlane --version2.172.0 # 如果报错 Could not find a valid gem 'fastlane' (= 2.170.0) in any repository , 那么更换一个ruby源,详见步骤2 # 继续更新最新版本 sudo gem install -n /usr/local/bin/ fastlane --version2.172.0 # 2.170.0成功安装!
相关教程拓展:
1、Fastlane自动化构建工具(完整解决测试和发布流程)