Skip to main content
Prebuild generates the ios/ and android/ directories from your app.json configuration and installed packages. It’s like a bundler for native code.

What is Prebuild?

Prebuild transforms your Expo project configuration into native iOS and Android projects:

Why Use Prebuild?

Advantages

  • Reproducible: Same app.json = same native projects
  • Version control: Can ignore ios/ and android/ in git
  • Easy updates: Regenerate when config changes
  • Config plugins: Modify native code declaratively
  • Clean slate: Reset native projects anytime

When to Use

  1. Development builds: Generate native code for custom modules
  2. CI/CD: Reproducible native projects in CI
  3. Config changes: When updating app.json plugins
  4. Clean start: Reset corrupted native projects

Running Prebuild

Basic Usage

Options

Prebuild Process

1

1. Read configuration

Prebuild reads your app.json and evaluates config plugins:
app.json
2

2. Generate base projects

Creates native projects from template:
3

3. Apply config plugins

Runs plugins to modify native code:
4

4. Install dependencies

Installs native dependencies:

Clean vs Modified Projects

Clean Projects

Native projects that can be regenerated from config:
Pros:
  • Always in sync with config
  • No merge conflicts in native code
  • Easy to update SDK versions
Cons:
  • Must run prebuild before building
  • Can’t make manual native changes
  • Requires CI to run prebuild

Modified Projects

Projects with manual native modifications:
Pros:
  • Can make any native changes
  • No prebuild step needed
  • Direct control over native code
Cons:
  • Hard to keep in sync with config
  • Merge conflicts in native code
  • Manual SDK updates

Config Plugins

Plugins modify native projects declaratively.

Using Plugins

app.json

Creating Custom Plugins

plugins/withCustomConfig.js

Plugin Examples

Modify iOS Entitlements

Add Android Permissions

Modify Gradle

Templates

Prebuild uses templates to generate native projects.

Default Template

Custom Template

Template Structure

template.config.js

Workflow Strategies

Workflow:
When to use:
  • Standard Expo modules only
  • No custom native code
  • Team prefers simplicity
  • CI/CD builds

Strategy 2: Modified Projects

Workflow:
When to use:
  • Custom native code
  • Third-party SDKs
  • Advanced configurations
  • Need full native control

Strategy 3: Hybrid

Workflow:

CI/CD Integration

GitHub Actions

.github/workflows/build.yml

EAS Build

EAS Build runs prebuild automatically:
eas.json

Troubleshooting

Prebuild Fails: Package Conflicts

Solution:

Native Directories Out of Sync

CocoaPods Install Fails

Solution:

Gradle Sync Fails

Solution:

Plugin Errors

Solution:

Best Practices

1. Use Clean Projects When Possible

Regerate anytime:

2. Document Custom Changes

If modifying native code:
NATIVE_CHANGES.md

3. Test After Prebuild

4. Keep Config Plugins Simple

5. Version Lock Templates

app.json
Prebuild uses matching template version automatically.

Next Steps

Build Properties

Configure native build settings

Creating Builds

Build your prebuilt project

Native Modules

Create custom native modules

Monorepos

Use prebuild in monorepos