首页 > 解决方案 > 安装 Ruby gem 'cocoapods' 失败

问题描述

我尝试将 cocoapods 合并到我的 fastlane 构建中。根据应该像在我的 Fastfile 中添加一行一样简单的文档:

cocoapods

这应该会打电话pod install给我。但情况似乎并非如此。而不是仅仅调用pod installfastlane 尝试安装 cocoapods ,然后失败:

[16:32:36]: Installing Ruby gem 'cocoapods'...
Building native extensions.  This could take a while...
+------------------+-----------------+
|            Lane Context            |
+------------------+-----------------+
| DEFAULT_PLATFORM | ios             |
| PLATFORM_NAME    | ios             |
| LANE_NAME        | ios kptapp_TEST |
+------------------+-----------------+
[16:32:52]: ERROR: Failed to build gem native extension.

    current directory: /usr/local/Caskroom/fastlane/latest/fastlane_lib/bundle/lib/ruby/gems/2.2.0/gems/ffi-1.12.2/ext/ffi_c
/usr/local/Caskroom/fastlane/latest/fastlane_lib/bundle/bin/ruby -r ./siteconf20200309-76244-14k7phf.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

特别奇怪的是:cocoapods 已经安装好了:

>which pod                   
/usr/local/bin/pod

无需安装。如前所述,文档没有说明这一点。任何提示或指针。

更新 1:

注意到一些有趣的事情。打电话时fastlane env我得到:

| Key                         | Value                                                                |
| --------------------------- | -------------------------------------------------------------------- |
| Ruby                        | 2.2.4                                                                |

但实际安装的摩擦是:

>ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]

看起来 fastlane 使用了错误的 ruby​​。

标签: ioscocoapodsfastlane

解决方案


推荐阅读