【问题标题】:Issue installing cocoapods for Flutter on MacOS在 MacOS 上为 Flutter 安装 cocoapods 时出现问题
【发布时间】:2021-04-12 09:24:46
【问题描述】:

最初,我尝试安装 Ruby 而不是在 MacOS 上使用 on 并使用 gem install cocoapods 安装 cocoapods 但这不起作用并给出错误:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

还尝试了sudo gem install -n /usr/local/bin cocoapods,它给出了错误:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf60240306-20262-1w4q438.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.
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

对于 Ruby,我使用的是版本:ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19] 当我尝试使用sudo gem update --system 更新系统时,它显示“已安装最新版本。完成。”

然后我下载了 Homebrew 并尝试安装 cocoapods 但我再次遇到错误

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/xcodeproj
Target /usr/local/bin/xcodeproj
already exists. You may want to remove it:
  rm '/usr/local/bin/xcodeproj'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/xcodeproj

然后,在遵循有关另一个 stackoverflow 答案的建议后,我使用了brew link --overwrite cocoapods。但是,现在 XCode 出现问题,iPhone 设备模拟器无法连接 - 显示没有设备。

我在构建期间收到此错误:

Showing Recent Messages
/Users/Developer/honours/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths

我不太确定如何解决这个问题,非常感谢任何帮助!

【问题讨论】:

  • FWIW。推荐的方法是使用gem 而不是homebrew 安装cocoapods。见herehere
  • @Honey 啊,是的,我读了这两本书,但不明白为什么它不能用 ruby​​ 安装,所以试图找到另一种方法......
  • 对不起,我没有自制软件的经验。如果您使用 gem 提出新问题,那么也许我可以提供帮助。但也总是好的 1. 链接您获得用于安装的步骤 2. 链接您用来修复您面临的错误的答案。有时,经验丰富的开发人员只是重新阅读它并意识到即使他们甚至没有使用 homebrew/gem 也错过了哪一步。 atm 您有 2 个错误“您没有写入权限”和“错误:brew link 步骤未成功完成”因此请具体说明您用于解决哪个错误的链接
  • 嗨@Honey 感谢您的建议!我更新了我的问题,以解释更多关于我使用 gem 所做的事情,但我还没有解决任何错误
  • 系统 ruby​​ 太旧,无法正确安装 cocoapods。您需要使用 brew(或 macports)安装 ruby​​,然后 that ruby​​(注意您的路径!)“gem install cocoapods”

标签: ruby xcode flutter cocoapods homebrew


【解决方案1】:

使用 this website 解决了我的问题,第 4 步非常有用!然后我通过使用this answer 中的flutter build ios 解决了Xcode 无法找到xcconfig 文件的问题。通过运行 flutter build,它告诉我问题出在哪里以及如何解决它 - 我需要更改默认签名标识符。

【讨论】:

猜你喜欢
  • 2021-06-09
  • 2021-07-29
  • 2018-08-04
  • 1970-01-01
  • 1970-01-01
  • 2020-12-18
  • 1970-01-01
  • 1970-01-01
  • 2022-08-12
相关资源
最近更新 更多