Skip to content
Documentation
Esc
↑↓navigate↵open⌘Jpreview
On this page

Build bare React Native apps for iOS and Android without a Mac

How Limrun installs Node packages and CocoaPods for React Native apps without Expo, and how to load JavaScript from Metro on a cloud device.

Build a React Native app that commits its own ios/ and android/ projects with lim xcode build and lim gradle build, then run it on a cloud iOS simulator or Android emulator. The sandbox installs the app’s Node packages before CocoaPods and Gradle read them, so you sync only your source.

This page covers apps without Expo. For an Expo app, including one with committed native projects, see Expo.

Before you start

  • Install the CLI with npm install --global lim and set LIM_API_KEY in the shell that runs it. See Set up your coding agent for agent environments.
  • Run the commands on this page from the app’s root folder, the one with package.json, ios/, and android/.

How the sandbox prepares the app

A React Native app’s ios/Podfile and Android Gradle settings load scripts from node_modules/, which .gitignore usually excludes. The sync skips paths your .gitignore excludes, so the sandbox installs the packages itself.

When the root package.json lists react-native in dependencies or devDependencies, a lim xcode build or lim gradle build:

  1. Installs Node packages with the project’s package manager. A packageManager field in package.json selects it; otherwise the lockfile does, with npm as the fallback.
  2. On iOS, runs pod install from ios/Podfile, unless the Podfile inputs are unchanged since the last build.
  3. Runs xcodebuild or Gradle.

A custom Gradle command run with lim gradle run skips these steps. Later builds on the same sandbox skip the install while package.json and the lockfile are unchanged. An npm project’s build log starts like this:

$ npm install --include=dev
...
added 858 packages, and audited 859 packages in 4s

Build for iOS

Build the app and install it on a cloud simulator:

lim xcode build . --ios

--ios reuses a recent Xcode sandbox with an attached iOS simulator, or creates and attaches both, and installs and launches every successful build on the simulator. The sandbox finds the .xcworkspace that pod install writes in ios/ and builds the project’s app target as the scheme. To build another scheme, pass --scheme. Build with remote Xcode covers the other build flags, uploads, and signing.

Build for Android

Build the debug APK on a Gradle sandbox:

lim gradle build .

The sandbox finds the Gradle project in android/ and runs assembleDebug with the project’s wrapper. If it finds more than one Gradle project, pass --project-path android. To install every successful build on a cloud emulator, create one and attach it to the sandbox:

lim android create --no-connect
lim gradle attach-emulator

attach-emulator installs the latest APK right away and later builds as they finish. Both commands default to the instances you created last; pass IDs to choose others. See Build with Gradle.

Load JavaScript from Metro

A Debug build loads its JavaScript from Metro on port 8081 instead of from the app bundle: an iOS simulator build at localhost:8081, an Android emulator build at 10.0.2.2:8081. A tunnel sends those connections from the cloud device to Metro on your machine.

Start Metro from the app folder and keep it running:

npx react-native start

In a second terminal, open a tunnel for port 8081 and relaunch the app so it connects through the tunnel. Replace the app ID with your bundle identifier or Android application ID:

lim ios tunnel --selector localhost:8081 --detach
lim ios launch-app com.example.app --mode RelaunchIfRunning --detach
lim android tunnel --selector localhost:8081 --detach
lim android launch-app com.example.app --mode RelaunchIfRunning --detach

On Android, a localhost:8081 selector also covers 10.0.2.2:8081, the address the emulator build uses. Metro’s terminal shows the bundle request when the app connects. Connect to local services covers tunnel limits and traffic inspection.

lim xcode build --dev-server-url does not apply here: the sandbox accepts it only for Expo apps.

Run without Metro

A Release build bundles its JavaScript, so it runs without Metro:

lim xcode build . --ios --configuration Release
lim gradle build . --task :app:assembleRelease

The React Native template signs Android release builds with its debug keystore, so the APK installs on an attached emulator. To sign for Google Play or the App Store, see Sign and publish and Sign and distribute.

Limits

  • The app must sit at the root of the synced folder. The sandbox reads only the root package.json, so a React Native app nested in a monorepo is not detected yet. Its build runs without the install and fails where CocoaPods or Gradle first reads node_modules/.
  • The package manager must be unambiguous. Lockfiles from two package managers, such as yarn.lock next to package-lock.json, or a yarn.lock whose Yarn version the sandbox cannot tell, leave the choice open. The build then runs without the install and fails the same way. Keep one lockfile, or set packageManager in package.json.
  • Expo apps take the Expo pipeline on iOS. When the root package.json lists expo and the root has an app.json or app.config file, the Xcode sandbox builds the app as an Expo app. See Expo.

Next steps

Last updated on