realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Unable to build React-Native iOS app after installing realm #2549

Closed seantansey closed 4 years ago

seantansey commented 4 years ago

Goals

Install realm into my react native application.

Expected Results

Successful installation and build using react-native run-ios

Actual Results

After installation I am unable to build the app using the "react-native run-ios" command, or building the project through xcode. The errors I receive are:

Steps to Reproduce

Running these 2 commands results in missing realm constructor errors, which lead me to following the instructions in https://realm.io/docs/javascript/latest/#missing-realm-constructor. After closing simulator and terminal, deleting the ios build and running react-native run-ios I receive the errors mentioned above.

Version of Realm and Tooling

henriqueweiand commented 4 years ago

I believe we are facing the same problem, this other issue we are facing something similar #2460

seantansey commented 4 years ago

@henriqueweiand the issue is similar but I dont think its specific to v0.60 of react native, I tried creating brand new react native app at v0.61.2 as well as downgrading to v0.59.0 and experienced the same issues.

MichaelHao25 commented 4 years ago

I also encountered the same problem using the version "realm": "2.28.0" to solve this problem

pierroo commented 4 years ago

I also encountered the same problem using the version "realm": "2.28.0" to solve this problem

Thank you @MichaelHao25 for the suggestion;

do you know if this version works with Hermes engine? Or does this one fail as well?

samtoya commented 4 years ago

@MichaelHao25 I'm currently facing the same issue & I've implemented your suggestion and it still won't build past this.

Screenshot 2019-10-07 at 12 09 13 PM

I'm using RN 0.59.9 Realm: ^2.28.0

seantansey commented 4 years ago

I was able build the app using @MichaelHao25 solution of downgrading to v2.28.0

ertankara commented 4 years ago

Yay I think this is going to be my first time being helpful to others

I resolve the issue by opening the realmjs project in my xcode. As the error path shows these are for testing purposes, and I thought it should be okay to delete them, and it worked.

Steps: 1- Open Xcode 2- Go to /your/system/path/projectName/node_modules/realm/src 3- You will see the file called RealmJS.xcodeproj, launch project by double clicking 4- Go to targets 5- You will see three targets first Target -> RealmJS second target -> GCDWebServers third target -> RealmJSTests or something similar, (not sure bcs I deleted earlier) 6- Delete test target and thank me later.

And yes I know this would re-occur when you need to reinstall node_modules. But I want to use latest version, so dropping a hint in your README can help you later.

cybercoder commented 4 years ago

Yay I think this is going to be my first time being helpful to others

I resolve the issue by opening the realmjs project in my xcode. As the error path shows these are for testing purposes, and I thought it should be okay to delete them, and it worked.

Steps: 1- Open Xcode 2- Go to /your/system/path/projectName/node_modules/realm/src 3- You will see the file called RealmJS.xcodeproj, launch project by double clicking 4- Go to targets 5- You will see three targets first Target -> RealmJS second target -> GCDWebServers third target -> RealmJSTests or something similar, (not sure bcs I deleted earlier) 6- Delete test target and thank me later.

And yes I know this would re-occur when you need to reinstall node_modules. But I want to use latest version, so dropping a hint in your README can help you later.

You saved my day.

samtoya commented 4 years ago

I got it to work... Thanks @stansey92

pierroo commented 4 years ago

Are any of you using Hermes engine as well, if you did, did it work for you as well?

cybercoder commented 4 years ago

@ertankara After downloading a bunch of files react-native says in ios simulator : Error: Missing Realm constructor. Did you run "react-native link realm"?

ertankara commented 4 years ago

@cybercoder Yes, I had the same error and no matter what I've tried I wasn't able to resolve it., after reading other issues, I think realm has support issues with the latest version of React Native 0.61. So I gave up on this and now using react-native-storage.

davidnuvolar commented 4 years ago

I wanted to confirm this issue also happens to us using RN 0.59.9, so it's not specific to 0.60. We're using realm 3.2.0

manithin commented 4 years ago

Happening this on react native 0.61.2 iOS. I was working fine on .59.9. Reak version 3.2.1. Unable to get around this after linking, manually adding library

dakkafex commented 4 years ago

can confirm that this is also happening on 0.59.8.

Downgrading to 2.28 did not work for

that causes more errors like "clock bla bla not found"

following @ertankara s suggestion worked for getting it to build, but ends in: missing realm constructor

RealmBot commented 4 years ago

➤ Kenneth Geisshirt commented:

We have release Realm JS v3.4.0 (and a couple of bug fix releases) to support recent React Native. Please try to upgrade.

dakkafex commented 4 years ago

➤ Kenneth Geisshirt commented:

We have release Realm JS v3.4.0 (and a couple of bug fix releases) to support recent React Native. Please try to upgrade.

no dice, still issues with the time things

davidnuvolar commented 4 years ago

➤ Kenneth Geisshirt commented:

We have release Realm JS v3.4.0 (and a couple of bug fix releases) to support recent React Native. Please try to upgrade.

It still happens for us with 3.4.0. I removed the manually linked library, updated to 3.4.0, ran pod install and launched the app. Still getting Missing Realm constructor error.

kneth commented 4 years ago

@dakkafex @davidnuvolar Thank you for the feedback. @kraenhansen and I will take a closer look (likely tomorrow).

dakkafex commented 4 years ago

I have noticed that it the issues only start to happen after i integrated react-native firebase into the app, in my case.

kneth commented 4 years ago

@dakkafex That's an interesting observation. Sounds like we need to take a closer look at our friends at Firebase :smile:.

davidnuvolar commented 4 years ago

I have noticed that it the issues only start to happen after i integrated react-native firebase into the app, in my case.

In our case no Firebase integration at all.

kraenhansen commented 4 years ago

@stansey92 do you have time to test this with the latest version of Realm JS and React Native? Alternatively I will close this issue, as I cannot reproduce it. If it doesn't work, could I get you to share what other dependencies you're using and perhaps the contents of your Podfile?

I noticed you wrote that you run react-native link realm. There is no longer a need to run this command as Realm JS now supports autolinking.

For anyone else experiencing something similar, please open an issue of your own, possibly referencing this.

seantansey commented 4 years ago

@kraenhansen i tried updating to 3.4.0 this morning and was not able to successfully build, but was receiving a different error "clang: error: linker command failed with exit code 1", ill see if i can figure out what causing that tomorrow

reyn-nova commented 4 years ago

in the first pod install it works fine, when you pod install again it give me 'realm/util/assert.hpp' not found and sometime duplicate architecture error

reyn-nova commented 4 years ago

I need to

npm uninstall realm && cd ios && pod install && cd ..

then

npm install realm && cd ios && pod install

to get fresh realm installation and get rid of my realm errors

LeoLeBras commented 4 years ago

Same error ! I have to reinstall everything every time with realm@3.4.x

kraenhansen commented 4 years ago

@LeoLeBras we would love to help you resolve your issue. To do this, its important for us to know exactly what error / stacktrace you're experiencing and what versions of React Native and Realm JS you're using. As I wrote earlier on this issue, please create your own issue with these details:

For anyone else experiencing something similar, please open an issue of your own, possibly referencing this.

LeoLeBras commented 4 years ago

Okay, of course, I'll do that to you right now ! (thank you for your reactivity)

kraenhansen commented 4 years ago

@stansey92 have you tried deleting your ./ios/build directory? When upgrading React Native dependencies, sometimes this step is needed to remove outdated build artifacts.

davidnuvolar commented 4 years ago

I created a project from scratch and I did not encounter this issue. In our existing project, deleting build folder, unlinking the library, removing the realm dependency, running pod install, installing realm 3.4.2, running pod install again and building ios from scratch fixed the issue.

kraenhansen commented 4 years ago

I am closing this since I've gotten no response from @stansey92 - please open another issue regarding the linker error, if this persists.

trungnguyencmu commented 4 years ago

+1, after build, I cant open app in android

kneth commented 4 years ago

@trungnguyencmu Please create a new issue containing relevant information (see the issue template).

trungnguyencmu commented 4 years ago

@kneth , It's worked, Thank you!

faizantariq1 commented 4 years ago

Note: It's running on android side but giving error on ios side. when adding realm library.

Using Node.js v12.16.2 internal/modules/cjs/loader.js:983 throw err; ^

Error: Cannot find module '/Users/faraztariq/Desktop/Naseeb' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15) at Function.Module._load (internal/modules/cjs/loader.js:862:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } Command PhaseScriptExecution failed with a nonzero exit code