React Native能否为Android/iOS实现Alpha、Beta、生产环境动态应用图标?
Absolutely! You can absolutely implement distinct app icons for dev/beta and production builds in a single React Native project—no need to maintain separate codebases or apps. This is a common need to avoid confusing test builds with production ones, and it’s totally doable with platform-specific configuration tweaks. Let’s break it down for each OS:
iOS Setup
iOS makes this straightforward using Asset Catalogs and build configurations:
- Open your React Native project’s iOS folder in Xcode, then navigate to
Assets.xcassets. - Create separate App Icon Sets for each environment (e.g.,
AppIcon-Dev,AppIcon-Beta,AppIcon-Prod). Upload the corresponding icon assets to each set (make sure all required sizes are included—Xcode will flag missing ones). - Go to your project’s Build Settings, search for
Asset Catalog App Icon Set Name. - For each build configuration (Debug, Release, or custom Beta config), set the value to match your icon set:
- Debug →
AppIcon-Dev - Beta →
AppIcon-Beta - Release →
AppIcon-Prod
- Debug →
- If you don’t have a Beta configuration yet, you can create one by going to Project → Info → Configurations, duplicating the Release config, and renaming it to Beta.
Android Setup
Android uses build types or product flavors to swap icons:
Option 1: Use Default Build Types (Debug/Release)
- In
android/app/src/, create adebugfolder if it doesn’t exist, then addres/mipmap-*subfolders inside it. Place your dev-specific icons here, using the same filenames as the default production icons (e.g.,ic_launcher.png,ic_launcher_round.png). - The
releasebuild will automatically use the icons insrc/main/res/mipmap-*, while thedebugbuild will prioritize the ones insrc/debug/res/mipmap-*.
Option 2: Use Product Flavors (For Dev/Beta/Prod)
If you need more granular control (like a dedicated Beta flavor), add this to your android/app/build.gradle:
android { // ... other configs productFlavors { dev { applicationIdSuffix ".dev" resValue "string", "app_name", "MyApp Dev" } beta { applicationIdSuffix ".beta" resValue "string", "app_name", "MyApp Beta" } prod { resValue "string", "app_name", "MyApp" } } }
- Then create folders
src/dev/res/mipmap-*,src/beta/res/mipmap-*, and place your respective icons in each. When you build with a specific flavor (e.g.,./gradlew assembleDevDebug), Android will use the icons from that flavor’s resource folder.
Key Notes
- For iOS, double-check that all icon sizes are present in each App Icon Set—missing sizes will cause Xcode build errors.
- On Android, ensure your icon filenames match the default ones (or update the
android:iconattribute inAndroidManifest.xmlif you use custom names). - This approach swaps icons at build time, which is perfect for distinguishing dev/beta/prod builds. If you ever need runtime icon switching (a rarer use case), iOS has the
setAlternateIconNameAPI, and Android has similar functionality via package manager tricks—but that’s overkill for your original goal.
With these steps, you’ll have distinct, environment-specific icons all from one React Native project—no more accidentally opening the wrong build during testing!
内容的提问来源于stack exchange,提问作者chapeljuice

