简体   繁体   中英

React Native - Error during post install hook for Podfile

I am brand new to iOS React Native apps, so this may be a super simple fix, but after the version of React Native has been upgraded, the Podfile shown below is crashing with the error below.

The error is undefined method 'real_path' for nil:NilClass

Version of Cocoapods if 1.11.3 Version of Node is 14.17.3 Version of NPM is 6.14.13

Error is:-

ios % pod install
Auto-linking React Native modules for target `MYAPP`: RNCAsyncStorage, RNCCheckbox, RNCMaskedView, RNDateTimePicker, RNDeviceInfo, RNGestureHandler, RNLocalize, RNSVG, RNScreens, RNVectorIcons, react-native-config, react-native-image-picker, react-native-netinfo, react-native-safe-area-context, react-native-version-check, and rn-fetch-blob
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Downloading dependencies
… installs packages here successfully
Generating Pods project
[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `real_path' for nil:NilClass

/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object/container_item_proxy.rb:96:in `container_portal_annotation'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object/container_item_proxy.rb:105:in `to_hash_as'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:421:in `to_ascii_plist'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:298:in `block in to_ascii_plist'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:296:in `each'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:296:in `to_ascii_plist'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:365:in `block in save'
/Library/Ruby/Gems/2.6.0/gems/atomos-0.1.3/lib/atomos.rb:21:in `block in atomic_write'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tempfile.rb:295:in `open'
/Library/Ruby/Gems/2.6.0/gems/atomos-0.1.3/lib/atomos.rb:17:in `atomic_write'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:364:in `save'
/Users/MyUser/dev/MYAPPV2/node_modules/react-native/scripts/cocoapods/utils.rb:71:in `block in exclude_i386_architecture_while_using_hermes'
/Users/MyUser/dev/MYAPPV2/node_modules/react-native/scripts/cocoapods/utils.rb:66:in `each'
/Users/MyUser/dev/MYAPPV2/node_modules/react-native/scripts/cocoapods/utils.rb:66:in `exclude_i386_architecture_while_using_hermes'
/Users/MyUser/dev/MYAPPV2/node_modules/react-native/scripts/react_native_pods.rb:161:in `react_native_post_install'
/Users/MyUser/dev/MYAPPV2/ios/Podfile:17:in `block (3 levels) in from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:945:in `run_podfile_post_install_hook'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:933:in `block in run_podfile_post_install_hooks'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:149:in `message'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:932:in `run_podfile_post_install_hooks'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:331:in `block (2 levels) in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:330:in `block in create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:309:in     `create_and_save_projects'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:301:in `generate_pods_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:180:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:167:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/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.11.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

[!] `<PBXGroup name=`Libraries` UUID=`832341AE1AAA6A7D00B99B32`>` attempted to initialize an object with an unknown UUID. `65A7A9B869DB4D1CB5659E12` for attribute: `children`. This can be the result of a merge and the unknown UUID is being discarded.

[!] `<PBXProject name=`MYAPP` UUID=`83CBB9F71A601CBA00E9B192`>` attempted to initialize an object with an unknown UUID. `65A7A9B869DB4D1CB5659E12` for attribute: `project_references`. This can be the result of a merge and the unknown UUID is being discarded.

Podfile is:-

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
target 'MyApp' do
      config = use_native_modules!
      use_react_native!(
        :path => config[:reactNativePath],
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    :flipper_configuration => FlipperConfiguration.enabled,
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  pod 'RNSVG', :path => '../node_modules/react-native-svg'
  pod 'CocoaAsyncSocket'
  post_install do |installer|
    react_native_post_install(installer, :mac_catalyst_enabled => false)
        __apply_Xcode_12_5_M1_post_install_workaround(installer)
          installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
          config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
          end
      end
  end
end

Not sure if this helps, but I ran into a couple of similar issues and finally installed cocoapods 1.11.3 via homebrew ( brew install cocoapods ) on macOS 13.0.1. Cocoapods recommends to use the default macOS ruby but this wasn't very stable for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM