在 CircleCI 上使用 fastlane 安装 gemfile 时出错

Error installing gemfile with fastlane on CircleCI

我有以下 gemfile:

source "https://rubygems.org"

gem "cocoapods", "=1.5.3"
gem "cocoapods-check", "=1.1.0"
gem "fastlane", "~> 2.131"

以及 CircleCI 上的以下管道部分:

- run:
          name: Install Gemfile for Fastlane
          command: bundle check || bundle install --path vendor/bundle

这会产生这个输出:

#!/bin/bash --login -o pipefail
bundle check || bundle install --path vendor/bundle
^D^DThe following gems are missing
 * minitest (5.12.0)
 * babosa (1.0.3)
 * cocoapods-core (1.5.3)
 * fourflusher (2.0.1)
 * cocoapods (1.5.3)
 * cocoapods-check (1.1.0)
 * excon (0.67.0)
 * json (2.2.0)
 * rubyzip (1.3.0)
Install missing gems with `bundle install`
Fetching gem metadata from https://rubygems.org/........
Using CFPropertyList 3.0.1
Using concurrent-ruby 1.1.5
Using i18n 0.9.5
Using minitest 5.12.0
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 4.2.11.1
Fetching public_suffix 2.0.5
Installing public_suffix 2.0.5
Fetching addressable 2.7.0
Installing addressable 2.7.0
Using atomos 0.1.3
Fetching babosa 1.0.3
Installing babosa 1.0.3
Using bundler 2.0.2
Using claide 1.0.3
Using fuzzy_match 2.0.4
Using nap 1.1.0
Using cocoapods-core 1.5.3
Using cocoapods-deintegrate 1.0.4
Using cocoapods-downloader 1.2.2
Using cocoapods-plugins 1.0.0
Using cocoapods-search 1.0.0
Using cocoapods-stats 1.1.0
Using netrc 0.11.0
Using cocoapods-trunk 1.4.0
Using cocoapods-try 1.1.0
Using colored2 3.1.2
Using escape 0.0.4
Using fourflusher 2.0.1
Using gh_inspector 1.1.3
Using molinillo 0.6.6
Using ruby-macho 1.4.0
Using nanaimo 0.2.6
Using xcodeproj 1.12.0
Using cocoapods 1.5.3
Using cocoapods-check 1.1.0
Fetching colored 1.2
Installing colored 1.2
Fetching highline 1.7.10
Installing highline 1.7.10
Fetching commander-fastlane 4.4.6
Installing commander-fastlane 4.4.6
Fetching declarative 0.0.10
Installing declarative 0.0.10
Fetching declarative-option 0.1.0
Installing declarative-option 0.1.0
Fetching digest-crc 0.4.1
Installing digest-crc 0.4.1
Fetching unf_ext 0.0.7.6
Installing unf_ext 0.0.7.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/distiller/project/vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.6/ext/unf_ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r
./siteconf20190926-723-dvbzjp.rb extconf.rb
mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in
/Users/distiller/project/vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.6 for
inspection.
Results logged to
/Users/distiller/project/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-18/2.3.0/unf_ext-0.0.7.6/gem_make.out

An error occurred while installing unf_ext (0.0.7.6), and Bundler
cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.6' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  fastlane was resolved to 2.131.0, which depends on
    faraday-cookie_jar was resolved to 0.0.6, which depends on
      http-cookie was resolved to 1.0.3, which depends on
        domain_name was resolved to 0.5.20190701, which depends on
          unf was resolved to 0.1.4, which depends on
            unf_ext
Exited with code 5
CircleCI received exit code 5

如您所见,安装unf_ext时似乎失败了。为什么是这样?我该如何解决这个问题?

我已经尝试在我的电脑上安装 gem install unf_ext -v '0.0.7.6' --source 'http://rubygems.org/',它工作正常。

你的 Gemfile 放在哪里?

它应该和fastlane目录在同一目录(同一级别)才能工作。

因此,如果您遵循 Fastlane 文档,并且如果您正在使用 React Native 或 Flutter 构建应用程序,您应该在 iOS 中有一个 Gemfile,在 android 中有一个目录。

这是 CircleCI 本身的问题,但已经解决了。