Reputation: 15845
Keep getting the Missing Realm Constructor error and have tried everything from the Realm documentation on this common issue to relinking with rnpm link realm
which tells me they're already linked. I've also tried linking in Xcode by adding in the libRealmReact.a
file manually, but all to no avail.
Upvotes: 2
Views: 4511
Reputation: 1580
For now, you can add this line in your Pod file:-
pod 'RealmJS', :path => '../node_modules/realm' pod 'GCDWebServer'
Upvotes: -1
Reputation: 3393
For me following steps worked, here version of realm npm played major role -
step1
npm install --save [email protected]
react-native link realm
step2 : Run(build) XCode project target named 'RealmReact'
step3 : Link binary with library for your project, add framework named 'libRealmReact.a'
That's all if the above steps didn't work, try to delete test target of RealmReact.xcodeproj
your xcode project->Libraries->RealmReact.xcproject->Test target for this linked project
Upvotes: 0
Reputation: 15845
After a few long hours of debugging and going through GitHub issue articles (and posting one of my own), I found this article where the solution is to set the Realm variable as null for load, but to define the variable in the constructor as so:
const Realm = null;
constructor() {
if (Realm === null) { Realm = require('realm'); };
}
The issue is that there is some sort of timing issue where Realm doesn't load before the view itself instantiates.
Upvotes: 3