Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating New Build Configuration Results in Header Not Found Error

In Xcode I have created a new Staging build configuration. I duplicated the Release configuration to make it. Both the Release and the Debug configurations build just fine. When I select the Staging config I end up with header issues. I have checked in the build settings to ensure that all three configs have the same header search paths.

As an important side note, the issues are popping up between a couple libraries I have that are referencing each other.

To be specific I am using a library called CodePush that references the React library like this:

#if __has_include("RCTEventEmitter.h")
    #import "RCTEventEmitter.h"
#else
    #import "React/RCTEventEmitter.h"
#endif 

Which the RCTEventEmitter.h file in tern states #import <React/RCTBridge.h> and it is with the RCTBridge file that the header file not found is coming from.

I am using react native 0.40 and react-native-code-push 1.16.1-beta.

Any thoughts as to what could be causing the issue. Please let me know if you need any more info and I will gladly provide. I would like to mention that I do not believe this to be an issue with the libraries but rather my set up. I suspect this is just the first library that the compiler hits.

like image 535
Osman Avatar asked Jan 16 '17 20:01

Osman


1 Answers

The issue is with the way RN 0.40 handles headers. React only knows about Release and Debug, so you have to add the Release headers path to your staging configuration and make sure React is built first as a dependency.

Scheme:

  • Go to Product->Scheme->Manage Schemes.
  • Double click your scheme. In my case I made a staging scheme and set build configuration to Staging in the Run section.
  • Then in the Build section, make sure Parallelize Build is off
  • Make sure the React build target is in the list of targets. If not, hit the + button, add it, and drag it to the top. Then hit Close.

Target Dependencies:

  • Now select your target in the navigator, go to Build Phases, and under Target Dependencies add React. This ensures XCode builds React before the rest of the project.

Header Path:

  • Select your target in the navigator, go to Build Settings.
  • Click the +, add the user-defined setting REACT_HEADERS_PATH and set the value to $(BUILD_DIR)/Release-$(PLATFORM_NAME)/include. It should resolve to something like build/Release-iphoneos/include
  • Then still in Build Settings, scroll up to Header Search Paths and add $(REACT_HEADERS_PATH) to the list for the Staging configuration only.

Now Clean and Build...

I found this solution here on Github after struggling for 2 days. All credit goes to the author of that comment.

like image 105
Julian Mann Avatar answered Sep 28 '22 01:09

Julian Mann