react-native
react-native copied to clipboard
NativeModules are empty
Description
When creating new native library for application, when library is attached to the react native mobile application in iOS, the NativeModules are empty ({}
)
React Native version:
System: OS: macOS 10.15.5 CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz Memory: 30.54 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.14.1 - /usr/local/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.14.2 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 IDEs: Android Studio: 3.6 AI-192.7142.36.36.6308749 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2 npmGlobalPackages: create-react-native-app: 3.4.0 react-native-create-library: 3.1.2 react-native: 0.61.4
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Create new RN application using
create-react-native-app my-project
- Create new native library using
react-native-create-library -—platforms ios,android my-library
- Configure XCode .xcworkspace project, link React library to the project, to let project see React binaries.
- In my-project app add
import { Button, NativeModules } from 'react-native';
const App: () => React$Node = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<Button title="Press" onPress={() => onPress()}></Button>
</SafeAreaView>
</>
);
function onPress() {
console.log(NativeModules);
}
};
Expected Results
It doesn't matter if it's XCode 11 or XCode 10, the NativeModules is empty. When printing NativeModules.MyLibrary it's null.
Does the behavior vary with remote JS debugging being enabled and disabled?
@chrisbobbe Thanks for response, when JS is enabled, I can see some libraries but there is no MyLibrary.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
i have same issue nativeModule returns null for both android and ios
我也是,请问你解决了 吗?
I too.
Anybody working on this issue or has anyone found a fix? I am currently experiencing the issue too.
expo: "~48.0.4" react: "18.2.0" react-native: "0.71.3"
Gradle version is 7.5.1. XCode version is 1.74.3 (Universal)
Can't share the project as it is private but I was working from this tutorial..
Yes, I am getting the same issue on the same version of react-native
0.71.3
. I can see a duplicate issue here. I followed the same guide @macro6461
Same happening on version 0.71.13
Happening to me i created a native component following the guide from react native docs the native component returns null
on react-native version 0.73.1
. i found old discussion about this issue Native Modules #96 but no proper resolution yet.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.