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:
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
Podsdirectory >Headers/Public/React-Core - If
config.his nowhere to be seen, create a new header file namedconfig.hand 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/Podfileand 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-updateto pull fresh, compatible dependencies. - Close Xcode completely, reopen the
.xcworkspacefile, 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 Datato 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 ejectagain, follow the prompts carefully - Immediately after ejecting, run
pod installin the ios directory - Open the
.xcworkspaceand 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

