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)

Most upvoted comments

I found the solution:

  1. create a new project with the same name as your existed project
  2. removeios folder from existed project, and replace by the ios folder which is created from the new one.
  3. remove node_modules and yarn.lock/package-lock.json
  4. Add pod link if needed in Podfile
  5. Make sure your ios folder dont includes Pods/ and Podfile.lock
  6. yarn add realm
  7. cd ios/ && pod install && cd …/
  8. yarn start && yarn run ios

Hope 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 ok

If 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/build and again run project in xCode - again Error “Missing Realm constructor” and folder ios/build is empty

UPD: 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!

“react-native”: “0.61.2”, “realm”: “^3.5.0”,

If run $ react-native run-ios - its ok

If 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/build and again run project in xCode - again Error “Missing Realm constructor” and folder ios/build is empty

UPD: Go to xCode menu Product -> Clean Build Folder - Yesssss YO! Its work

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 yarn issue, and we are working on a solution (see #2623). When you do yarn add redux, the node_modules/realm folder is reset, and the header and binary files you need, are deleted!

Currently, two workarounds are possible: use npm instead of yarn or add the line "postinstall": "node node_modules/realm/scripts/download-realm.js ios --sync" to the scripts section in your package.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

react-native init example
cd example/
yarn add realm
cd ios/ && pod install
cd ../
yarn add redux

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?