Skip to content

Missing Realm constructor or duplicated symbols #2634

Closed
@hauhuynh1208

Description

@hauhuynh1208

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

Activity

hauhuynh1208

hauhuynh1208 commented on Dec 4, 2019

@hauhuynh1208
Author

Confirm that only iOS platform experience this bug, Android still work properly.

kneth

kneth commented on Dec 4, 2019

@kneth
Contributor

I haven't been able to reproduce it. I am using Realm JS v3.5.0 and React Native v0.61.2 but on macOS v10.14.6 and Xcode 11.0 (build version 11A420a).

gangwarily

gangwarily commented on Dec 4, 2019

@gangwarily

Running into this same issue on a pre-existing project that was previously using Realm JS v2.29.2. On macOS v10.4.6, RN v.0.61.2 and Xcode 11.2.1.

hauhuynh1208

hauhuynh1208 commented on Dec 5, 2019

@hauhuynh1208
Author

@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?

hauhuynh1208

hauhuynh1208 commented on Dec 5, 2019

@hauhuynh1208
Author

@gangwarily After I added all the packages from pre-existing project to the new one, my new project ran into the same issue as the existed project. Let's compare to see which packages we have the same

"@react-native-community/geolocation": "^2.0.2",
        "@react-native-community/netinfo": "^4.4.0",
        "events": "^3.0.0",
        "formatcoords": "^1.1.3",
        "geolib": "^3.0.4",
        "lodash": "^4.17.15",
        "moment": "^2.24.0",
        "native-base": "^2.13.8",
        "prop-types": "^15.7.2",
        "react": "16.9.0",
        "react-native": "0.61.5",
        "react-native-datepicker": "^1.7.2",
        "react-native-device-info": "^4.0.1",
        "react-native-geolocation-service": "^3.1.0",
        "react-native-gesture-handler": "^1.4.1",
        "react-native-image-picker": "^1.1.0",
        "react-native-location": "^2.5.0",
        "react-native-maps": "0.25.0",
        "react-native-modal": "^11.1.0",
        "react-native-reanimated": "^1.2.0",
        "react-native-screens": "^1.0.0-alpha.23",
        "react-native-share": "^2.0.0",
        "react-native-svg": "^9.11.1",
        "react-native-tab-view": "^2.9.0",
        "react-native-uuid": "^1.4.9",
        "react-native-vector-icons": "^6.6.0",
        "react-navigation": "^4.0.10",
        "react-navigation-drawer": "^2.2.2",
        "react-navigation-stack": "^1.9.4",
        "react-redux": "^7.1.0",
        "realm": "^3.5.0",
        "redux": "^4.0.4",
        "redux-thunk": "^2.3.0",
        "rn-fetch-blob": "^0.11.2",
        "victory-native": "^33.0.0"
kneth

kneth commented on Dec 5, 2019

@kneth
Contributor

@hauhuynh1208 You can send it to help--at--realm.io and mention that it is for me. Eventually I will get it 😄.

hauhuynh1208

hauhuynh1208 commented on Dec 5, 2019

@hauhuynh1208
Author

@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

kneth commented on Dec 6, 2019

@kneth
Contributor

@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 #2617 (comment)).

gangwarily

gangwarily commented on Dec 6, 2019

@gangwarily

@kneth, I'm using npm and running into the same issue. Not sure if there are multiple causes for this :/

hauhuynh1208

hauhuynh1208 commented on Dec 6, 2019

@hauhuynh1208
Author

@kneth I have tried postinstall solution before, and it still fail. And I just tried npm, but still no luck. Did you do these solutions successfully?
P/s for my existed project, when I do postinstall ..., the error that xcode cannot find realm has been passed. But I continue to fall in the problem I described in this thread title.

kraenhansen

kraenhansen commented on Dec 6, 2019

@kraenhansen
Member

What happens if you run pod install as the last step before react-native run-ios?

esutton

esutton commented on Dec 6, 2019

@esutton

@hauhuynh1208 Search your ios/YourProject.xcodeproj for "realm". Mine had dozens of realm entries.

I think this may be a problem when upgrading existing projects. Not sure how best to solve.

Option A
This is what I did.

  1. react-native unlink realm
  2. yarn remove realm
  3. Manually remove all the realm lines from ios/YourProject.xcodeproj
  4. yarn add realm

Option B
This might help understand what realm is trying to do. ( Not sure if it is correct or not )

  1. Create a new Awesome project and add realm
  2. Compare the new ios/Awesome.xcodeproj to your project and copy realm related lines

I ended up rolling back to "realm": "^3.2.0" and manually adding and linking the realm project in xcode.

I spent so much time on this trying so many things. I and not sure what finally sorted things out.

File: react-native.config.js

module.exports = {
  dependencies: {
    realm: {
      platforms: {
        ios: null, // disable iOS platform, other platforms will still autolink if provided
      },
    },
  },
};

I am sticking with realm 3.2.0 for now:

    "react": "^16.9.0",
    "react-native": "0.60.6",
    "realm": "3.2.0",
    "redux": "^4.0.4",

33 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Rotemy@kneth@kraenhansen@mklb@esutton

      Issue actions

        Missing Realm constructor or duplicated symbols · Issue #2634 · realm/realm-js