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

iOS - Missing Realm constructor - please ensure RealmReact framework is included! #375

Closed bosung90 closed 8 years ago

bosung90 commented 8 years ago

When I run I get error (red screen) on iOS emulator Missing Realm constructor - please ensure RealmReact framework is included!

'use strict'
import Realm from 'realm'
{...}
export default new Realm({schema: [WeatherProperty, WeatherStation, WeatherCurrent, WeatherDetail, WeatherTemperature, WeatherTemperatureData]})

Note that I am not getting any error in Android.

My dependencies :

  "dependencies": {
    "react": "^0.14.7",
    "react-native": "^0.22.2",
    "react-native-router-flux": "aksonov/react-native-router-flux#dcc7558",
    "react-native-viewpager": "bosung90/react-native-viewpager#db525c8",
    "react-redux": "^4.4.1",
    "realm": "^0.11.1",
    "redux": "^3.3.1"
  },
  "devDependencies": {
    "redux-devtools": "^3.1.1"
  }
bosung90 commented 8 years ago

Found out libRealmReact.a was missing from Linked Frameworks and Libraries.

enu-kuro commented 8 years ago

@bosung90 how to solve the problem?

bosung90 commented 8 years ago

@enu-kuro

  1. Install rnpm npm install -g rnpm
  2. Execute this in command line within your project rnpm link realm
  3. Go to Xcode, select Show your project navigator -> select your project (blue icon) -> select general tab -> scroll to bottom and add "libRealmReact.a" to Linked Frameworks and Libraries by pressing + button.
enu-kuro commented 8 years ago

@bosung90 Thanks! My problem was the same with this(https://github.com/realm/realm-js/issues/361). Now it fixed.

amonmoce commented 7 years ago

Me I have the libRealmReact.a but still the same problem .... any idea can be the problem ?

appden commented 7 years ago

@amonmoce Can you send your project to help@realm.io so I can take a look?

amonmoce commented 7 years ago

@appden I read one of your comment on another website. I was using the 0.14 version ... i changed to 0.13.2, and it worked. Feel like the latest version has some problems. Thanks for you promptitude @appden

appden commented 7 years ago

@amonmoce We just released 0.14.1-rc. Would you mind updating to that and seeing if your issue is resolved? Thanks!

jaimecorrea commented 7 years ago

I have the same issue, not resolved with 0.14.1

alazier commented 7 years ago

@jaimecorrea - can you verify that libRealmReact.a is in the Linked Libraries and Frameworks for the iOS project?

jaimecorrea commented 7 years ago

I'm working with Android, Realm worked well until today as I updated it...

alazier commented 7 years ago

@jaimecorrea what steps did you take when you updated? Maybe running rnpm link realm again will fix the issue?

jaimecorrea commented 7 years ago

I already did it but it doesn't work, actually I try to do a test with "react-native init ..." (Reac Native 0.29.0) and realm 0.14.1 and I got the same error in Android...

alazier commented 7 years ago

@jaimecorrea odd - can you confirm that the line to include realm line is listed in android/app/build.gradle?

jaimecorrea commented 7 years ago

I have this in build.gradle

dependencies { compile project(':realm') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules }

Yhozen commented 7 years ago

I'm getting the same error in Android with RN 0.29 and realm 0.14.1 (I can't test in iOS)

Yhozen commented 7 years ago

I fix it just by adding this two lines in MainApplication.java


import io.realm.react.RealmReactPackage; // ADD THIS
...
  @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RealmReactPackage() // AND THIS
      );
    }
tantv commented 7 years ago

Thanks @Yhozen, it worked for me.

Chris-Petty commented 7 years ago

@Yhozen's changes were necessary for me using react native 0.30.0-rc0. RN 0.29.2 I had no problems.

Yhozen commented 7 years ago

@Chris-Petty maybe the problem is with "rnpm link" in some versions

ismdcf commented 7 years ago

@Yhozen it did work for me as well :+1:

jomaint commented 7 years ago

I had issue running on xcode, even just starting the app. All i do was import realm. I downgraded to version from 0.14.7 to 0.13.2 and it works now.

micmor commented 7 years ago

it works!

bartolkaruza commented 7 years ago

Running into this issue since today on iOS device:

"react": "15.2.0",
"react-native": "^0.30.0",
"realm": "^0.14.3",

Library libRealmReact.a is linked through rnpm (also tried with manual linking, but the same error is still there).

Kufert commented 7 years ago

Had the same with RN 0.31 on Android (no issues on iOS) and @Yhozen fix helped. @appden please consider adding the fix to your sources.

alazier commented 7 years ago

We will improve the error message to make some of the suggestions made in this issue. Thank!

pospetur commented 7 years ago

Everything works good when I build for my iPhone but I get the "Missing Realm constructor - pl..." when I run it in the simulator. Can anyone help with this?

"react": "15.2.1", "react-native": "0.31.0", "realm": "^0.14.3"

yyppaag commented 7 years ago

Still not working on iOS :( , Does anyone know how to solve this? "react": "15.3.0", "react-native": "0.32.0", "realm": "^0.13.2"

I've also tried realm '0.12.0', '0.14.0', '0.14.3', Those are not working..

PS: Android is fine.

alazier commented 7 years ago

@yyppaag - is libRealmReact.a in Linked Frameworks and Libraries of your project after running react-native link realm?

abhisheknalin commented 7 years ago

I and using react-native 0.29 and fixed this error by running react-native link realm

robertherber commented 7 years ago

I'm getting this error on iOS and can't get it to work. The libRealmReact.a is linked allright. npm ls gives me: realm@0.14.3 react@15.3.2 react-native@0.34.0

On Android the app gets stuck at "fetching JS bundle", also here it seems like the rnpm has done it's job.

Anybody getting realm working with these versions?

jakeatwork commented 7 years ago

here's a solution that worked for me on el capitan in the simulator:

  1. close all simulators/device builds
  2. stop the package manager running in terminal (or better yet, just restart terminal)
  3. open the ios folder in your app root in finder
  4. go into the build folder (note: you won't see this build folder in atom, so just right click ios and click open in finder)
  5. delete everything inside of the build folder (just move to trash and keep trash around in case you're worried)
  6. run react-native run-ios to rebuild the whole thing

it appears when you link new modules, you have to rebuild the build to include it.

jbcullis commented 6 years ago

This issue has presented itself for v47 & v48 on iOS only.

stefanengel commented 6 years ago

@jbcullis We had the same issue on iOS with React Native 0.47.1 and Realm 1.11.1. After updating Realm to version 1.12.0, it suddenly worked.

atburghardt commented 6 years ago

I have the same Issue with iOS and Android "react-native": "^0.48.1", "realm": "^1.13.0", I linked the package, libRealmReact.a etc. is in Linked Frameworks, android files have the right imports aswell. Do I need to downgrade ?

arefed-zz commented 6 years ago

I get the error even though everything seems to have been linked properly. "realm": "^1.13.0" "react": "^16.0.0", "react-native": "0.48.3",

jbcullis commented 6 years ago

When are you calling the require for the realm library @atburghardt & @arefed? For me, the issue presented itself if I initiated the realm lib during app load. Instead, I now load the lib during log in well and truly after the app has loaded and have not experienced the issue since.

atburghardt commented 6 years ago

I require realm in a Saga. I tested to require after a TimeOut of a few seconds. App is running and after the TimeOut I get the then the same error.

houman-sanati commented 4 years ago

it happens in debug mode but otherwise, it works fine. I cant debug my whole project because of realm