realm-js: Missing Realm constructor or duplicated symbols
Goals
Using Realm normally
Expected Results
Actual Results
after install Realm and pod install, app will launch with error Missing Realm constructor. After research through github, I found that we should link libRealmReact.a to Link binary with libraries. But after linked, app throw error that 155 duplicate symbols for architecture x86_64.
Steps to Reproduce
react-native init exampleProject yarn add realm cd ios && pod install
Code Sample
import Realm from 'realm
Version of Realm and Tooling
- Realm JS SDK Version: 3.5.0
- Node or React Native: node 10.15.3 RN 0.61.2
- Client OS & Version: Mac OSX Catalina 10.15.1 Xcode 11.2.1
- Which debugger for React Native: None
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 41 (13 by maintainers)
I found the solution:
iosfolder from existed project, and replace by theiosfolder which is created from the new one.node_modulesandyarn.lock/package-lock.jsonPodfileiosfolder dont includesPods/and Podfile.lockHope my workaround could help who are got stuck on running existed project with realm 😃
“react-native”: “0.61.2”, “realm”: “^3.5.0”,
If run
$ react-native run-ios- its okIf run project in xCode to simmulator - Error: Missing Realm constructor. Did you run “pod install”? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting
If remove folder
ios/buildand again run project in xCode - again Error “Missing Realm constructor” and folderios/buildis emptyUPD: Go to xCode menu
Product -> Clean Build Folder- Yesssss YO!Its work
I have this problem too, I upgrade Realm 3.2.0 to Realm 10.2.0 due to iOS 14.5 beta crash, but always encounter this missing Realm constructor issue, this really drive me to crazy, I have tried all the ways I could think of and read all the solutions above, still cannot resolve this. I’m really upset about this, this issue keeps showing up to developers but still cannot be resolved totally, I decide to remove this entirely from my project and never use it again!
I spent 2 hours on this, and this fixed my problem. Be sure to tap options to make Clean -> Clean Build Folder
@hauhuynh1208 I do encounter the bug.
We believe it is a
yarnissue, and we are working on a solution (see #2623). When you doyarn add redux, thenode_modules/realmfolder is reset, and the header and binary files you need, are deleted!Currently, two workarounds are possible: use
npminstead ofyarnor add the line"postinstall": "node node_modules/realm/scripts/download-realm.js ios --sync"to thescriptssection in yourpackage.json(see https://github.com/realm/realm-js/issues/2617#issuecomment-559446483).@kneth I think I found the way how you can reproduce the bug. First of all, init the fresh project. Then install realm, make sure app is running properly. Then you install any packages (such as redux, react-native-maps …). Then bug occurs
I sure you will encounter this bug 😃
@kneth I created a new project and also added
realm, it is working normally. However, my pre-existing project still throw error. I confirm that my pre-existing project used to run normally and I didn’t update any packages. How can I share my pre-existing project (private project) so you can take a look?