fastlane 安装以及一些坑

4,499 阅读1分钟

安装 fastlane

faslane 安装准备
1.检查Xcode项目是否为share

Xcode -> Manager Scheme -> 项目勾选☑️Shared

2.升级ruby版本保持2.5+,查看ruby版本:
ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]

若不满足需要升级ruby:

brew install ruby
3.安装Xcode command line tools,若已安装,请忽略
xcode-select --install
4.安装fastlane
  • 使用gem安装fastlane
sudo gem install fastlane -NV

...

Successfully installed fastlane-2.211.0
  • 使用homebrew安装fastlane
brew install fastlane
5.查看fastlane当前版本
fastlane -v
/usr/local/lib/ruby/gems/3.0.0/gems/fastlane-2.211.0/bin/fastlane

-----------------------------

[✔] 🚀 

fastlane 2.211.0
6.配置信息 输入open .bash_profile 文件末尾添加配置如下:
export PATH="$HOME/.fastlane/bin:$PATH"
export PATH="$HOME/.fastlane/bin/fastlane_lib:$PATH"
7.安装bundler
sudo gem install bundler

执行 fastlane 报错:

报错1:
Exit status of command 'cd '.' && bundle exec pod install' was 1 instead of 0.
/usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': Could not find 'bundler' (1.17.2) required by your /Users/kaiwang/vue-project-xiaoyaoyao/ykq_heyestore_flutter/ios/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.17.2`
        from /usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
        from /usr/local/opt/ruby/bin/bundle:23:in `<main>'

 /usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': Could not find 'bundler' (1.17.2) required by your /Users/kaiwang/vue-project-xiaoyaoyao/ykq_heyestore_flutter/ios/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.17.2`
        from /usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
        from /usr/local/opt/ruby/bin/bundle:23:in `<main>'

首先根据提示,bundler 未安装,先执行安装:

sudo gem install bundler:1.17.2

安装完成之后,查看 bundler 版本:

bundle -v

再次执行,fastlane, 还报同样的错误,执行下面语句:

gem update --system

错误解决。

报错2:
bundler: failed to load command: pod (/usr/local/Cellar/fastlane/2.197.0/libexec/bin/pod) (FastlaneCore::Interface::FastlaneShellError)

解决:

在项目根目录下 fastlane/Fastfile 修改文件中的cocoapods ' cocoapods(use_bundle_exec: false)'