Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in linking package in RN >= 0.60 #686

Closed
ravimaurya-nickelfox opened this issue Jul 12, 2019 · 10 comments
Closed

Issue in linking package in RN >= 0.60 #686

ravimaurya-nickelfox opened this issue Jul 12, 2019 · 10 comments

Comments

@ravimaurya-nickelfox
Copy link

System info

System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz
    Memory: 592.89 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.10.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.3 => 0.60.3 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

The package is not properly working with react-native version >=0.60.
I have followed each steps to install but it is not working after linking the package.
When I ran react-native link react-native-gesture-handler, it produces error link below;
image

If i try to link the package manually, I get error like,

fatal error: 'React/RCTEventDispatcher.h' file not found
#import <React/RCTEventDispatcher.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

I guess this issue is with RN 0.60.3, because I have tried it RN0.60.0 and it was working fine with v0.60.0.

My Package.json looks like below;

{
  "name": "animations",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "jetify"
  },
  "dependencies": {
    "react": "16.8.6",
    "react-native": "0.60.3",
    "react-native-gesture-handler": "^1.3.0",
    "react-navigation": "^3.11.0"
  },
  "devDependencies": {
    "@babel/core": "^7.5.4",
    "@babel/runtime": "^7.5.4",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.8.0",
    "eslint": "^6.0.1",
    "jest": "^24.8.0",
    "jetifier": "^1.6.2",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}
@thymikee
Copy link
Contributor

thymikee commented Jul 12, 2019

react-native-gesture-handler is compatible with autolinking. What you need to do:

cc @osdnk feel free to close this.

@spasecadet
Copy link

@thymikee I'm having the same issue. This is an ios problem though, android is working fine (at least for me, after some tinkering). The ios app builds successfully, but when it loads I get the same error as @ravimaurya-nickelfox.

@spasecadet
Copy link

spasecadet commented Jul 12, 2019

@ravimaurya-nickelfox @thymikee the ios problem is (hopefully temporarily) solved by adding pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler' to the Podfile. Doing so gives me this error/warning:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler")

but the app still works.

I had this before and I tried unlinking to resolve this error message - that's when I got the null is not an object error shown above, so it appears that the line is still needed in the Podfile.

@kimihiro64
Copy link

react-native-gesture-handler is compatible with autolinking. What you need to do:

cc @osdnk feel free to close this.

I'm not sure what you mean by adjusting MainActivity.java. After running unlink, you'll get the error that the package cannot be imported, in order to fix that you would have to manual link. If you remove all of it instead, you get the Direction undefined error as though autolink didn't work... It only works if I manually link.

@ravimaurya-nickelfox
Copy link
Author

As far as I read in official doc of react-navigation, they suggest to create react-native.config.js file to neglect react-navigation from auto-linking. After adding that file, it still doesn't work.
I think they should add pod method to doc, as @spasecadet mentioned here.

@thymikee
Copy link
Contributor

thymikee commented Jul 17, 2019

@ravimaurya-nickelfox @kimihiro64 you don't need to add react-native.config.js. It was mentioned by react-navigation but is obsolete now. What you need to do is to run cd ios && pod install before running iOS app.

@tapz
Copy link

tapz commented Aug 15, 2019

Unlinked and manually cleaned from gradle file and getPackages, but still get this. Is the autolinking working or not? With all other libraries it worked out of the box when upgrading to RN 0.60.

MainActivity.java:68: error: package com.swmansion.gesturehandler.react does not exist
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

@ethanshar
Copy link

Not sure why, but it seems that if the package is included in my project's package.json (as a dependency or devDependency) the auto-link works.
While if the package was installed by another dependency it's not enough for the auto-link

@pcowgill
Copy link

pcowgill commented Jan 3, 2020

react-native-gesture-handler is compatible with autolinking. What you need to do:

* if you have it linked already (e.g upgrading existing project), run `unlink`:
  ```
  react-native unlink react-native-gesture-hadnler
  ```

* adjust `MainActivity.java`: https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html#android

* make sure to run [jetifier](https://www.npmjs.com/package/jetifier) on "postinstall" step because it's not yet compatible with AndroidX

* run `cd ios && pod install` for iOS project

cc @osdnk feel free to close this.

@thymikee These instructions are out of date now that jetifier is included and run automatically with react-native-community/cli for React Native versions 0.60 and above, right? Thanks!

@jakub-gonet
Copy link
Member

RNGH supports auto-linking, so I'm closing this right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants