realm-js: Incompatible with React Native Autolinking (React Native v0.60)
Goals
Use the Realm.js with React Native Autolinking correctly.
Expected Results
Don’t show warning information.
Let the CocoaPods don’t show warning after executing pod install.
Actual Results
After the pod install, it shows the following warning:
[!] use_native_modules! skipped the react-native dependency 'realm'. No podspec file was found.
- Check to see if there is an updated version that contains the necessary podspec file
- Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See
https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec
- If necessary, you can disable autolinking for the dependency and link it manually. See
https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library
Steps to Reproduce
cd ${REACT_NATIVE_PROJECT_ROOT_PATH}
npm install --save realm
cd ios && pod install & cd ..
Version of Realm and Tooling
- Realm JS SDK Version:
realm-js 2.29.1 - Node or React Native:
React Native v0.60.3 - Client OS & Version:
iOS 12.2 - Which debugger for React Native:
None
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 35
- Comments: 40 (9 by maintainers)
Commits related to this issue
- Exclude Realm as a dependency Issue based on https://github.com/realm/realm-js/issues/2460 — committed to ndinata/react-native-template-opinionated by deleted user 5 years ago
Hey everyone. There are already plans to fix this soon.
I’ve tried the solutions posted here, and manual linking works.
react-native.config.jsconfig file in the root of the project with this content:That will skip autolinking for Realm for iOS.
Add the project
RealmReact.xcodeprojfromnode_modulesinto your project as a subprojectBe sure to include
libRealmReact.ain theLink Binary With Librariesstep of your targetBuild Phases. Important: I’ve spent a lot of time chasing theCannot read property 'debugHosts' of undefinedbug because I was linking tolibRealm.aand notlibRealmReact.a, I’m sure that may happen to someone else.I was hyped to use RealmDB for the current project but, I’ve been chasing errors after errors. This is an awesome project and I really hope to see it up without errors soon 😕
@d14na You don’t need to change DB. We’ve got two RN 0.60.5 apps using Realm 2.29.1 live with the Android 64-bit update.
The only issue right now is that it doesn’t support autolinking, but that doesn’t mean you can’t use the module.
Just tell RN it doesn’t support autolinking on ios (Android actually works fine since it works in a different manner) by editing your
react-native.config.jslike so:Since you’re upgrading a project I assume your iOS project already has the manually linked
RealmReact.xcodeproj? That’ll be sufficient for the iOS side. On the Android side ensure theimplementation project(':realm')isn’t in theapp/build.gradleand:isn’t in the
settings.gradleand you should be good to go on both platforms. Android will autolink, iOS won’t.same for me
To fix the pod’s
use_native_modules!-error, just add areact-native.config.js-file in the root of your project with the following code (exclusive example for realm, but you get the idea):👉 autolinking info for more details
Disabling autolinking means we have to use good ol’ manual linking, but sadly realm doesn’t provide a guide here and the standard way (as told by the react-native-team) doesn’t work, either.
I followed this guide, but still get the
Cannot read property 'debugHosts' of undefinederror. It looks like the export of NativeModules in RealmJS is undefined, thus no destruction ofdebugHosts.The realm problem I see here is that realm currently doesn’t use CocoaPods for iOS, which prohibits auto linking.
Looking forward for this issue being fixed.
Edit: Fix typo react-native.config.js
I have a PR ready for this https://github.com/realm/realm-js/pull/2586. If some of you have experience writing Podspec files and especially in the context of React Native libraries, it would be really awesome if you spent a few minutes reviewing the change and adding a comment on the PR.
It would also be great if one or more of you wanted to test out the changes:
git clone --recurse-submodules --single-branch --branch kh/podspec https://github.com/realm/realm-js.gitnpm packnpm install [path to realm-js]/realm-3.3.0.tgzpod install(from your./iosdirectory).react-native unlink realmfirst.Apply this
npm install realm@hermesWork’s for me.
🤦♂️ Sure, fixed.
run
npx react-native link realmthennpx jetifyignore the warning, my project is running properly with that