React-native: How to use `react-native link` with a existing iOS or Android project path

Created on 3 Jul 2017  ยท  8Comments  ยท  Source: facebook/react-native

Can I use react-native link command with a parameter like

react-native link --path "{a_path_to_my_exisiting_ios_or_android_project}"

to link the native code in the node_modules/ to a specific, existing iOS/Android project?

If YES, how to do that and can you document it?
If No, can you add this feature?

Using the manual method for existing projects is error-prone and time-consuming.

Locked

Most helpful comment

@xareelee you can set a rnpm key in your package.json and define some properties to override defaults.

E.g. here we read properties from an object userConfig.

In order to override location to your .xcodeproj, you'd do:

{ "rnpm": { "ios": { "project": ".../a.xcodeproj" } } }

All 8 comments

What is your project structure? You can do it if automatic detection fails. In that case, I would have to see list of your directories and what you are trying to link.

I have an iOS project, and I add package.json and install node_modules:

.
โ”œโ”€โ”€ Podfile
โ”œโ”€โ”€ Podfile.lock
โ”œโ”€โ”€ Pods/
โ”œโ”€โ”€ helloworld/    ## native code
โ”‚ย ย  โ”œโ”€โ”€ Assets.xcassets/
โ”‚ย ย  โ”œโ”€โ”€ Base.lproj/
โ”‚ย ย  โ””โ”€โ”€ src/
โ”œโ”€โ”€ helloworld.xcodeproj/
โ”œโ”€โ”€ helloworld.xcworkspace/
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ node_modules/
โ””โ”€โ”€ yarn.lock
  1. I need to add a fake Android project in the project to make react-native link work. I want to just run react-native link --ios to link the iOS project only.
  2. The command react-native link doesn't automatically install React-Native-associated native projects including React, RCTAnimation, RCTActionSheet, etc. I need to add those .xcodeproj into our iOS project, and add them to the linked binary in the Build Phases manually.
  3. I need to set View controller-based status bar appearance to NO manually in the info.plist.

I hope I can just install those node modules and simply run react-native link to add the native code to our iOS project.

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@xareelee did you find any solution for this?

@hramos is it possible to re-open and add bug label?

I was also disappointedreact-native link command does not link react-native packages. It's much more labor intensive to manually install react-native libraries than external packages.

Current experience: where is RCT.xcodeproj even located? do I need to find a lib too? .. ok build .. nope error .. what is wrong .. google error code .. oh no RCTWebSocket is red color ..

@xareelee you can set a rnpm key in your package.json and define some properties to override defaults.

E.g. here we read properties from an object userConfig.

In order to override location to your .xcodeproj, you'd do:

{ "rnpm": { "ios": { "project": ".../a.xcodeproj" } } }

@grabbou your solution doesn't work

@xareelee did you find any solution for this? I have the same problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

despairblue picture despairblue  ยท  3Comments

josev55 picture josev55  ยท  3Comments

TrakBit picture TrakBit  ยท  3Comments

lazywei picture lazywei  ยท  3Comments

WG-Com picture WG-Com  ยท  3Comments