What is @expo/prebuild-config?
@expo/prebuild-config is a package that helps you manage and customize the native configuration of your Expo project. It allows you to modify native files and settings before building your project, making it easier to integrate custom native code and settings.
What are @expo/prebuild-config's main functionalities?
Modifying AndroidManifest.xml
This feature allows you to modify the AndroidManifest.xml file of your Expo project. You can use it to add, remove, or change elements in the manifest file.
const { withAndroidManifest } = require('@expo/config-plugins');
module.exports = function withCustomAndroidManifest(config) {
return withAndroidManifest(config, async config => {
const androidManifest = config.modResults;
// Modify the AndroidManifest.xml here
return config;
});
};
Modifying Info.plist
This feature allows you to modify the Info.plist file of your Expo project. You can use it to add, remove, or change properties in the plist file.
const { withInfoPlist } = require('@expo/config-plugins');
module.exports = function withCustomInfoPlist(config) {
return withInfoPlist(config, config => {
const infoPlist = config.modResults;
// Modify the Info.plist here
return config;
});
};
Adding custom native code
This feature allows you to add or modify custom native code in your Expo project. You can use it to include custom Objective-C, Swift, Java, or Kotlin code in your project.
const { withDangerousMod } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');
module.exports = function withCustomNativeCode(config) {
return withDangerousMod(config, [
'ios',
async config => {
const filePath = path.join(config.modRequest.platformProjectRoot, 'path/to/your/file.m');
const fileContent = fs.readFileSync(filePath, 'utf-8');
// Modify the native code here
fs.writeFileSync(filePath, fileContent);
return config;
}
]);
};
Other packages similar to @expo/prebuild-config
react-native-config
react-native-config allows you to manage environment-specific configurations for your React Native app. It provides a way to use different configurations for different environments, such as development, staging, and production. Unlike @expo/prebuild-config, it focuses on managing environment variables rather than modifying native files.
react-native-ultimate-config
react-native-ultimate-config is another package for managing environment-specific configurations in React Native apps. It supports both iOS and Android and allows you to define environment variables in a single place. It is similar to react-native-config but offers additional features like type safety and better integration with TypeScript.
react-native-code-push
react-native-code-push is a service that allows you to deploy mobile app updates directly to your users' devices. It enables you to push updates to JavaScript code and assets without going through the app store review process. While it doesn't modify native files like @expo/prebuild-config, it provides a way to manage and deploy updates efficiently.