Mobile development · Advanced · 20 min
Change native iOS and Android settings with Expo config plugins and prebuild
By Padding · Updated 18 Nov 2026
Expo SDK 58 · Node.js 26 · node:26 (Debian)
You will generate the android and ios folders of an Expo SDK 58 app with npx expo prebuild, change the Android minimum SDK and R8 minification with expo-build-properties, and write a local config plugin that adds a manifest attribute and an Info.plist key, checking each change in the generated files.
On this page
An Expo app is still a native iOS app and a native Android app. Somewhere there is an AndroidManifest.xml, a build.gradle, an Info.plist and an Xcode project. The difference is who owns those files. In Expo's Continuous Native Generation (CNG) model, you do not. npx expo prebuild writes the android and ios folders from a template, your app.json and the config plugins of the libraries you install. The folders are output, like a dist folder on the web, so they stay out of Git and can be thrown away and regenerated at any time.
That raises a practical question: if you must not edit those files, how do you change a native setting? This tutorial answers it with a small blank app. You set two Android build settings with the expo-build-properties plugin, then write your own config plugin that edits the Android manifest and the iOS Info.plist. After each change you regenerate the folders and read the result, so you can see exactly what each plugin did. Every command here runs on Linux, macOS or Windows with WSL. Building the native projects needs Android Studio or Xcode, and comes last.
Step 1 · Create a blank app and give it native identifiers
Create a TypeScript app from the blank template in a practice folder. The @sdk-58 suffix fixes the template to Expo SDK 58:
mkdir -p ~/native-settings-demo
cd ~/native-settings-demo
npx create-expo-app@5.0.0 native-settings --template blank-typescript@sdk-58Install expo-build-properties now, while the project still has only app.json. You configure it in a later step. npx expo install picks the version that matches your SDK and adds the plugin's name to the plugins list in app.json:
cd ~/native-settings-demo/native-settings
npx expo install expo-build-propertiesIt ends with Added config plugin: expo-build-properties. With no options the plugin changes nothing yet.
A native project needs an Android application ID and an iOS bundle identifier, and the template has neither. Prebuild asks for them when it runs in a terminal, but a script or CI job has no one to answer, so set them up front. Instead of editing app.json, add an app.config.js next to it. Expo reads app.json first and passes it to this file as config, so you only write the parts you change:
cd ~/native-settings-demo/native-settings
cat > app.config.js <<'JS'
// Replace com.example.nativesettings with your own reverse-domain ID.
const APP_ID = 'com.example.nativesettings'
module.exports = ({ config }) => ({
...config,
ios: { ...config.ios, bundleIdentifier: APP_ID },
android: { ...config.android, package: APP_ID },
})
JSPick the real ID before your first store upload: Google Play and the App Store treat it as the app's permanent identity, and you cannot change it later. From now on, npx expo install cannot write to app.config.js for you: when a library you add has a plugin, it prints the entry to add and exits with an error, and you add the entry by hand.
Check it worked
cd ~/native-settings-demo/native-settings
npx expo config --type public --json | node -e "const c=JSON.parse(require('fs').readFileSync(0,'utf8')); console.log(c.android.package, c.ios.bundleIdentifier)"The output is com.example.nativesettings com.example.nativesettings. npx expo config prints the config Expo actually uses after reading both files, which is the fastest way to catch a typo in app.config.js.
Step 2 · Generate the native folders with prebuild
Run prebuild for both platforms. --no-install skips the CocoaPods install for iOS, which only works on macOS, and leaves npm alone:
cd ~/native-settings-demo/native-settings
npx expo prebuild --no-install
ls android iosPrebuild unpacks the expo-template-bare-minimum template that matches SDK 58, runs every config plugin, and writes the result. You get android with Gradle files and an app module, and ios with an Xcode project and a Podfile. On Linux the iOS files are still generated. You need a Mac to install the pods and build them. A line such as userInterfaceStyle: Install expo-system-ui in your project to enable this feature is a warning about a setting this app does not need, not an error.
The template's .gitignore already ends with /ios and /android. That is the CNG contract: the source of truth is app.json, app.config.js, package.json and any plugins, and the folders are rebuilt from them.
Check it worked
Initialise Git (create-expo-app may already have done so) and list what it would commit:
cd ~/native-settings-demo/native-settings
git init --quiet
if git check-ignore -q android && git check-ignore -q ios; then echo "android and ios are ignored"; else echo "NOT ignored"; false; fiThe command prints android and ios are ignored. git check-ignore -q prints nothing and succeeds only when a path matches a .gitignore rule. If you see NOT ignored, the two .gitignore lines are missing: add them back before you commit.
Step 3 · Change Android build settings with expo-build-properties
Some settings live in Gradle rather than in the manifest: the lowest Android version the app installs on, and whether release builds run R8, the tool that removes unused code and shortens class names. The expo-build-properties library you installed in the first step is a config plugin for exactly these.
Before you give it options, take a copy of the current android folder. You will compare against it to see what the plugin really changes:
cd ~/native-settings-demo
rm -rf snapshots
mkdir snapshots
cp -R native-settings/android snapshots/android-beforeNow replace app.config.js with a version that lists the plugin and its options:
cd ~/native-settings-demo/native-settings
cat > app.config.js <<'JS'
// Replace com.example.nativesettings with your own reverse-domain ID.
const APP_ID = 'com.example.nativesettings'
module.exports = ({ config }) => ({
...config,
ios: { ...config.ios, bundleIdentifier: APP_ID },
android: { ...config.android, package: APP_ID },
plugins: [
[
'expo-build-properties',
{
android: {
minSdkVersion: 26,
enableMinifyInReleaseBuilds: true,
enableShrinkResourcesInReleaseBuilds: true,
},
},
],
],
})
JSThis plugins list replaces the one in app.json, which still names expo-build-properties from the install step. In your own app, either keep every plugin in this one list or start from ...(config.plugins ?? []) and add to it, otherwise any plugin listed only in app.json is silently dropped.
minSdkVersion: 26 means Android 8.0 or newer. Raise it only when a library or feature needs it, and check your audience first: in many markets, including much of Africa, a large share of people use older, low-cost Android phones, and every step up locks some of them out of installing your app. enableMinifyInReleaseBuilds runs R8 on release builds. The SDK 58 template already switches it on, so listing it here records the choice and keeps it if a later template changes the default. enableShrinkResourcesInReleaseBuilds is new: it removes images and layouts nothing refers to, which makes the download smaller on prepaid data. R8 can remove classes that are only reached by reflection, so test a release build whenever these settings change.
Next you regenerate with --clean, which deletes android and ios first. In a terminal it can stop to warn you about uncommitted Git changes, so commit your config before every clean run. That way a clean run never puts work at risk:
cd ~/native-settings-demo/native-settings
git add -A
git commit --quiet -m "Configure expo-build-properties"Now regenerate the folders. The result comes only from your config, with nothing left over from the previous run:
cd ~/native-settings-demo/native-settings
npx expo prebuild --clean --no-install --platform androidCheck it worked
cd ~/native-settings-demo/native-settings
grep -x 'android.minSdkVersion=26' android/gradle.properties
grep -x 'android.enableMinifyInReleaseBuilds=true' android/gradle.properties
grep -x 'android.enableShrinkResourcesInReleaseBuilds=true' android/gradle.propertiesEach grep -x matches only the whole line, so the output is exactly android.minSdkVersion=26, android.enableMinifyInReleaseBuilds=true and android.enableShrinkResourcesInReleaseBuilds=true. If any line is missing or has a different value, that grep prints nothing and fails. The plugin did not touch build.gradle. It wrote properties that the template's Gradle files already read.
Step 4 · Review what a plugin changes before you trust it
A library's config plugin runs your build. It can add permissions, change signing settings or download code, so read its effect the same way you read a dependency's code. Compare the snapshot with the new folder:
cd ~/native-settings-demo
diff -ru snapshots/android-before native-settings/android > snapshots/build-properties.diff || true
grep '^diff ' snapshots/build-properties.diff
grep '^[-+][^-+]' snapshots/build-properties.diffdiff exits with status 1 whenever the folders differ, which is expected here, so || true keeps the command from reporting a failure. The first grep lists one header line per changed file. Expect exactly one: diff -ru snapshots/android-before/gradle.properties native-settings/android/gradle.properties. The second grep shows only the changed lines. Expect +android.minSdkVersion=26 and +android.enableShrinkResourcesInReleaseBuilds=true, plus a - and + pair for the last line of the file, which only gained a line break. enableMinifyInReleaseBuilds does not appear, because the template already had it set to true. Nothing else changed. A plugin that also added a uses-permission line or a new Maven repository would show up here too, which is your cue to read its source.
To read that source, look at the plugin's entry point inside node_modules. Expo looks for an app.plugin.js at the package root first and falls back to the package's main entry, and most plugin packages ship one. expo-build-properties does:
cd ~/native-settings-demo/native-settings
cat node_modules/expo-build-properties/app.plugin.jsCheck it worked
The grep '^diff ' line names only gradle.properties, and app.plugin.js is one line that loads the package's built plugin. Follow that path (build/withBuildProperties.js) if you want to read the full implementation.
Step 5 · Write a local config plugin
Some settings have no ready-made plugin. Here are two examples:
- On Android,
android:appCategoryon the<application>element tells the system what kind of app this is, so settings screens can group its battery and data use with similar apps. - On iOS,
ITSAppUsesNonExemptEncryptionset tofalseinInfo.plisttells App Store Connect that the app uses only standard, exempt encryption such as HTTPS, so it stops asking the export compliance question on every upload. Set it tofalseonly if that is true for your app.
A config plugin is a function that takes the Expo config and returns it with changes queued. The helpers withAndroidManifest and withInfoPlist hand your callback the parsed file as modResults. You edit that object and return it, and prebuild writes it back. Create the plugin in a plugins folder:
cd ~/native-settings-demo/native-settings
mkdir -p plugins
cat > plugins/with-store-defaults.js <<'JS'
const { AndroidConfig, withAndroidManifest, withInfoPlist } = require('expo/config-plugins')
const CATEGORIES = ['accessibility', 'audio', 'game', 'image', 'maps', 'news', 'productivity', 'social', 'video']
function withStoreDefaults(config, { appCategory = 'productivity', usesNonExemptEncryption = false } = {}) {
if (!CATEGORIES.includes(appCategory)) {
throw new Error(`with-store-defaults: appCategory must be one of ${CATEGORIES.join(', ')}`)
}
config = withAndroidManifest(config, (cfg) => {
const application = AndroidConfig.Manifest.getMainApplicationOrThrow(cfg.modResults)
application.$['android:appCategory'] = appCategory
return cfg
})
config = withInfoPlist(config, (cfg) => {
cfg.modResults.ITSAppUsesNonExemptEncryption = usesNonExemptEncryption
return cfg
})
return config
}
module.exports = withStoreDefaults
JSNotes on the code:
require('expo/config-plugins')loads the plugin helpers through theexpopackage, so the version always matches your SDK. Do not add@expo/config-pluginstopackage.jsonyourself.- The manifest arrives as the XML converted to objects. Attributes of an element sit under
$, which is why the line readsapplication.$['android:appCategory']. Info.plistarrives as a plain object, so a key is a property and a plist boolean is a JavaScripttrueorfalse.- The plugin checks its input and throws a clear error. A typo then fails at prebuild, not in a store review weeks later.
For a single fixed plist value, ios.infoPlist in app.json is enough and needs no plugin. A plugin earns its place when you change both platforms together, need logic or validation, or want to reuse the same change across several apps.
Check it worked
cd ~/native-settings-demo/native-settings
node -e "console.log(typeof require('./plugins/with-store-defaults.js'))"The output is function. A syntax error would print the file and line instead.
Step 6 · Register the plugin and preview its effect
Add the plugin to the plugins list, after expo-build-properties, with its options. A local plugin is named by its path relative to the project:
cd ~/native-settings-demo/native-settings
cat > app.config.js <<'JS'
// Replace com.example.nativesettings with your own reverse-domain ID.
const APP_ID = 'com.example.nativesettings'
module.exports = ({ config }) => ({
...config,
ios: { ...config.ios, bundleIdentifier: APP_ID },
android: { ...config.android, package: APP_ID },
plugins: [
[
'expo-build-properties',
{
android: {
minSdkVersion: 26,
enableMinifyInReleaseBuilds: true,
enableShrinkResourcesInReleaseBuilds: true,
},
},
],
['./plugins/with-store-defaults', { appCategory: 'productivity', usesNonExemptEncryption: false }],
],
})
JSBefore writing any files, ask Expo to run the plugins in memory and show the result. The introspect type evaluates the modifiers that are safe to preview, including Info.plist, and prints the final config:
cd ~/native-settings-demo/native-settings
npx expo config --type introspect --json > introspect.json
node -e "const c=require('./introspect.json'); console.log('ITSAppUsesNonExemptEncryption =', c.ios.infoPlist.ITSAppUsesNonExemptEncryption)"Check it worked
The output is ITSAppUsesNonExemptEncryption = false. If the plugin threw an error, npx expo config prints the message instead, so you can test a bad option without touching the native folders. Change appCategory to 'clinic' and run it again to see the error, then change it back. Delete introspect.json when you are done with it.
Step 7 · Regenerate and read the generated files
Commit the plugin and the new config, then run prebuild for both platforms with --clean:
cd ~/native-settings-demo/native-settings
rm -f introspect.json
git add -A
git commit --quiet -m "Add with-store-defaults config plugin"
npx expo prebuild --clean --no-installCheck it worked
Look for the attribute in the Android manifest and the key in the iOS Info.plist. The iOS folder is named after the app, so the path uses a wildcard:
cd ~/native-settings-demo/native-settings
grep -o 'android:appCategory="[a-z]*"' android/app/src/main/AndroidManifest.xml
grep -A1 'ITSAppUsesNonExemptEncryption' ios/*/Info.plist
if grep -A1 'ITSAppUsesNonExemptEncryption' ios/*/Info.plist | grep '<false/>' > /dev/null; then echo "encryption key is false"; else echo "encryption key is NOT false"; false; fi
grep -x 'android.minSdkVersion=26' android/gradle.propertiesThe output is:
android:appCategory="productivity"
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
encryption key is false
android.minSdkVersion=26The if line prints encryption key is NOT false and fails if the key is <true/> or missing.
Both plugins ran in the same prebuild, in the order they are listed: expo-build-properties still set the Gradle property, and your plugin added its two changes.
Step 8 · Prove that hand edits do not survive
This step shows why you never fix a setting by editing the generated folders. Add a line to gradle.properties by hand, regenerate, and look for it:
cd ~/native-settings-demo/native-settings
echo "# hand edit: org.gradle.caching=true" >> android/gradle.properties
grep -c 'hand edit' android/gradle.properties
npx expo prebuild --clean --no-install --platform android
if grep -q 'hand edit' android/gradle.properties; then echo "hand edit survived"; false; else echo "hand edit is gone"; fiThe first grep prints 1. After --clean, the last line prints hand edit is gone. If the edit had survived, it would print hand edit survived and fail. Without --clean, prebuild changes existing files in place and can leave such edits alone, but the next teammate, CI job or EAS build starts from a fresh copy and loses them. If a setting matters, it belongs in the config or a plugin.
To build and run the generated projects on a device or emulator, use the run commands. They need the Android SDK, or macOS with Xcode, and run prebuild for you if the folders are missing:
npx expo run:android --variant release
npx expo run:iosCheck it worked
The last command printed hand edit is gone. When you leave CNG for good, the other path is the bare workflow: commit android and ios, edit them by hand, and maintain them yourself on every SDK upgrade. Teams choose it when they have a lot of custom native code that plugins cannot express. For settings like the ones in this tutorial, it is rarely worth that cost.
Remove the practice folder when you are finished:
rm -rf ~/native-settings-demoNext steps
- Build the app in the cloud, where EAS runs prebuild for you: build and submit an app with EAS.
- See a library plugin add permission strings to both platforms: ask for camera and photo permissions in Expo.
- Measure what R8 and resource shrinking save: shrink an Android app built with Expo.
- Start from the basics of an Expo project: create your first Expo app.
Related tutorials
- How to Build and Submit an Expo App to the App Stores with EASYou will set up EAS for an Expo SDK 58 app, build it for testers with an internal distribution profile, build a production release, and submit it to TestFlight and Google Play, with the costs, the accounts you need and the places where credentials stay out of your repository.
- Ask for camera and photo permissions in an Expo app the right wayYou will have an Expo screen that explains why it needs the camera before asking, handles every answer including a permanent refusal, offers the photo library as a fallback, and ships only the permissions it uses.
- How to Create Your First React Native App with ExpoYou will create an Expo SDK 58 project with TypeScript, look at what the template gives you, run it on your phone or in a simulator, replace the home screen with a small counter of your own, and check from the command line that the project bundles and passes expo-doctor.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials