wonday / react-native-orientation-locker

A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
MIT License
757 stars 274 forks source link

[iOS] Native module cannot be null. #39

Closed devonhuangcodes closed 5 years ago

devonhuangcodes commented 5 years ago

I manually linked this library and it works perfectly on Android. On iOS, it also works fine when I run the app through xcode. However, when I try to run the app through react-native-cli using the command react-native run-ios, I get the following error:

Native module cannot be null.

screen shot 2018-12-11 at 1 33 22 pm
emilany commented 5 years ago

Also experiencing the same issue, any fix or workaround?

paulxuca commented 5 years ago

Did you run react-native link prior?

devonhuangcodes commented 5 years ago

Yup I have already tried that

paulxuca commented 5 years ago

If it works via xcode and not through cli, it might mean that you're running an old version of the app in simulator without the native code built. I would double check that the right app is being launched when you start the app via cli.

devonhuangcodes commented 5 years ago

I'm not too sure what I did or what happened. It might've been resolved when I did a clean build to fix a previous issue. I just tried running it using the cli just now and it started working. Closing this issue. Thanks for your insights Paul

truongluuxuan commented 5 years ago

Right click to Libraries in xcode, chose add newnew file to "your project", find in node_module , open react-native-orientaion-locker , chose RCTOrientationation.xcodeproj, Go to Build Phases, in Link BinariesBinary with Libraries, add libRCTOrientation.a. enjoy

LAITONEN commented 4 years ago

Right click to Libraries in xcode, chose add newnew file to "your project", find in node_module , open react-native-orientaion-locker , chose RCTOrientationation.xcodeproj, Go to Build Phases, in Link BinariesBinary with Libraries, add libRCTOrientation.a. enjoy

Just to clarify:

  1. Add ${ROOT}/node_nodules/react-native-orientation-locker/iOS/RCTOrientation.xcodeproj to XCode -> ${YOUR_PROJECT_NAME}/Libraries
  2. Click on ${YOUR_PROJECT_NAME}, openBuild Phases - Link Binary With Libraries`
  3. In the folder from step 1, find Products/libRCTOrientation.a, and drag-drop it to the list of Binaries from the step 2.