Ziqi (Katrina) Ding

Back

Context#

  • Upgrading React Native 0.72 → 0.76
  • Building for iOS Simulator using Xcode 16.4
  • Running pod install with CocoaPods

Error Log#

During pod install

...
Generating Pods project
[!] An error occurred while processing the post-install hook of the Podfile.

undefined local variable or method 'config' for an instance of Pod::Podfile

*********************/ios/Podfile:66:in 'block (2 levels) in Pod::Podfile.from_ruby'
...
sh

Notes

  • The key line is: undefined local variable or method 'config'.
  • The stack points to Podfile:66, inside the post-install hook.
  • Likely cause: config is out of scope in post_install.

Root Cause#

The first line mentions that the issue was in Podfile line 66,

*********************/ios/Podfile:66:in 'block (2 levels) in Pod::Podfile.from_ruby'
plaintext

where in my case was

react_native_post_install(
	installer,
	config[:reactNativePath],  # <-- Here
	:mac_catalyst_enabled => false,
	# :ccache_enabled => true
)
ruby

The error undefined local variable or method 'config'... indicates that the variable reactNativePath was not found in config.

Since config is defined in target '<AppName>' block, maybe the code that referencing config[:reactNativePath] is placed outside of the target block, causing that config is out of scope, and hence CocoaPods can’t see config[:reactNativePath]

The Fix#

Move the code inside target block, or don’t reference config in post_install. Pass the RN path directly (or declare a constant at the top).

  1. Add this near the top:
    react_native_path = File.join(__dir__, '..', 'node_modules', 'react-native')
    ruby
  2. Then change your post_install call to:
     react_native_post_install(
        installer,
        react_native_path,                  # <- use the constant
        :mac_catalyst_enabled => false
      )
    ruby

Summary#

This error occurs because config is defined inside the target block but referenced in post_install, where it’s out of scope. The solution is simple: define the React Native path as a constant at the top of your Podfile instead of relying on the scoped config variable.

References#

Fix: undefined local variable or method 'config' for Podfile in React Native
https://katrina-ziqi-ding.com/blog/podfile-config-error-undefined-local-variable
Author Ziqi (Katrina) Ding
Published at 07-08-2025
Comment seems to stuck. Try to refresh?✨