marcshilling / react-native-idle-timer

A cross-platform bridge that allows you to enable and disable the screen idle timer in your React Native app
MIT License
212 stars 41 forks source link

Autolinking not working? #23

Closed shamilovtim closed 4 years ago

shamilovtim commented 4 years ago

Just installed from npm and tried to compile straight away. Got an error that the method doesn't exist. It seems the native code isn't linked on iOS. Is autolinking broken with this project?

marcshilling commented 4 years ago

Hmm, it should work because we have a podspec file at the root of the project. Did you run pod install?

shamilovtim commented 4 years ago

Hey @marcshilling thanks for the fast response! Yes I did pod install in ios. No dice, Podfile didn't even change.

shamilovtim commented 4 years ago

Btw I added the plugin with yarn add react-native-idle-timer. Perhaps there's an exception in the npm/yarn flow?

marcshilling commented 4 years ago

Ok, I will look into this. Just to confirm, you are on a RN version >= 0.60 correct? Is auto linking working with other libraries?

shamilovtim commented 4 years ago

Yes I am on RN 0.61.4 and Expo 36 (ExpoKit). Autolinking has worked with any other libraries I've used in the past.

Also just to update, npm install made no difference. It doesn't seem to autolink under neither npm nor yarn.

marcshilling commented 4 years ago

@shamilovtim ok so I just tested this out and everything seemed to work for me. In a RN 0.62.2 project, I:

  1. Ran yarn add react-native-idle-timer
  2. Ran cd ios && pod install (the output showed >Installing react-native-idle-timer (2.1.6))
  3. In a component in my app, I was able to import the library and call the function to disable the idle timer.
shamilovtim commented 4 years ago

Gotcha, well I'm going to close this then. The main step of failure I found is that pod 'react-native-idle-timer', :path => '../node_modules/react-native-idle-timer' is simply never added to the Podfile. I don't know why that fails to happen, whether it's an npm thing or an Expo thing in my particular project. But once that line is added to Podfile, the rest is indeed autolinked.