在 Mac M1 中安装 pod 时出现“LoadError -dlopen...”

tas*_*csy 4 ruby ios cocoapods flutter apple-m1

我有 Mac M1,在使用 iOS 构建 flutter 项目时遇到以下错误pod install。\n我已经安装了 homebrew,请使用卸载/安装 cocoapodssudo arch -x86_64 gem install cocoapods,但仍然出现错误。\n我可以做些什么来解决这个问题..?

\n
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n...\n
Run Code Online (Sandbox Code Playgroud)\n

的结果flutter doctor -v没有问题。

\n
    [\xe2\x9c\x93] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-arm, locale ja-JP)\n    \xe2\x80\xa2 Flutter version 2.10.2 at /Users/sae/development/flutter\n    \xe2\x80\xa2 Upstream repository https://github.com/flutter/flutter.git\n    \xe2\x80\xa2 Framework revision 097d3313d8 (12 days ago), 2022-02-18 19:33:08 -0600\n    \xe2\x80\xa2 Engine revision a83ed0e5e3\n    \xe2\x80\xa2 Dart version 2.16.1\n    \xe2\x80\xa2 DevTools version 2.9.2\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)\n    \xe2\x80\xa2 Android SDK at /Users/sae/Library/Android/sdk\n    \xe2\x80\xa2 Platform android-32, build-tools 32.1.0-rc1\n    \xe2\x80\xa2 Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)\n    \xe2\x80\xa2 All Android licenses accepted.\n\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 13.2.1)\n    \xe2\x80\xa2 Xcode at /Applications/Xcode.app/Contents/Developer\n    \xe2\x80\xa2 CocoaPods version 1.11.2\n\n[\xe2\x9c\x93] Chrome - develop for the web\n    \xe2\x80\xa2 Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome\n\n[\xe2\x9c\x93] Android Studio (version 2021.1)\n    \xe2\x80\xa2 Android Studio at /Applications/Android Studio.app/Contents\n    \xe2\x80\xa2 Flutter plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/9212-flutter\n    \xe2\x80\xa2 Dart plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/6351-dart\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)\n\n[\xe2\x9c\x93] Connected device (2 available)\n    \xe2\x80\xa2 iPhone 13 (mobile) \xe2\x80\xa2 C2EDE2E3-E820-42C2-B0EC-AFC07C401397 \xe2\x80\xa2 ios            \xe2\x80\xa2 com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)\n    \xe2\x80\xa2 Chrome (web)       \xe2\x80\xa2 chrome                               \xe2\x80\xa2 web-javascript \xe2\x80\xa2 Google Chrome 98.0.4758.109\n\n[\xe2\x9c\x93] HTTP Host Availability\n    \xe2\x80\xa2 All required HTTP hosts are available\n\n\xe2\x80\xa2 No issues found!\n
Run Code Online (Sandbox Code Playgroud)\n

如果您需要更多信息,请发表评论。

\n

小智 14

  1. sudo arch -arm64e gem 安装 cocoapods
  2. sudo arch -arm64e gem install ffi

  • 通过额外的支持信息可以改进您的答案。请[编辑]添加更多详细信息,例如引文或文档,以便其他人可以确认您的答案是正确的。您可以[在帮助中心](/help/how-to-answer)找到有关如何写出好的答案的更多信息。 (2认同)