Installation
#
Requirements- node >= 18.18
- react-native = 0.77 (0.78 - 0.80 support is in progress)
- new architecture enabled (if you are not using the new architecture, you can still use react-native-navigation of version 7.x.x with react-native 0.73 and lower)
#
npm or yarnnpm:
yarn:
npx rnn-link
(automatic installation)#
Installing with You can benefit from autolinking for some of the necessary installation steps. But unlike most other libraries, react-native-navigation requires you to make a few changes to native files.
We've simplified the process through a set of scripts. So to make all the necessary changes automatically, in your project's root folder run:
Make sure to commit the changes introduced by the rnn-link
script.
The automatic linking is optimized for new applications created via the
npx @react-native-community/cli@latest init
command. If you are migrating from a version of react-native-navigation older than v7, it's recommended to check the steps manually after the script runs.
If one of the steps failed or you can't run (or are not comfortable with) the automatic scripts, you'll need to complete the relevant steps in the manual installation steps below, for both platforms.
#
CocoaPodsAfter the the automatic scripts completed successfully, run pod install:
#
Update index.js fileindex.js
is typically used as an entry point into the app. It's first parsed and executed by the JS engine, therefore we'll want to show our UI from there.
The following diff demonstrates changes needed to be made to index.js
, initialized by react-native init
.
#
FinishIf you followed the steps successfully up to this point, then rebuild your application and you are good to go:
tip
This is a good moment to build your application in both platforms, validate that everything is working properly and commit your changes. If you're coming from a fresh npx @react-native-community/cli@latest init
project, then you should be seeing the Welcome screen as usual, but under the hood your application is using react-native-navigation!
#
Manual InstallationIf installation with npx rnn-link
did not work, follow the manual installation steps below.
#
iOSMake sure your Xcode is updated. We recommend editing
.h
,.mm
and.swift
files in Xcode as the IDE will usually point out common errors.
#
Installation with CocoaPods#
Native InstallationChoose your implementation language: Depending on whether your project uses Swift or Objective-C, follow the appropriate section below. Most new React Native projects use Swift by default.
#
For Swift projectsIn Xcode, you will need to update this file: AppDelegate.swift
#
For Objective-C projectsIn Xcode, you will need to edit this file: AppDelegate.h
. Its content should look like this:
#
AndroidMake sure your Android Studio installation is up to date. We recommend editing
gradle
andkotlin
files in Android Studio as the IDE will suggest fixes and point out errors, this way you avoid most common pitfalls.
android/build.gradle
:#
1. Update MainActivity.kt
#
2. Update If you have any react-native related methods, you can safely delete them.
MainApplication.kt
#
3. Update This file is located in android/app/src/main/java/com/<yourproject>/MainApplication.java
.
#
App rootNow that you're done, don't forget to update the index.js
file, as shown above.
#
Troubleshooting#
Build app with gradle commandprefered solution - The RNN flavor you would like to build is specified in app/build.gradle
. Therefore in order to compile only that flavor, instead of building your entire project using ./gradlew assembleDebug
, you should instruct gradle to build the app module: ./gradlew app:assembleDebug
. The easiest way is to add a package.json command to build and install your debug Android APK .
Now run npm run android
to build your application
#
Force the same support library version across all dependenciesSome of your dependencies might require a different version of one of Google's support library packages. This results in compilation errors similar to this:
To resolve these conflicts, add the following to your app/build.gradle
: