In this section, we are describing the steps that you need to do in order to run our React Native app templates on iOS, from setting up the environment to building the project in Xcode. To run a React Native on iOS, you need Mac OS and Xcode, but there’s no need for an Apple developer account or an iPhone – you can simply run any Xcode project on the iOS simulator. If you are not new to iOS / React Native development, and you already have the dev environment set up, simply do the following steps:
- Be absolutely sure you have the latest STABLE Xcode version (Make sure you are NOT using Xcode Beta)
- Run “yarn install && cd ios && pod install && ls” in the root folder of the downloaded project
- Open the .xcworkspace file in Xcode, which got generated at the previous step
- In Xcode, select the iOS simulator / device and build and run the app (Command + R)
If this is the first time you are running an iOS project on your machine, you need to set up your environment first. We recommend you to follow the official Facebook documentation first, on how to run React Native CLI apps. There are a few prerequisites that are iOS specific (you don’t need them for Android):
We’re assuming you already have the environment to run react native apps. If not, follow Facebook’s documentation for running native apps (do not use Expo, you don’t need it). Follow the next quick steps to get your app running on an iOS device or iOS simulator.
1. Run “yarn install” in the project root directory
2. Locate the ios folder and run “pod update“
This will install all the pods that the chat app depends on, such as Firebase Auth, Storage, etc. Make sure you have Cocoapods installed beforehand. Here’s how a successful output looks like: This will also generate a .xcworkspace file, that can be opened in Xcode.
3. Open the .xcworkspace file in Xcode
Simply double click on the file in the terminal (make sure you are in the ios folder).
4. Run Xcode project
Choose a simulator or device in Xcode then go to Product -> Run, or simply press Command + R. This will build and run the chat project in the selected device/simulator.
Frequently Asked Questions
1. I’m getting a red screen error saying the metro bundler is not running Sometimes, Xcode cannot open the metro bundler by itself, so you need to open it manually. To do that, simply open a Terminal window, locate the project folder and run:
yarn install && npm start -- --reset-cache
Now, the packager server has started – keep this window open and re-build the project in Xcode.
2. I’m getting a glog error (/configure:-1: in `node_modules/react-native/third-party/glog-0.3.4′:) This error might appear in some environments. To fix it, locate the glog folder. Assuming you’re in the root folder:
Now run your Xcode project again and the error will be gone.
3. I’m getting error: Build input file cannot be found: ‘node_modules/react-native/Libraries/WebSocket/libfishhook.a’ If you run into this error, click on the RTCWebSocket subproject in Xcode -> Build Phases -> Link Binary with Libraries and remove the libfishhook.a entry. Now add it again (yes, it’s crazy – welcome to react native!). Then re-build the project and everything should work now.
Why can’t I just run “react-native run-ios”?
Unfortunately, you need to build the app with Xcode, because we are using Firebase packages, which can’t be compiled from the command line yet. Hopefully, once react native gets more mature, you’ll be able to run react native iOS apps more easily. Enjoy our React Native App Template!