Reference version

Expo BuildProperties

GitHub

npm

A config plugin that allows customizing native build properties during prebuild.


expo-build-properties is a config plugin configuring the native build properties of your android/gradle.properties and ios/Podfile.properties.json directories during Prebuild.

This config plugin configures how Prebuild command generates the native android and ios folders and therefore cannot be used with projects that don't run npx expo prebuild (bare projects).

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb

Installation

Terminal
npx expo install expo-build-properties

Usage

Example app.json with config plugin

app.json
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "compileSdkVersion": 31,
            "targetSdkVersion": 31,
            "buildToolsVersion": "31.0.0"
          },
          "ios": {
            "deploymentTarget": "13.0"
          }
        }
      ]
    ]
  }
}

Example app.config.js usage

app.config.js
export default {
  expo: {
    plugins: [
      [
        'expo-build-properties',
        {
          android: {
            compileSdkVersion: 31,
            targetSdkVersion: 31,
            buildToolsVersion: '31.0.0',
          },
          ios: {
            deploymentTarget: '13.0',
          },
        },
      ],
    ],
  },
};

All configurable properties

PluginConfigType interface represents currently available configuration properties.

API

Methods

BuildProperties.withBuildProperties(config, props)

NameTypeDescription
configExpoConfig

Expo config for application.

propsPluginConfigType

Configuration for the build properties plugin.


Config plugin allowing customizing native Android and iOS build properties for managed apps.

Returns:

ExpoConfig

Interfaces

Only for:
iOS

ExtraIosPodDependency

Interface representing extra CocoaPods dependency.

See: Podfile syntax reference

ExtraIosPodDependency Properties

NameTypeDescription
branch
(optional)
string

The git branch to fetch. See the git property for more information.

commit
(optional)
string

The git commit to fetch. See the git property for more information.

configurations
(optional)
string[]

Build configurations for which the pod should be installed.

Example

['Debug', 'Release']

git
(optional)
string

Use the bleeding edge version of a Pod.

Example{ "name": "AFNetworking", "git": "https://github.com/gowalla/AFNetworking.git", "tag": "0.7.0" }

This acts like to add this pod dependency statement:

pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
modular_headers
(optional)
boolean

Whether this pod should use modular headers.

namestring

Name of the pod.

path
(optional)
string

Custom local filesystem path to add the dependency.

Example

~/Documents/AFNetworking

podspec
(optional)
string

Custom podspec path.

Example

https://example.com/JSONKit.podspec

source
(optional)
string

Custom source to search for this dependency.

Example

https://github.com/CocoaPods/Specs.git

tag
(optional)
string

The git tag to fetch. See the git property for more information.

testspecs
(optional)
string[]

Test specs can be optionally included via the :testspecs option. By default, none of a Pod's test specs are included.

Example

['UnitTests', 'SomeOtherTests']

version
(optional)
string

Version of the pod. CocoaPods supports various versioning options.

Example

~> 0.1.2


PluginConfigType

Interface representing base build properties configuration.

PluginConfigType Properties

NameTypeDescription
android
(optional)
PluginConfigTypeAndroid
Only for:
Android

Interface representing available configuration for Android native build properties.

ios
(optional)
PluginConfigTypeIos
Only for:
iOS

Interface representing available configuration for iOS native build properties.


Only for:
Android

PluginConfigTypeAndroid

Interface representing available configuration for Android native build properties.

PluginConfigTypeAndroid Properties

NameTypeDescription
buildToolsVersion
(optional)
string

Override the default buildToolsVersion version number in build.gradle.

compileSdkVersion
(optional)
number

Override the default compileSdkVersion version number in build.gradle.

enableProguardInReleaseBuilds
(optional)
boolean

Enable Proguard or R8 in release builds to obfuscate Java code and reduce app size.

enableShrinkResourcesInReleaseBuilds
(optional)
boolean

Enable shrinkResources in release builds to remove unused resources from the app. This property should be used in combination with enableProguardInReleaseBuilds.

extraMavenRepos
(optional)
string[]

Add extra maven repositories to all gradle projects.

This acts like to add the following code to android/build.gradle:

allprojects {
  repositories {
    maven {
      url [THE_EXTRA_MAVEN_REPOSITORY]
    }
  }
}
extraProguardRules
(optional)
string

Append custom Proguard rules to android/app/proguard-rules.pro.

flipper
(optional)
string

By default, Flipper is enabled with the version that comes bundled with react-native.

Use this to change the Flipper version when running your app on Android. You can set the flipper property to a semver string and specify an alternate Flipper version.

kotlinVersion
(optional)
string

Override the Kotlin version used when building the app.

minSdkVersion
(optional)
number

Override the default minSdkVersion version number in build.gradle.

networkInspector
(optional)
boolean

Enable the Network Inspector.

Default: true
newArchEnabled
(optional)
boolean

Enable React Native new architecture for Android platform.

packagingOptions
(optional)
PluginConfigTypeAndroidPackagingOptions

Interface representing available configuration for Android Gradle plugin PackagingOptions.

targetSdkVersion
(optional)
number

Override the default targetSdkVersion version number in build.gradle.

usesCleartextTraffic
(optional)
boolean

Indicates whether the app intends to use cleartext network traffic.

Default: false

Only for:
Android

PluginConfigTypeAndroidPackagingOptions

Interface representing available configuration for Android Gradle plugin PackagingOptions.

PluginConfigTypeAndroidPackagingOptions Properties

NameTypeDescription
doNotStrip
(optional)
string[]

Array of patterns for native libraries that should not be stripped of debug symbols.

exclude
(optional)
string[]

Array of patterns for native libraries that should be excluded from being packaged in the APK.

merge
(optional)
string[]

Array of patterns for native libraries where all occurrences are concatenated and packaged in the APK.

pickFirst
(optional)
string[]

Array of patterns for native libraries where only the first occurrence is packaged in the APK.


Only for:
iOS

PluginConfigTypeIos

Interface representing available configuration for iOS native build properties.

PluginConfigTypeIos Properties

NameTypeDescription
deploymentTarget
(optional)
string

Override the default iOS "Deployment Target" version in the following projects:

  • in CocoaPods projects,
  • PBXNativeTarget with "com.apple.product-type.application" productType in the app project.
extraPods
(optional)
ExtraIosPodDependency[]

Add extra CocoaPods dependencies for all targets.

This acts like to add the following code to ios/Podfile:

pod '[EXTRA_POD_NAME]', '~> [EXTRA_POD_VERSION]' # e.g. pod 'Protobuf', '~> 3.14.0'
flipper
(optional)
string | boolean

Enable Flipper when running your app on iOS in Debug mode. Setting true enables the default version of Flipper, while setting a semver string will enable a specific version of Flipper you've declared in your package.json. The default for this configuration is false.

You cannot use flipper at the same time as useFrameworks, and doing so will generate an error.

networkInspector
(optional)
boolean

Enable the Network Inspector.

Default: true
newArchEnabled
(optional)
boolean

Enable React Native new architecture for iOS platform.

useFrameworks
(optional)
'static' | 'dynamic'

Enable use_frameworks! in Podfile to use frameworks instead of static libraries for Pods.

You cannot use useFrameworks and flipper at the same time, and doing so will generate an error.