react-native: pod install error on M1 Macbook
Description
I followed the instructions of https://reactnative.cn/docs/environment-setup but i always occur an error when i run pod install
Looking for related issues on cocoapods/cocoapods...
Searching for inspections failed: undefined method `map' for nil:NilClass
[!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).
[!] - Emulated x86_64 is slower than native arm64
[!] - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)
[!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.
Version
0.71
Output of npx react-native info
System: OS: macOS 13.1 CPU: (8) arm64 Apple M1 Memory: 359.53 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.4.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.3 - /usr/local/bin/npm Watchman: 2023.01.23.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/hai/.rvm/gems/ruby-2.7.6/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 24, 25, 28, 29, 30, 31, 32, 33 Build Tools: 27.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-30 | Google APIs Intel x86 Atom, android-31 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 1.8.0_291 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
brew install cocoapods
sudo arch -x86_64 gem install ffi arch -x86_64 pod install
or
pod install
always occur this
Snack, code example, screenshot, or link to a repository
Stack
CocoaPods : 1.11.3
Ruby : ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin22]
RubyGems : 3.1.6
Host : macOS 13.1 (22C65)
Xcode : 14.2 (14C18)
Git : git version 2.37.1 (Apple Git-137.1)
Ruby lib dir : /Users/hai/.rvm/rubies/ruby-2.7.6/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/
Plugins
cocoapods-deintegrate : 1.0.5
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.1
cocoapods-trunk : 1.6.0
cocoapods-try : 1.2.0
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, min_ios_version_supported
prepare_react_native_project!
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
target 'hello2' do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'hello2Tests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Error
JSON::ParserError - unexpected token at '{
"name": "Flipper",
"version": "0.125.0",
"license": {
"type": "MIT"
},
"homepage": "https://github.com/facebook/flipper",
"summary": "SonarKit core cpp code with network implementation",
"authors": "Facebook",
"source": {
"git": "https://github.com/facebook/flipper.git",
"tag": "v0.125.0"
},
"module_name": "Flipper",
"public_header_files": [
"xplat/Flipper/*.h",
"xplat/utils/*.h"
],
"source_files": [
"xplat/Flipper/*.{h,cpp,m,mm}",
"xplat/Flipper/utils/*.{h,cpp,m,mm}"
],
"libraries": "stdc++",
"dependencies": {
"Flipper-Folly": [
"~> 2.6\n "
],
"Flipper-RSocket": [
"~> 1.4"
]
},
"compiler_flags": "-DFLIPPER_OSS=1 -DFB_SONARKIT_ENABLED=1 -DFOLLY_HAVE_BACKTRACE=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0 -Wall\n -std=c++14\n -Wno-global-constructors",
"platforms": {
"ios": "10.0"
},
"pod_target_xcconfig": {
"USE_HEADERMAP": "NO",
"CLANG_CXX_LANGUAGE_STANDARD": "c++14",
"HEADER_SEARCH_PATHS": "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/Flipper-Boost-iOSX\" \"$(PODS_ROOT)/Flipper-RSocket\" \"$(PODS_ROOT)/Flipper-DoubleConversion\" \"$(PODS_ROOT)/libevent/incl'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/common.rb:216:in `parse'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/common.rb:216:in `parse'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/specification/json.rb:61:in `from_json'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/specification.rb:748:in `from_string'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/specification.rb:722:in `from_file'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/source.rb:188:in `specification'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/resolver/lazy_specification.rb:37:in `specification'
/Users/hai/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/delegate.rb:342:in `block in delegating_block'
/Users/hai/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/delegate.rb:343:in `block in delegating_block'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/resolver.rb:178:in `dependencies_for'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:18:in `block in dependencies_for'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:77:in `with_no_such_dependency_error_handling'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:17:in `dependencies_for'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:809:in `block in group_possibilities'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:808:in `reverse_each'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:808:in `group_possibilities'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:779:in `possibilities_for_requirement'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:761:in `push_state_for_requirements'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:744:in `require_nested_dependencies_for'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:727:in `activate_new_spec'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/resolver.rb:94:in `resolve'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/Users/hai/Desktop/hello2/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/Users/hai/.rvm/gems/ruby-2.7.6/bin/pod:23:in `load'
/Users/hai/.rvm/gems/ruby-2.7.6/bin/pod:23:in `<main>'
/Users/hai/.rvm/gems/ruby-2.7.6/bin/ruby_executable_hooks:22:in `eval'
/Users/hai/.rvm/gems/ruby-2.7.6/bin/ruby_executable_hooks:22:in `<main>'
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don’t forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods… Searching for inspections failed: undefined method `map’ for nil:NilClass
[!] Do not use “pod install” from inside Rosetta2 (x86_64 emulation on arm64).
[!] - Emulated x86_64 is slower than native arm64
[!] - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)
[!] Run “env /usr/bin/arch -arm64 /bin/bash --login” then try again.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
what I try:
arch -arm64 pod install --repo-updatenot work.my
react-native info:it’s confused CocoaPods not found. but I run
which podgot/Users/j/.rbenv/shims/pod.worked for me:
Xcode Version 14.2 (14C18)toXcode Version 14.3.1 (14E300c). this step maybe not key step.gem uninstall cocoapodsbrew install cocoapodscd ios && bundle exec pod install --repo-updateHi @Haiananan, instead of running
pod installcould you runbundle install(you need to run this only once) and thenbundle exec pod installand let us know if this works?piccolo@Piccolos-MacBook-Pro ios % bundle exec pod install warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.12.0/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via “project.ios.sourceDir”. You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md Auto-linking React Native modules for target
AwesomeTSProject1: RNScreens, react-native-nordic-dfu, and react-native-safe-area-context Framework build type is static library [Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json Analyzing dependencies [Codegen] Found FBReactNativeSpec――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Command
Report
What did you do?
What did you expect to happen?
What happened instead?
Stack
Plugins
Podfile
Error
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=dlopen(%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%2C+0x0009)%3A+tried%3A+'%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle'+(mach-o+file+(%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle)%2C+but+incompatible+platform+(have+'iOS'%2C+need+'macOS'))%2C+'%2FSystem%2FVolumes%2FPreboot%2FCryptexes%2FOS%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle'+(no+such+file)%2C+'%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle'+(mach-o+file+(%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle)%2C+but+incompatible+platform+(have+'iOS'%2C+need+'macOS'))+-+%2FUsers%2Fpiccolo%2FFiles%2FPiccolo%2FSelfApp%2FRN%2FAwesomeTSProject1%2Fvendor%2Fbundle%2Fruby%2F2.7.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle&type=Issues
If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don’t forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods… Searching for inspections failed: undefined method `map’ for nil:NilClass piccolo@Piccolos-MacBook-Pro ios %
Hi 😃, Didn’t work for me. What’s the problem? 😦