You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo ejected的React Native项目Xcode编译报错:config.h未找到

Hey there, sorry to hear you're stuck with the config.h not found error after ejecting your Expo project—let's work through this together. I've dealt with similar headaches before, so here are some targeted fixes that often resolve this, even if you've tried generic forum solutions already:

Fixes for "config.h not found" After Expo Eject & Pod Install

1. Manually generate the missing config.h file

Sometimes the file gets skipped during the eject/pod install pipeline. Here's how to create it from scratch:

  • Open your iOS project in Xcode, navigate to the Pods directory > Headers/Public/React-Core
  • If config.h is nowhere to be seen, create a new header file named config.h and paste this basic boilerplate:
#ifndef config_h
#define config_h

#define RCT_DEBUG 1
#define RCT_PROFILE 0
#define RCT_ENABLE_INSPECTOR 1
#define RCT_DEV 1

#endif /* config_h */
  • Clean your project (Cmd+Shift+K) and rebuild right after.

2. Refresh your Podfile & re-run pod install

Expo eject can leave outdated or misconfigured Pod settings. Let's reset this:

  • Open your ios/Podfile and double-check your React dependencies match your Expo SDK version. For example, if you're on SDK 49, ensure you have lines like:
pod 'React', :path => '../node_modules/react-native/', :subspecs => [
  'Core',
  'RCTNetwork',
  'RCTText',
  # add other subspecs your project uses
]
pod 'React-Core', :path => '../node_modules/react-native/React'
  • Delete the stale Pod files:
rm -rf Pods Podfile.lock
  • Run pod install --repo-update to pull fresh, compatible dependencies.
  • Close Xcode completely, reopen the .xcworkspace file, clean and rebuild.

3. Fix Xcode's Header Search Paths

Incorrect search paths are one of the most common causes for this error:

  • Select your project in Xcode's navigator, switch to the Build Settings tab.
  • Search for Header Search Paths.
  • Make sure these paths are present (adjust the node_modules path if your project structure is different):
    • $(SRCROOT)/../node_modules/react-native/React (mark as recursive)
    • $(SRCROOT)/Pods/Headers/Public/React-Core (mark as non-recursive)
  • Add any missing paths, then clean and rebuild your project.

4. Wipe Xcode's build cache

Xcode's cache can hold onto broken, outdated references that cause weird errors like this:

  • Go to Xcode > Preferences > Locations
  • Click the arrow next to Derived Data to open the folder
  • Delete the folder associated with your project
  • Also, delete the local build folder in your ios directory:
rm -rf build
  • Reopen Xcode, clean, and try building again.

5. Re-eject your Expo project (as a last resort)

Sometimes the eject process doesn't complete fully, leaving behind broken project files. Make sure you have a backup first, then:

  • Run expo eject again, follow the prompts carefully
  • Immediately after ejecting, run pod install in the ios directory
  • Open the .xcworkspace and try building once more

Most cases get fixed with steps 2 or 3—give those a priority if you haven’t already. If none of these work, double-check that your Expo SDK and React Native versions are fully compatible, as mismatches can trigger odd build failures like this.


内容的提问来源于stack exchange,提问作者Janis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:34:57