EAS Build

Everything you need to know about Expo Application Services (EAS) Build.

What is EAS Build?

EAS Build is a cloud build service from Expo that compiles your React Native app for iOS and Android. It replaces the deprecated expo build command.

Installation

bash
# Install EAS CLI globally
npm install -g eas-cli

# Login to your Expo account
eas login

# Initialize EAS in your project
eas build:configure

Build Profiles

Configure different build types in eas.json:

eas.json
{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {}
  }
}

Development Profile

  • For local development with Expo Dev Client
  • Includes debugging tools
  • Fast iteration

Preview Profile

  • Internal testing builds
  • TestFlight or APK distribution
  • Production-like environment

Production Profile

  • App Store / Play Store releases
  • Optimized and minified
  • No debugging tools

Build Configuration

iOS Configuration

json
{
  "build": {
    "production": {
      "ios": {
        "buildConfiguration": "Release",
        "scheme": "YourApp",
        "simulator": false
      }
    }
  }
}

Android Configuration

json
{
  "build": {
    "production": {
      "android": {
        "buildType": "apk", // or "app-bundle"
        "gradleCommand": ":app:assembleRelease"
      }
    }
  }
}

Credentials Management

iOS Credentials

EAS can manage your certificates automatically:

bash
# Let EAS handle certificates
eas build --platform ios

# Or use your own
eas credentials

Android Keystore

bash
# Generate new keystore (EAS does this automatically)
eas build --platform android

# Use existing keystore
eas credentials
Keep your keystores secure! Losing your Android keystore means you can't update your app.

Environment Variables

In eas.json

json
{
  "build": {
    "production": {
      "env": {
        "EXPO_PUBLIC_API_URL": "https://api.production.com",
        "EXPO_PUBLIC_ANALYTICS_KEY": "prod-key-123"
      }
    },
    "preview": {
      "env": {
        "EXPO_PUBLIC_API_URL": "https://api.staging.com",
        "EXPO_PUBLIC_ANALYTICS_KEY": "staging-key-456"
      }
    }
  }
}

Using Secrets

bash
# Set secret
eas secret:create --scope project --name API_KEY --value "your-secret-key"

# List secrets
eas secret:list

# Delete secret
eas secret:delete --name API_KEY
json
{
  "build": {
    "production": {
      "env": {
        "API_KEY": "$API_KEY" // References secret
      }
    }
  }
}

Build Commands

Start a Build

bash
# Build for specific platform and profile
eas build --platform ios --profile production

# Build both platforms
eas build --platform all --profile production

# Non-interactive build (for CI/CD)
eas build --platform ios --non-interactive

# Auto-submit after build
eas build --platform ios --auto-submit

Monitor Builds

bash
# List recent builds
eas build:list

# View specific build
eas build:view <build-id>

# Cancel build
eas build:cancel <build-id>

Build Caching

Speed up builds with caching:

json
{
  "build": {
    "production": {
      "cache": {
        "key": "production-cache",
        "paths": [
          "node_modules",
          ".expo"
        ]
      }
    }
  }
}
bash
# Clear build cache
eas build --clear-cache

Custom Build Lifecycle

Pre-build Hook

eas.json
{
  "build": {
    "production": {
      "prebuildCommand": "npm run generate-assets"
    }
  }
}

Post-build Hook

json
{
  "build": {
    "production": {
      "postbuildCommand": "npm run upload-sourcemaps"
    }
  }
}

Local Builds

Build locally instead of in the cloud:

bash
# Build locally
eas build --platform ios --local

# Requires Xcode (iOS) or Android Studio (Android)

Build Optimization

Reduce Bundle Size

metro.config.js
module.exports = {
  transformer: {
    minifierConfig: {
      compress: {
        drop_console: true, // Remove console.logs in production
      },
    },
  },
};

Asset Optimization

  • Use WebP images for better compression
  • Remove unused fonts and icons
  • Enable Hermes for Android (enabled by default)

CI/CD Integration

GitHub Actions

.github/workflows/eas-build.yml
name: EAS Build
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      
      - name: Install dependencies
        run: npm ci
      
      - name: Build
        run: eas build --platform all --non-interactive --no-wait

Troubleshooting

Build Fails

bash
# View detailed logs
eas build:view <build-id>

# Common fixes:
# 1. Clear cache
eas build --clear-cache

# 2. Update EAS CLI
npm install -g eas-cli@latest

# 3. Check credentials
eas credentials

# 4. Validate configuration
npx expo-doctor

iOS Certificate Issues

  • Revoke and regenerate certificates via eas credentials
  • Ensure Bundle ID matches in App Store Connect
  • Check Apple Developer account permissions

Android Keystore Issues

  • Verify keystore credentials are correct
  • Ensure package name is unique
  • Check Google Play Console access

Best Practices

✅ Use build profiles

Separate development, preview, and production configurations

✅ Store secrets securely

Use eas secret for API keys and tokens

✅ Enable caching

Speed up builds with dependency caching

✅ Test preview builds

Always test with preview builds before production

Next Steps