4

I'm getting this linker error using CocoaPods with React Native: ld: library not found for -lReact

I have followed the guide at https://facebook.github.io/react-native/docs/embedded-app-ios.html#content

I am trying to integrate with an existing iOS project, which is a JUCE C++ project. JUCE generates the Xcode project file so I believe I need to use the Cocoapods method.

The steps I'm doing are:

  • create or save iOS build from Introjucer project
  • run npm install react-native from root of project (alongside the .jucer file)
  • create Podfile in Builds/iOS as per the guide (but with ../../node_modules as the path)
  • run pod install
  • open workspace in Xcode
  • adjust GCC_PREPROCESSOR_DEFINITIONS to include $(inherited)
  • build

An example project displaying this issue is at https://github.com/adamski/juce-native-navigation/tree/react-native-cocoapods

I think there is something going on with the Introjucer generated project, as I tried the whole process on a fresh new Xcode project and it builds fine.

I have also tried adding libReact.a to the 'Link Binary With Libraries' section but that does not seem to have helped.

Adamski
  • 3,585
  • 5
  • 42
  • 78

4 Answers4

4

I looked for differences between the Introjucer generated project and the Xcode generated one.

One significant difference was the CONFIGURATION_BUILD_DIR or "Per-configuration Build Products Path"

I copied over the setting from the Xcode generated project $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

This allowed the linking to complete and gave a successful build :)

Adamski
  • 3,585
  • 5
  • 42
  • 78
  • 1
    i am having the same problem but not with this package...im curious if you could describe where you copied the `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` to? – ewizard Sep 17 '18 at 13:37
  • @ewizard in Binary Location – Adamski Sep 17 '18 at 13:39
  • you mean just in `build settings -> per configuration Build Products Path`, if so mine already says that :( – ewizard Sep 17 '18 at 13:45
  • actually i think it might be looking for a react pod instead of at my node_modules/react-native folder because I search for CONFIGURATION_BUILD_DIR and I see alot of ${PODS_CONFIGURATION_BUILD_DIR}/React in `React.xcconfig` file - should i change this to point to node_modules folder? – ewizard Sep 17 '18 at 13:50
4

Go to your Project -> Your Target -> Build Phases -> Link Binary With Libraries and you might see some red entries there referring to the React library files here. Just remove those red entries and you should be good to go.

If there are no red entries, then just check that the list of libs in Link Binary With Libraries list has no items which you removed from React project using 'npm uninstall lib_name' command.

Filipp Ignatov
  • 141
  • 1
  • 8
1

Some steps may not be necessary and bring concerns of other, larger issues being hidden. Specifically:

adjust GCC_PREPROCESSOR_DEFINITIONS to include $(inherited)

Namely, pod install scripts are supposed to do the $(inherited) magic for you.

Could a configuration reset be of help?

Community
  • 1
  • 1
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • Thanks, I followed the suggestions, remove configurations from the generated workspace (the original project had none set). I still get the linker error. – Adamski Jan 15 '16 at 21:22
  • Also to add that step did get rid of the warning about `GCC_PREPROCESSOR_DEFINITIONS` – Adamski Jan 15 '16 at 21:34
0

Go to your Project -> Your Target -> Build Settings -> Link Binary With Libraries and you might see some red entries there referring to the React library files here. Just remove those red entries and you should be good to go.

NSKevin
  • 564
  • 8
  • 20
  • I got this error after I removed some third party libraries from my react-native project and did a clean rebuild in Xcode. Deleting these entries as well as the associated libraries solved the problem. – Logister Jan 02 '17 at 19:40