如何解决在 macOS Big sur
我对 macOS 还是很陌生,最近从 Windows 转向 macOS,我开始研究 react-native 应用程序,当我尝试 react-native run-ios
时,它给了我以下错误
error Could not find "Podfile.lock" at /Users/saniranimantha/Documents/Learning/albums/ios/Podfile.lock. Did you run "pod install" in iOS directory?
info Found Xcode project "albums.xcodeproj"
info Launching iPhone 11 (iOS 14.3)
info Building (using "xcodebuild -project albums.xcodeproj -configuration Debug -scheme albums -destination id=FE71292F-36FA-4226-A8E5-B4EF4E8B625D")
(node:726) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further,consider building your app with Xcode.app,by opening albums.xcodeproj. Run CLI with --verbose flag for more details.
当我搜索这个错误的原因时,我发现我需要运行 pod install
命令,当我尝试时,它给了我另一个错误。我尝试了 stack-overflow & git 的几个建议,但仍然没有运气。我确实安装了 cocoapod
。我搜索了类似的问题,但找不到任何内容。这就是为什么我决定将其发布在这里以获得答案。如果有人能在这里帮助我,那就太好了。
我的操作系统是 macOS Big Sur (v11.1)
这是我的 podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios,'10.0'
target 'albums' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'albumsTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled,Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'albums-tvOS' do
# Pods for albums-tvOS
target 'albums-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
这是我在 pod install
上遇到的错误
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
### Command
```
/usr/local/bin/pod install
```
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
CocoaPods : 1.10.0
Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]
RubyGems : 3.0.3
Host : macOS 11.1 (20C69)
Xcode : 12.3 (12C33)
Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories :
```
### Plugins
```
cocoapods-deintegrate : 1.0.4
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-trunk : 1.5.0
cocoapods-try : 1.2.0
```
### Podfile
```ruby
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios,Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'albums-tvOS' do
# Pods for albums-tvOS
target 'albums-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
```
### Error
```
LoadError - 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
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
编辑
对于一个 react-native 项目(新创建的)@Leri Gogsadze 的回答是有效的。我克隆了一个已经开发的 react-native 应用程序的存储库,并且遇到了同样的问题,在那个项目中,我尝试了@Leri 建议的解决方案,但没有成功 react-native run-ios
构建失败,然后我尝试了 {{1 }} 命令,它现在给了我以下错误。
pod update
解决方法
似乎与Ruby ffi有关。运行以下命令:
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
在 Apple Silicon 和 MacOS Big Sur 上,我以这种方式修复了它并且它有效
- 在 Finder 中找到 Terminal.app
- 右键单击并选择获取信息
- 检查使用 Rosetta 打开
- 退出终端应用程序并再次运行
- 运行 sudo gem install ffi
- 运行 pod install
sudo arch -x86_64 gem install ffi
然后
arch -x86_64 pod install
这适用于 Apple M1 芯片。已确认。
,对我来说,有效的是重新克隆存储库并重新开始。
您也可以尝试更新 cocoapods,最后一个 case 也更新 Xcode 并重新克隆 repo。
目前 Pod、库、依赖项和 Xcode 不匹配,例如您也使用的 Firebase SDK 经常更新。
我的设置: Xcode 12.4 麦克M1 反应原生 63.4
,自制软件用户
步骤 1 brew install cocoapods
第 2 步 sudo arch -x86_64 gem install ffi
第 3 步 arch -x86_64 pod install
解决了我的问题
如果问题仍然存在,您可能已经使用其他平台而不是自制软件安装了 node.js
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。