Apple Silicon (M1) 上的 React Native pod 安装失败

Ale*_*hef 13 cocoapods react-native apple-silicon apple-m1

我购买了配备 M1 芯片的新 Macbook Pro。

\n

我尝试运行我的 React Native 项目,但卡在pod install 上。

\n

之后,我创建了一个空项目并尝试仍然遇到相同的错误。

\n
### Command\n\n```\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod install\n```\n\n### Report\n\n* What did you do?\n\n* What did you expect to happen?\n\n* What happened instead?\n\n\n### Stack\n\n```\n   CocoaPods : 1.10.1\n        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]\n    RubyGems : 3.0.3\n        Host : macOS 11.0.1 (20B29)\n       Xcode : 12.4 (12D4e)\n         Git : git version 2.24.3 (Apple Git-128)\nRuby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib\nRepositories : \n```\n\n### Plugins\n\n```\ncocoapods-deintegrate : 1.0.4\ncocoapods-plugins     : 1.0.0\ncocoapods-search      : 1.0.0\ncocoapods-trunk       : 1.5.0\ncocoapods-try         : 1.2.0\n```\n\n### Podfile\n\n```ruby\nrequire_relative '../node_modules/react-native/scripts/react_native_pods'\nrequire_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'\n\nplatform :ios, '10.0'\n\ntarget 'temp2' do\n  config = use_native_modules!\n\n  use_react_native!(:path => config["reactNativePath"])\n\n  target 'temp2Tests' do\n    inherit! :complete\n    # Pods for testing\n  end\n\n  # Enables Flipper.\n  #\n  # Note that if you have use_frameworks! enabled, Flipper will not work and\n  # you should disable these next few lines.\n  use_flipper!\n  post_install do |installer|\n    flipper_post_install(installer)\n  end\nend\n\ntarget 'temp2-tvOS' do\n  # Pods for temp2-tvOS\n\n  target 'temp2-tvOSTests' do\n    inherit! :search_paths\n    # Pods for testing\n  end\nend\n```\n\n### Error\n\n```\nLoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/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/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'\n/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'\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/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'\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/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'\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/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `map'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:177:in `sources'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'\n/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `load'\n/opt/homebrew/Cellar/cocoapods/1.10.1/libexec/bin/pod:23:in `<main>'\n```\n\n\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95 TEMPLATE END \xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\xe2\x80\x95\n\n[!] Oh no, an error occurred.\n\nSearch for existing GitHub issues similar to yours:\nhttps://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+missing+compatible+arch+in+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues\n\nIf none exists, create a ticket, with the template displayed above, on:\nhttps://github.com/CocoaPods/CocoaPods/issues/new\n\nBe sure to first read the contributing guide for details on how to properly submit a ticket:\nhttps://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md\n\nDon't forget to anonymize any private data!\n\nLooking for related issues on cocoapods/cocoapods...\n - Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: Invalid ABI specified\n   https://github.com/CocoaPods/CocoaPods/issues/10368 [open] [2 comments]\n   a week ago\n\n - CocoaPods compatibility with Apple DTK (Apple Silicon)\n   https://github.com/CocoaPods/CocoaPods/issues/9907 [open] [75 comments]\n   15 hours ago\n\n - Firebase installation error on xcode 12 com m1 processor\n   https://github.com/CocoaPods/CocoaPods/issues/10329 [closed] [4 comments]\n   12 hours ago\n\nand 3 more at:\nhttps://github.com/cocoapods/cocoapods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%2C%200x0009%29%3A%20missing%20compatible%20arch%20in%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle%20-%20%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues&utf8=\xe2\x9c\x93\n
Run Code Online (Sandbox Code Playgroud)\n

在我对这个主题进行研究后,我找到了几种解决方案,但我的问题仍然没有解决。

\n

我已经尝试安装

\n
sudo gem install ffi\n
Run Code Online (Sandbox Code Playgroud)\n

然后再次尝试pod install。仍然遇到同样的错误。

\n

之后,根据我的研究,有人说使用带有 Rosetta 的终端或 Rosetta 的另一种方式,

\n
sudo arch -x86_64 gem install ffi\narch -x86_64 pod install\n
Run Code Online (Sandbox Code Playgroud)\n

使用这些基于英特尔的安装尝试我收到以下错误:

\n
Analyzing dependencies\nFetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`\nFetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`\nFetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`\n[!] Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: Invalid ABI specified\n
Run Code Online (Sandbox Code Playgroud)\n

有人遇到过这个问题吗?我做错了什么或者我需要做什么才能运行我的项目?

\n

Sye*_*Ali 13

对于自制用户

步骤 1brew install cocoapods 步骤 2sudo arch -x86_64 gem install ffi 步骤 3arch -x86_64 pod install

解决了我的问题


小智 10

我的 ffi 问题只需brew install cocoapods=)就解决了

首先我尝试安装bundler,有一个特定的旧版本的cocoapods还不支持m1;然后我用了brew,现在用最新的cocoapods它工作得很好


Ale*_*hef 2

我意识到自制安装弄乱了 cocoapods。

简单地说,我卸载了自制程序并从头开始。然后就成功了。