React Native DevOps: iOS

Part Two: Building

Jake Myers
Red Squirrel
3 min readOct 19, 2020

--

Non-native mobile ecosystems like Flutter and React Native have evolved at a rapid pace, leaving behind a collection of outdated articles. Rather than writing another prescriptive tutorial, the goal of this series is for you to learn, at a high level, about each part of the mobile deploy process and how one might go about configuring continuous integration for their project.

Note: This article is part two in a series around React Native DevOps and using tools like fastlane to make life easier. Links to the other articles in the series can be found at the end of the article.

Photo by Artem Sapegin on Unsplash

fastlane build_app

That’s it. That’s all we need to type into our console for fastlane to do its magic and spit out a packaged iOS app. But what’s behind all that magic and simplicity?

For some insight, let’s take a look at how to manually build an iOS app through the tools provided by Xcode.

Clean

It’s prudent to clean your build folder before building a new version for release, when switching to a version of code that is different than your current local version, when dependencies change, or when you are having unexplained issues.

This one’s pretty straightforward. Just select Product > Clean Build Folder from Xcode’s menu, or press Shift + Command + K on your keyboard.

The “Clean Build Folder” command is highlighted in Xcode’s “Product” menu.

Archive

This is the actual meat of the building process. The result is a bundle that contains everything needed to publish an app to the App Store.

After cleaning the project, select Archive from Xcode’s Product menu. This will start a build process that when finished will be uploaded to the App Store via Xcode.

Note: you must have a suitable or generic device selected in the Devices dropdown.

The “Archive” command is highlighted in Xcode’s “Product” menu.

Command Line Alternatives

Cleaning and archiving can also be done via the CLI. The Xcode Command Line Tools can be installed on your machine by running xcode-select --install in the Terminal. These tools include the xcodebuild command which has a variety of uses.

To clean an app:

xcodebuild clean -workspace MyAppWorkspace.xcworkspace -scheme my_app_scheme

To build an app for local use:

xcodebuild -workspace MyAppWorkspace.xcworkspace -scheme my_app_scheme

To archive an app:

xcodebuild archive -workspace MyAppWorkspace.xcworkspace -scheme my_app_scheme -archivePath ~/WhereverYouWant/my_app.xcarchive

Fastlane

The fastlane command build_app uses CLI commands like these to do its magic. This makes it easier for you, or a continuous integration machine, to build apps without even opening Xcode.

Next Steps

After code-signing, which we dove into in our last article, and building our app, which we covered here, there are only a few more steps until our app is live in the App Store!

Our next article on React Native DevOps will focus on different ways to distribute beta and production builds to the App Store and Testflight, and how we can use fastlane to make it simple.

Other articles in this series:

--

--