Ejecting from Create React Native App
"Ejecting" is the process of setting up your own custom builds for your CRNA app. It can be necessary to do if you have needs that aren't covered by CRNA, but please note that aside from the use of version control systems (git, hg, etc.) it is not reversible.
If you see the reason you'd like to eject, click the link for a short explanation of the options:
- I want to include a library which uses
- I want to write my own native code for my app
- I want to build my app to publish to the App Store or Play Store
Create React Native App makes it easy to start working on React Native apps by removing native code build tools from the equation. However, many apps want functionality that comes from interfacing directly with mobile platform APIs via Java, Objective-C, Swift, C, etc. As of right now, the only way to get direct access to these APIs from your app is by "ejecting" from CRNA and building the native code yourself.
You may also want to distribute your app to coworkers, friends, or customers (shocking!). Right now you can do so by either making use of a service to host or build your CRNA app or by ejecting. At the moment, Expo is the only provider we're aware of that offers hosting and build services for CRNA apps, but we'll definitely update this section as we become aware of others.
If you do need to eject to build your own distribution package or to include your own native code, there are two options at this time. To use either option, make sure to have the appropriate Xcode and/or Android Studio environment configured.
Starting the Ejection Process
npm run eject will start the process of ejecting from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project. Once this command has successfully run, you should also follow any steps below that are applicable to your environment.
Ejecting to Regular React Native
This will give you a project very similar to one created by
react-native init. Make sure to install the
npm i -g react-native-cli # or yarn global add react-native-cli
Also, please note that if you did make use of any Expo APIs before ejecting, you'll need to remove or replace them.
Ejecting to ExpoKit
Using ExpoKit will allow you to continue using Expo APIs along with building your own native code, but it requires an Expo account and use of Expo developer tools.
Because this ejection process essentially produces a custom build of the Expo client app, you don't need to modify any of your app's code, but you do still need to have an Xcode/Android Studio environment, along with
react-native-cli and Expo CLI.
React Native Link
If you need to include a library which includes
Writing My Own Native Code
Developers are sometimes surprised at what can be accomplished with JS-only projects, which is also good for encouraging code reuse across platforms. That said, if you really need to write your own native code, then you'll need to eject.