Realm-js: Unable to build React-Native iOS app after installing realm

Created on 4 Oct 2019  Â·  36Comments  Â·  Source: realm/realm-js

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:

  • error: Build input file cannot be found: '/Users/seantansey/Sites/IntelligentOfficeMobile/node_modules/realm/tests/ios/RJSModuleLoader.m'

  • error: Build input file cannot be found: '/Users/seantansey/Sites/IntelligentOfficeMobile/node_modules/realm/tests/ios/RealmJSCoreTests.m'

Steps to Reproduce

  • npm install --save realm
  • react-native link realm

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

  • Realm JS SDK Version: 3.2.0
  • React Native: 0.60.5
  • Client OS & Version: macOS Mojave 10.14.6
O-Community T-Help

Most helpful comment

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.

All 36 comments

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

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

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

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?

@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

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

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.

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.

I got it to work... Thanks @stansey92

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

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

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

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

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

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

➤ 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.

➤ 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

➤ 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.

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

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

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

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.

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

@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

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

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

Same error ! I have to reinstall everything every time with [email protected]

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

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

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

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.

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

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

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

@kneth , It's worked, Thank you!

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

max-zu picture max-zu  Â·  3Comments

CrystalRanita picture CrystalRanita  Â·  3Comments

camslaz picture camslaz  Â·  4Comments

texas697 picture texas697  Â·  3Comments

fever324 picture fever324  Â·  4Comments