Monday, July 16, 2018

How to run React Native app on iOS device


Command Prompt (in windows) or terminal (macOS) is a very necessary tool for creating React Native application . You have to use this tool in every step of React-Native app development process, like to create a React-Native project, install different libraries or run the project in the simulator or in a real device.

In this post, I am going to talk about how to run the React-Native app in an iOS device directly from the terminal. For Android, it is very easy to do. You really do not need to do anything extra for running React Native app in Android physical device. You have to connect your android device to your MAC and in the terminal just type react-native run-android your app will run on the Android device. But to run on the iOS (physical) device you have to open the project in XCode then run it there. But I really hate to do this (because I feel very annoying to change the development environment frequently (VSCode to XCode) and obviously I am a very lazy person 😜). So I have started little research on how to run RN app in iOS device directly from the terminal or command line. 

To run the app on iOS physical device you have to install iOS deploy globally by: 
npm install -g ios-deploy
It will take some time. Wait until it is done. In the meantime set the development team in XCode (Image 1).  Otherwise you will get an error like Image 2. After that build the project in XCode.  Then run the command given below (of course your iOS device has to be connected to your MAC.)
react-native run-ios —device
If your device is connected to your MAC then you will see the app is running on the device. 


Image 1: Set developer team in XCode
Image 2: Error without developer team









Now let’s talk about some requirements you will need.
  1.  A MAC (you can not do this in Windows OS). The macOS must be upper than 10.
  2. Xcode 7 or upper version (though you are not going to use Xcode in the whole procedure still you need to install it in your MAC)
  3. (of course) a physical iOS device like iPhone/iPad
  4. Check the development iOS version and the device OS version. (if you are developing on latest version  but your device is lowest then you will face error)
I hope this post will help you on the journey of React Native app development 😃. So feel free to share this post or you can give me a +1. If you have any doubt leave a comment.

No comments:

Post a Comment