DEV Community

Anna
Anna

Posted on

Why and How to Start Using Xcode to Build Your React Native iOS Apps ASAP

Many of us involved in mobile application development with React Native have been used to working on Expo. This makes complete sense since the React Native documentation itself has indicated that it is the easiest way to get started.

That said, if you are interested in eventually publishing your app on the App store, you might want to start getting used to working with Xcode. That’s because starting April 2021, all iOS and iPadOS apps submitted to the App Store will be required to be built using Xcode 12.

So, let’s get started. If you don’t already have Node and Watchman installed, you should get them via Homebrew using the following terminal commands:

brew install node
brew install watchman

While you probably have these as a React Native developer, it is a good idea to at least install Node 10 or later.

Of course, you’ll need to install Xcode. You can just download it from the app store here. Next, you’ll need CocoaPods, which manages library dependencies for your projects when using Xcode. So, install using:

sudo gem install cocoapods

Now we’re ready – are you exiting to get started on your new app? To start a new project, navigate to where you would like to save it, then in your terminal type,

npx react-native init <the name of your new project>

Your project will have starter boilerplate code, which you will be able to see once you open it in your code editor. To run your project and view it in a mobile device simulator, simply type,

npx react-native start
npx react-native run-ios

Now you are ready to start programming and to see your work on the simulator. Happy coding!

Top comments (2)

Collapse
 
sakko profile image
SaKKo

Hi, just a suggestion.
Since cocoapods is coded by ruby, there maybe time in the future that you might need to update your ruby version and this gem may break. Also, i'm not a big fan fo sudo gem install _____. it's root and most of the time it's not necessary.

I would suggest you to install rvm first, follow this url.
github.com/rvm/rvm

Once rvm is installed, restart terminal then install ruby (latest now is 2.7.2)
rvm install 2.7.2
NOTE: you can install other versions as well.

You can now swap to use this ruby version using
rvm use 2.7.2
to set this version as default run
rvm use 2.7.2 --default

Once your are on 2.7.2 (try checking with ruby -v) you can now run
gem install cocoapods

ps1: you don't need root permission to install cocoapods.
ps2: rvm will also install homebrew for you. you might find it useful later.

Collapse
 
analyticsinstitute profile image
Anna

Thank you! I'll check it out