Realm-js: Realm fails to compile when gRPC-Core is also in the project

Created on 9 Jan 2018  路  13Comments  路  Source: realm/realm-js

Goals

I'm seeing compilation errors in object-store files. I'd like to be able to compile my project on iOS.

Expected Results

I expected my project to compile.

Actual Results

I added Firebase to my app via Cocoapods, then got the following errors in Realm:

In file included from /Users/kevboh/my-project/node_modules/realm/react-native/ios/RealmReact/RealmReact.mm:25:
In file included from ../../src/object-store/src/shared_realm.hpp:22:
In file included from ../../src/object-store/src/execution_context_id.hpp:30:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:96:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/chrono:303:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:60:9: error: no member named 'clock' in the global namespace; did you mean 'flock'?
using ::clock;

There are many members it cannot find, including clock as above, plus difftime, mktime, and many more.

Steps to Reproduce

  1. react-native init MyProject
  2. cd MyProject/
  3. yarn add realm
  4. react-native link realm
  5. cd ios/
  6. pod init and add pod 'Firebase/Core' and pod 'Firebase/Firestore' to the Podfile
  7. react-native run-ios

A sample project that is the result of these steps is here: https://github.com/kevboh/RealmFirebaseBugDemo

Version of Realm and Tooling

  • Realm JS SDK Version: 2.1.0
  • Node or React Native: 0.51.0
  • Client OS & Version: macOS 10.13.2, Xcode 9.2
  • Which debugger for React Native: None
T-Help

Most helpful comment

Confirm that remove "$(SRCROOT)/../../../../ios/Pods/Headers/Public/React**" search path on RealmReact working for me

All 13 comments

More details on this鈥攊t seems to happen when I add Firebase to the app via Cocoapods.

I'm fairly certain this line is causing the problem: https://github.com/realm/realm-js/blob/2b8caaa95d16300b1c52e60c835b75f641a12c1f/react-native/ios/RealmReact.xcodeproj/project.pbxproj#L352

Realm is pulling in time.h and string.h header files from gRPC and getting confused. Any idea why that search path is in there when realm-js doesn't use cocoapods?

I see. Removing that line fixes this issue for me. This doesn't seem like a change y'all will want to make, but it's worth flagging in case anyone else sees this in the future.

I wonder if the search path could be changed to only add the headers for the ReactNative pod to the search path, rather than headers for _all_ pods. That seems like it'd avoid picking up headers from unrelated pods while also allowing Realm to find ReactNative's headers when it is integrated via CocoaPods.

That would be great! Maybe "$(SRCROOT)/../../../../ios/Pods/Headers/Public/React**"? I'm not super familiar with the wildcard syntax here.

@kevboh If you have time, a pull request will be appreciated 馃槃

Of course! If I have a moment I'll set up a test project to see if I can get it working. I don't use the react pod, so I'm not 100% sure what the requirements are here.

@kevboh Yeah, getting a test project working is a good first step. Once done, we can see if it is a code or documentation change :smile:

Confirm that remove "$(SRCROOT)/../../../../ios/Pods/Headers/Public/React**" search path on RealmReact working for me

@congnguyen91 worked for me too

To be clear, for anyone stumbling on this like I did, you need to REPLACE the existing header with $(SRCROOT)/../../../../ios/Pods/Headers/Public/React**

you need to REPLACE the existing header

only if you depend on React as a Cocoapod.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmartindivmedianet picture jmartindivmedianet  路  3Comments

camslaz picture camslaz  路  4Comments

laznrbfe picture laznrbfe  路  3Comments

MihaelIsaev picture MihaelIsaev  路  3Comments

max-zu picture max-zu  路  3Comments