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

react-native link never works #15646

Closed
gokulkulkarni1987 opened this issue Aug 25, 2017 · 9 comments
Closed

react-native link never works #15646

gokulkulkarni1987 opened this issue Aug 25, 2017 · 9 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@gokulkulkarni1987
Copy link

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

YES

Environment

  1. react-native -v: react-native-cli: 2.0.1, react-native: 0.47.0
  2. node -v: v8.4.0
  3. npm -v: 5.3.0
  4. yarn --version: 0.27.5

Then, specify:

  • Target Platform:
    iOS and Android
  • Development Operating System:
    macOS and Linux
  • Build tools:
    Not specific to any platform

Steps to Reproduce

(Write your steps here:)

  1. I do installation of any library by using npm install <lib_name> --save
  2. The installation goes successful and I run react-native link <lib_name>

Expected Behavior

The linking of the library must happen.

Actual Behavior

The library linking never happens and I will have to manually do all the steps to add the library in both iOS and Android.

Reproducible Demo

I think this step is not applicable as it is related to linking.

@patw0929
Copy link
Contributor

link issue were solved in 0.47.1.

@laurent22
Copy link

I had this issue after renaming a project. The old name was still used in one place and because of this linking was silently failing.

@agrison
Copy link

agrison commented Aug 25, 2017

I'm also having the exact same issue with react-native 0.47.2 and react-native-cli 2.0.1.

@agrison
Copy link

agrison commented Aug 25, 2017

Complete step to reproduce:

$ react-native -v
react-native-cli: 2.0.1
react-native: 0.47.2
$ create-react-native-app foo
$ cd foo
foo$ yarn add react-native-device-info
foo$ react-native link react-native-device-info
foo$ cat <<EOF > App.js
> import React from 'react';
> import { StyleSheet, Text, View } from 'react-native';
> 
> var DeviceInfo = require('react-native-device-info');
>
> export default (props) => {
>  return (
>    <View
>      style={{
>        flex: 1,
>        backgroundColor: '#fff',
>        alignItems: 'center',
>        justifyContent: 'center'
>      }}
>    >
>      <Text>Locale: {DeviceInfo.getDeviceLocale()}</Text>
>    </View>
>  );
>};
>EOF

http://i.imgur.com/wTKuCmw.png

Now if I eject and link manually in XCode, it works.

foo$ yarn eject
foo$ do some stuff in XCode
foo$ hit Cmd+R 

http://i.imgur.com/FAqjd4x.png

@agrison
Copy link

agrison commented Aug 25, 2017

Same problem with any other library, for instance react-native-i18n which I need to use, but I'd rather not have to eject just to handle internationalization 😃

@reneweb
Copy link
Contributor

reneweb commented Sep 11, 2017

The problem is that create-react-native-app does not support native code (https://github.com/react-community/create-react-native-app#what-are-the-limitations-of-create-react-native-app) thus the linking doesn't work. It's unfortunate though that the linking script doesn't present any error message, but just silently returns. I will look into adding some error message for that.
To use native code you need to either eject or use react-native init to setup the project.

@reneweb
Copy link
Contributor

reneweb commented Sep 11, 2017

There is already an error message by now in master: https://github.com/facebook/react-native/blob/master/local-cli/link/link.js#L160

@agrison
Copy link

agrison commented Sep 12, 2017

Thanks, that's what I did, everything works correctly :)

@stale
Copy link

stale bot commented Nov 11, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 11, 2017
@stale stale bot closed this as completed Nov 18, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants