In this lesson, you will learn how to automate native project modifications so your app stays consistent across every build without manual changes.
The "Prebuild" Problem
When you move from a Managed Expo workflow to a project that requires native code (like adding a custom native SDK), you usually have to run npx expo prebuild. This command generates the android and ios folders from scratch based on your app.json.
The problem? If you manually open Xcode or Android Studio to tweak a setting—like adding a permissions key in Info.plist or a repository in build.gradle—that change gets wiped out the next time you prebuild. This makes your native configuration "brittle" and hard for teammates to reproduce.
Enter Config Plugins
A Config Plugin is a JavaScript function that modifies native files automatically during the prebuild phase. Instead of manually editing native files, you write code that tells Expo how to "patch" them.
Think of it as a set of instructions: "When prebuilding, find the Info.plist, look for the camera permission key, and add it for me."
Here is a simple example of how a plugin might look in your app.json or a separate file:
const { withInfoPlist } = require('@expo/config-plugins');
const withMyCustomConfig = (config) => {
return withInfoPlist(config, (config) => {
config.modResults.NSCameraUsageDescription = "We need your camera to scan QR codes.";
return config;
});
};
By adding this to your plugins array in app.json, Expo will programmatically inject your camera description every time you run npx expo prebuild. You never have to touch the native folders directly. This keeps your native configuration version-controlled, reproducible, and entirely driven by your JavaScript project files.
By treating native configuration as code, you turn your project into a self-configuring system that can be rebuilt from scratch at any time, on any machine, without the risk of human error.
Key Takeaway: Config Plugins allow you to automate native file modifications, ensuring your project remains fully reproducible and removing the need to manually edit Xcode or Android Studio files.