Realm-js: Realm framework gets stripped when distributing app packages

Created on 30 Jan 2016  Â·  15Comments  Â·  Source: realm/realm-js

I'm getting the following crash when opening the app after installing it on device via Fabric Beta:

Thread : Fatal Exception: RCTFatalException: Unhandled JS Exception: Missing Realm constructor - please ensure RealmReact framework is included!
0  CoreFoundation                 0x18275d900 __exceptionPreprocess
1  libobjc.A.dylib                0x181dcbf80 objc_exception_throw
2  CoreFoundation                 0x18275d848 -[NSException initWithCoder:]
3  MyApp                          0x10003e638 RCTFatal (RCTAssert.m:133)
4  MyApp                          0x10005a96c -[RCTExceptionsManager reportFatalException:stack:exceptionId:] (RCTExceptionsManager.m:64)
5  CoreFoundation                 0x182763430 __invoking___
6  CoreFoundation                 0x182660eb4 -[NSInvocation invoke]
7  CoreFoundation                 0x1826657e0 -[NSInvocation invokeWithTarget:]
8  MyApp                          0x100073fdc -[RCTModuleMethod invokeWithBridge:module:arguments:] (RCTModuleMethod.m:472)
9  MyApp                          0x1000474f8 -[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] (RCTBatchedBridge.m:921)
10 MyApp                          0x100046ee8 __33-[RCTBatchedBridge handleBuffer:]_block_invoke387 (RCTBatchedBridge.m:851)
11 libdispatch.dylib              0x1821b1630 _dispatch_call_block_and_release
12 libdispatch.dylib              0x1821b15f0 _dispatch_client_callout
13 libdispatch.dylib              0x1821bd634 _dispatch_queue_drain
14 libdispatch.dylib              0x1821b50f4 _dispatch_queue_invoke
15 libdispatch.dylib              0x1821b15f0 _dispatch_client_callout
16 libdispatch.dylib              0x1821bfa88 _dispatch_root_queue_drain
17 libdispatch.dylib              0x1821bf224 _dispatch_worker_thread3
18 libsystem_pthread.dylib        0x1823c5470 _pthread_wqthread
19 libsystem_pthread.dylib        0x1823c5020 start_wqthread

Here's some extra information about my setup:

  • Tested using React Native 0.18.1 and 0.19.0
  • Using CocoaPods for installing react native, fabric+crashlytics
  • Running on simulator with Release in the schema works fine.
  • Running on device directly from Xcode with Release in the schema works fine.
T-Bug-Crash

All 15 comments

This happens with TestFlight as well, and not only in Fabric

Also note that I've removed any mention to realm other then require('realm')

Is the RealmReact.framework included in the Embedded Binaries section under the General tab in the app's setting? That's the only reason I could think that this would happen but I would imagine this would cause running on the device from XCode to fail too. Trying to see if I can reproduce the issue.

Ok. I can reproduce the issue using Fabric. Now just need to figure out what the problem is...

Think I figured it out. You need to turn of stripping the project settings:

"Strip Debug Symbols During Copy" -> NO
"Strip Linked Product" -> NO

@alazier on the app's target ?

Yes. Pretty sure "Strip Linked Product" is what is causing the problem but I changed both when I tried it out.

WORKS!!

We either need to update the docs for other users, or change something to avoid this altogether.

@appden The workaround should be added to the docs before release

Closing this unless we hear about other reports — the workaround documented in https://github.com/realm/realm-js/issues/219#issuecomment-178066140 should be enough!

Hi,

Another scenario when this is happening on Android: The app is turned off and it receives a push notification. import Realm is called and this error appears:
screen shot 2016-03-09 at 6 29 33 pm
The same issue happened with CodePush but it was fixed by calling the constructor only when a specific method was called (ex. CodePush.sync()).

Thank You!

Adding the two strip NO options no longer work under Xcode 7.3 and iOS 9.3.

  • "Strip Debug Symbols During Copy" -> NO
  • "Strip Linked Product" -> NO

@dorongutman You'll no longer need to disable stripping symbols after updating to 0.11.0. Check out the 0.11.0 release notes for how to update your project.

Still happens

Fatal Exception: RCTFatalException: Unhandled JS Exception: Missing Realm constructor. Did you run "react-native link realm"? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting

Was this page helpful?
0 / 5 - 0 ratings