Skip to main content

Expo Prebuild and Continuous Native Generation Explained

· 5 min read

Expo makes it possible to build React Native apps without manually maintaining Xcode and Android Studio projects for every change. But as soon as you add a native dependency or need a custom native setting, you may encounter Expo Prebuild and Continuous Native Generation (CNG).

They are related concepts, but they are not the same thing.

What is Expo Prebuild?​

Prebuild generates the native iOS and Android project directories from your Expo app configuration and installed dependencies.

From the project root, run:

npx expo prebuild

The command creates or updates the native project structure, including:

my-app/
app.json
package.json
ios/
android/

After generating the native projects, you can compile with commands such as:

npx expo run:ios
npx expo run:android

Generating the folders does not automatically mean you must abandon Expo tooling. You can continue using Expo packages, Expo CLI, and compatible EAS services.

What is Continuous Native Generation?​

CNG is a workflow built around treating native projects as generated output instead of hand-maintained source code.

The idea is straightforward:

  1. Describe the app in your Expo configuration.
  2. Install native libraries that support your workflow.
  3. Configure native settings through Expo config plugins.
  4. Generate the native projects when they are needed.

This makes it easier to reproduce native builds and apply SDK upgrades without manually carrying forward every generated project-file change.

Prebuild is the command; CNG is the workflow that uses that command consistently.

A practical example: app name and permissions​

Suppose your app needs a display name and a camera permission description. Start with the configuration instead of editing native files:

{
"expo": {
"name": "Field Notes",
"slug": "field-notes",
"ios": {
"infoPlist": {
"NSCameraUsageDescription": "Allow Field Notes to capture photos for entries."
}
}
}
}

During Prebuild, Expo uses the app configuration to populate the applicable native project settings.

For functionality outside the built-in app config fields, a package may provide a config plugin.

What are config plugins?​

A config plugin applies native project changes during Prebuild. Plugins can set permissions, modify native project configuration, or integrate a supported native library.

You register one in the plugins array of the Expo app configuration. For example, when using expo-camera:

{
"expo": {
"plugins": [
[
"expo-camera",
{
"cameraPermission": "Allow this app to take photos."
}
]
]
}
}

Install the package using Expo's version-aware installer:

npx expo install expo-camera

The plugin configuration is applied when the native project is generated or regenerated. It is not a substitute for rebuilding the native app after native configuration changes.

When should you use --clean?​

You may see this command in documentation or troubleshooting guides:

npx expo prebuild --clean

The --clean option recreates the generated native project directories. This is useful when you want to confirm that your app can be built from its configuration alone.

Be careful: manual edits to ios/ or android/ can be lost during a clean regeneration. Commit your changes before experimenting, and move repeatable native modifications into config plugins where practical.

Should you commit ios/ and android/?​

There is no single correct answer for every project.

ApproachWorks well whenMain consideration
Generate native folders as neededMost native settings are expressed through app config and pluginsBuilds need to reproduce the same generated configuration
Commit native foldersYou actively maintain custom Xcode/Gradle changes or complex native codeYou are responsible for reviewing and merging native changes during upgrades

Whichever approach you choose, document it so teammates and CI pipelines do not accidentally overwrite native work.

Prebuild vs Expo Go vs development builds​

These terms solve different problems:

  • Expo Go is a ready-made app for quickly running projects that fit its included native capabilities.
  • Prebuild generates the native project files for your particular app.
  • A development build is a custom app binary containing the native dependencies your project needs.

If your app needs a native module unavailable in Expo Go, you typically build a development client rather than expecting Expo Go to load the new native code.

Common mistakes​

Editing a generated file and expecting it to survive​

A change made directly inside Info.plist, AndroidManifest.xml, or a Gradle file may disappear after prebuild --clean. Prefer supported app config settings or plugins if you plan to regenerate native projects.

Using prebuild --clean as a routine fix for every issue​

Regenerating native projects can be disruptive. Start by identifying whether the problem is JavaScript, configuration, native dependency linking, or the native build itself.

Assuming native configuration updates are over-the-air updates​

JavaScript and asset updates do not replace a native binary. Changes that add native modules or alter native project settings normally require a new native build.

When is CNG a good fit?​

CNG is particularly useful when your team wants repeatable native configuration and prefers to make most application changes through Expo configuration and packages. It is also useful in CI, where deterministic regeneration matters.

If your project has substantial hand-written native application code, you can still use Expo modules and other Expo tools without making native regeneration the center of your workflow.

The practical rule: Keep native changes declarative when possible, and choose a native-project ownership model that fits your app's complexity.

Further reading​