> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# react-native-community/react-native

Orb for building and testing React Native projects.


## Commands

### android_build

Builds the Android app at the given path with the given build types. This should be run only after installing dependencies.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `assemble_android_test` | string | assembleAndroidTest | Configure the android tests to run. Defaults to assembleAndroidTest but you might want to set to app:assembleAndroidTest if that works for your project |
| `build_type` | string | debug | The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app. |
| `cache` | boolean | true | Save and restore the caches? Defaults to true |
| `project_path` | string | ./android | The path to the root of the Android project you want to build, relative to the root of the repository. |

### android_emulator_start

Installs and starts an Android emulator with the given version and name.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `build_tools_version` | string | 28.0.3 | The version of the Android build tools to install. |
| `device_name` | string | TestingAVD | The name of the AVD. You use this name to tell which device to run tests on. |
| `logcat_grep` | string | com.reactnativecommunity | ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters. |
| `platform_version` | string | android-28 | The version of android to run on the emulator. Usually in the form of "android-28". |

### bundle

Bundles all JS files.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `asset_dest` | string |  | The location to output assets to. |
| `bundle_output` | string |  | The location to output the bundle to. |
| `dev` | boolean | false | If we should bundle in dev mode. Defaults to "false" |
| `entry_file` | string | index.js | The entry file for the bundle. Defaults to "index.js". |
| `platform` | string |  | The platform to build for. Usually one of "ios" or "android". |

### detox_build

Builds the app with the given Detox configuration, as specified in package.json.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `configuration` | string |  | The Detox configuration to build. |

### detox_test

Tests the app with the given Detox configuration, as specified in package.json.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `configuration` | string |  | The Detox configuration to test. |
| `loglevel` | enum | warn | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". |

### ios_build

Builds the iOS app at the given path with the given build scheme and configuration. This should be run only after installing NPM dependencies.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `build_configuration` | string | Debug | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. |
| `cache` | boolean | true | Save and restore the build cache? Defaults to true |
| `derived_data_path` | string | ios/build | The path to the directory to place the derived data, relative to the root of the repository. |
| `device` | string | iPhone 11 | The type of device you want to build for. |
| `project_path` | string |  | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. |
| `project_type` | enum | project | If the iOS app is built using a project file (*.xcodeproj) or a workspace. |
| `scheme` | string |  | The scheme to use. |

### ios_simulator_start

Starts an iOS simulator with the given name.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `background` | boolean | true | Should ios simulator boot in background? |
| `device` | string | iPhone 11 | The type of device you want to start. |

### metro_start

Starts the Metro packager.

### ndk_update

Update Android NDK

| Parameter | Type | Default | Description |
|---|---|---|---|
| `version` | string | 22.1.7171670 |  |

### pod_install

install pods

| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache` | boolean | true | Save and restore the cache? Defaults to true |
| `pod_install_command` | string | pod install | The command to run to install pods |
| `pod_install_directory` | string | ios | The location of the "ios" directory |

### setup_macos_executor

Installs the required packages to build and test Android and iOS applications on the MacOS executor. You need to run this before running any other command on those executors.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `android` | boolean | true | Should we set up the Android build environment? Defaults to true |
| `detox` | boolean | true | Should we set up Detox? Defaults to true |
| `homebrew_cache` | boolean | true | Should we cache after brew install? Defaults to true |
| `homebrew_update` | boolean | true | Should we run brew update? Defaults to true |
| `node_version` | string | 16 | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). |

### yarn_install

Install Javascript dependencies using Yarn. This command correctly configures the cache for any number of package.json and yarn.lock files.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache` | boolean | true | Save and restore the build cache? Defaults to true |
| `cache_folder` | string | /tmp/yarn | The path to the yarn cache folder.  Defaults to /tmp/yarn |
| `yarn_install_directory` | string |  | The working directory to run install at. Defaults to yarn's current working directory |

## Jobs

### android_build

Builds the Android app at the given path with the given build types.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `assemble_android_test` | string | assembleAndroidTest | Configure the android tests to run. Defaults to assembleAndroidTest |
| `attach_workspace` | boolean | true | Boolean for whether or not to attach to an existing workspace. Default is true. |
| `build_cache` | boolean | true | Should we cache after Gradle build? Defaults to true |
| `build_image_version` | string | 5.1 | React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags |
| `build_type` | string | debug | The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app. |
| `checkout` | boolean | false | Boolean for whether or not to checkout as a first step. Default is false. |
| `gradle_options` | string | -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError" | Gradle command options. Note that setting this will override the default options so you might need to supply those as well. |
| `on_after_initialize` | string |  | A custom command to run right after yarn install. |
| `persist_to_workspace` | boolean | true | Should this job persist files to a workspace? Defaults to true |
| `project_path` | string | ./android | The path to the root of the Android project you want to build, relative to the root of the repository. |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |
| `store_artifacts` | boolean | true | Store this job store files as job artifacts? Defaults to true |
| `workspace_root` | string | . | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). |
| `yarn_cache` | boolean | true | Should we cache after yarn install? Defaults to true |

### android_test

Tests the Android app on the given device, with the given Detox configuration. You should have already built the correct Android APK (including the androidTest APK) and have both persisted to the worksapce.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `build_tools_version` | string | 28.0.3 | The version of the Android build tools to install. Defaults to '28.0.3'. |
| `detox_configuration` | string | android.emu.release | The Detox configuration to test. Defaults to 'android.emu.release'. |
| `detox_loglevel` | enum | warn | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". |
| `device_name` | string | TestingAVD | The name of the AVD. You use this name to tell which device to run tests on. Defaults to 'TestingAVD'. |
| `homebrew_cache` | boolean | true | Should we cache after brew install? Defaults to true |
| `homebrew_update` | boolean | true | Should we run brew update? Defaults to true |
| `logcat_grep` | string | com.reactnativecommunity | ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters. Defaults to 'com.reactnativecommunity'. |
| `node_version` | string | 16 | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). |
| `on_after_emulator_start` | string |  | A custom command to run right after the android emulator starts. |
| `on_after_initialize` | string |  | A custom command to run right after yarn install. |
| `platform_version` | string | android-28 | The version of android to run on the emulator. Defaults to 'android-28'. |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |
| `should_on_after_emulator_start` | boolean | false | Set this to true if you want to run a custom shell command right after the android emulator starts. Provide the command in on_after_emulator_start command. |
| `should_on_after_initialize` | boolean | false | Set this to true if you want to run a custom shell command right after yarn install. Provide the command in on_after_initialize command. |
| `start_metro` | boolean | false | If we should start the Metro packager in the background for this job. |
| `store_artifact_path` | string |  | Stores detox artifacts at CircleCI |
| `workspace_root` | string | . | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). |
| `xcode_version` | string | 12.5.1 | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions |
| `yarn_cache` | boolean | true | Should we cache after yarn install? Defaults to true |

### ios_build

Builds the iOS app at the given path with the given build scheme

| Parameter | Type | Default | Description |
|---|---|---|---|
| `attach_workspace` | boolean | true | Boolean for whether or not to attach to an existing workspace. Default is true. |
| `build_configuration` | string | Debug | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. |
| `checkout` | boolean | false | Boolean for whether or not to checkout as a first step. Default is false. |
| `derived_data_path` | string | ios/build | The path to the directory to place the derived data, relative to the root of the repository. |
| `device` | string | iPhone 11 | The type of device you want to build for. |
| `homebrew_cache` | boolean | true | Should we cache after brew install? Defaults to true |
| `homebrew_update` | boolean | true | Should we run brew update? Defaults to true |
| `node_version` | string | 16 | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). |
| `on_after_initialize` | string |  | A custom command to run right after yarn install. |
| `pod_cache` | boolean | true | Save and restore the CocoaPods cache? Defaults to true |
| `pod_install_directory` | string |  | The location of the "ios" directory for `pod install`. Will skip `pod install` if missing. |
| `project_path` | string |  | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. |
| `project_type` | enum | project | If the iOS app is built using a project file (*.xcodeproj) or a workspace. |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |
| `scheme` | string |  | The scheme to use. |
| `start_metro` | boolean | false | If we should start the Metro packager in the background for this job. |
| `workspace_root` | string | . | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). |
| `xcode_version` | string | 12.5.1 | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions |
| `xcodebuild_cache` | boolean | true | Should we cache after Xcode build? Defaults to true |
| `yarn_cache` | boolean | true | Should we cache after yarn install? Defaults to true |
| `yarn_cache_folder` | string | /tmp/yarn | The path to the yarn cache folder |

### ios_build_and_test

Builds the iOS app at the given path with the given build scheme and configuration and then runs the tests with the Detox configuration given.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `attach_workspace` | boolean | true | Boolean for whether or not to attach to an existing workspace. Default is true. |
| `build_configuration` | string | Debug | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. |
| `checkout` | boolean | false | Boolean for whether or not to checkout as a first step. Default is false. |
| `derived_data_path` | string | ios/build | The path to the directory to place the derived data, relative to the root of the repository. |
| `detox_configuration` | string | ios.sim.release | The Detox configuration to test. |
| `detox_loglevel` | enum | warn | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". |
| `device` | string | iPhone 11 | The type of device you want to build for. |
| `homebrew_cache` | boolean | true | Should we cache after brew install? Defaults to true |
| `homebrew_update` | boolean | true | Should we run brew update? Defaults to true |
| `node_version` | string | 16 | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). |
| `on_after_initialize` | string |  | A custom command to run right after yarn install. |
| `pod_cache` | boolean | true | Save and restore the CocoaPods cache? Defaults to true |
| `pod_install_directory` | string |  | The location of the "ios" directory for `pod install`. Will skip `pod install` if missing. |
| `project_path` | string |  | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. |
| `project_type` | enum | project | If the iOS app is built using a project file (*.xcodeproj) or a workspace. |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |
| `scheme` | string |  | The scheme to use. |
| `start_metro` | boolean | false | If we should start the Metro packager in the background for this job. |
| `store_artifact_path` | string |  | Stores detox artifacts at CircleCI |
| `workspace_root` | string | . | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). |
| `xcode_version` | string | 12.5.1 | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions |
| `xcodebuild_cache` | boolean | true | Should we cache after Xcode build? Defaults to true |
| `yarn_cache` | boolean | true | Should we cache after yarn install? Defaults to true |
| `yarn_cache_folder` | string | /tmp/yarn | The path to the yarn cache folder |

## Executors

### linux_android

| Parameter | Type | Default | Description |
|---|---|---|---|
| `build_image_version` | string | 5.1 | React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags |
| `gradle_options` | string | -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError" | Gradle command options. Note that setting this will override the default options so you might need to supply those as well. |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |

### linux_js

| Parameter | Type | Default | Description |
|---|---|---|---|
| `node_version` | string | 16.15 | The version of Node to use. This can be a full SemVer point release (such as 16.15.2), or just the minor release (such as 18.2), or a version alias. See https://circleci.com/developer/images/image/cimg/node#image-tags |
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |

### macos

| Parameter | Type | Default | Description |
|---|---|---|---|
| `resource_class` | string | medium | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class |
| `xcode_version` | string | 12.5.1 | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions |

## Examples

### android

An example of how to build, test, and release the Android app

```yaml
version: '2.1'
orbs:
  rn: react-native-community/react-native@1.0.0
jobs:
  analyse_js:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: yarn eslint
          name: Run ESLint
      - run:
          command: yarn flow
          name: Flow
      - run:
          command: yarn jest
          name: Jest
  checkout_code:
    executor: rn/linux_js
    steps:
      - checkout
      - persist_to_workspace:
          paths: .
          root: .
  fastlane_release:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: bundle exec fastlane android release
          name: Run Fastlane
workflows:
  test:
    jobs:
      - checkout_code
      - analyse_js:
          requires:
            - checkout_code
      - rn/android_build:
          build_type: release
          requires:
            - analyse_js
      - rn/android_test:
          requires:
            - rn/android_build
      - fastlane_release:
          requires:
            - rn/android_test
```

### full

A full setup with a Javascript test job, leading to Detox build and test jobs, and finally releasing the apps using a Fastlane command

```yaml
version: '2.1'
orbs:
  rn: react-native-community/react-native@1.0.0
jobs:
  analyse_js:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: yarn eslint
          name: Run ESLint
      - run:
          command: yarn flow
          name: Flow
      - run:
          command: yarn jest
          name: Jest
  checkout_code:
    executor:
      name: rn/linux_js
      node_version: '16'
    steps:
      - checkout
      - persist_to_workspace:
          paths: .
          root: .
  fastlane_android_release:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: echo
          name: Run Fastlane
  fastlane_ios_release:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: echo 1
          name: Run Fastlane
workflows:
  test:
    jobs:
      - checkout_code
      - analyse_js:
          requires:
            - checkout_code
      - rn/android_build:
          build_type: debug
          name: build_android_debug
          project_path: android
          requires:
            - analyse_js
      - rn/android_build:
          build_type: release
          name: build_android_release
          project_path: android
          requires:
            - analyse_js
      - rn/android_test:
          detox_configuration: android.emu.release
          requires:
            - build_android_release
      - rn/ios_build:
          build_configuration: Release
          device: iPhone 11
          name: build_ios_release
          node_version: '12'
          project_path: ios/Example.xcodeproj
          requires:
            - analyse_js
          scheme: Example
      - rn/ios_build_and_test:
          build_configuration: Release
          detox_configuration: ios.sim.release
          device: iPhone 11
          node_version: '12'
          project_path: ios/Example.xcodeproj
          requires:
            - analyse_js
          scheme: Example
      - fastlane_android_release:
          requires:
            - rn/android_test
      - fastlane_ios_release:
          requires:
            - rn/ios_build_and_test
```

### ios

An example of how to build, test, and release the iOS app

```yaml
version: '2.1'
orbs:
  rn: react-native-community/react-native@1.0.0
jobs:
  analyse_js:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: yarn eslint
          name: Run ESLint
      - run:
          command: yarn flow
          name: Flow
      - run:
          command: yarn jest
          name: Jest
  checkout_code:
    executor: rn/linux_js
    steps:
      - checkout
      - persist_to_workspace:
          paths: .
          root: .
  fastlane_release:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          command: bundle exec fastlane ios release
          name: Run Fastlane
workflows:
  test:
    jobs:
      - checkout_code
      - analyse_js:
          requires:
            - checkout_code
      - rn/ios_build:
          build_configuration: Release
          device: iPhone 11
          name: build_ios_release
          project_path: ios/Example.xcodeproj
          requires:
            - analyse_js
          scheme: Example
      - rn/ios_build_and_test:
          build_configuration: Release
          detox_configuration: ios.sim.release
          device: iPhone 11
          project_path: ios/Example.xcodeproj
          requires:
            - analyse_js
          scheme: Example
      - fastlane_release:
          requires:
            - rn/ios_build_and_test
```