Submitting an app to the App Store can be a nerve-wracking experience, especially when Apple rejects your app for unclear or default permission strings. This is a common issue for developers using Expo, particularly with modules like expo-location
. Apple requires a clear, customized description for each permission your app requests, and the default permission strings provided by Expo often fall short of their guidelines.
I recently faced this challenge while trying to submit an Expo app to the App Store, and the road to solving it wasn’t straightforward. After trying multiple approaches and running into dead ends, I finally found a solution that worked. Here’s everything you need to know about resolving this issue, based on my experience.
The Problem
Apple’s App Store review process requires apps to provide clear, custom messages explaining why permissions, such as location access, are being requested. If your app uses the expo-location
module, Expo provides default permission strings. Unfortunately, these default messages often fail to meet Apple’s standards, leading to rejections.
In my case, the permission strings for expo-location
caused issues. Despite multiple attempts to customize the strings, the default messages persisted, and my app was repeatedly rejected by Apple.
What I Tried
I experimented with several methods to customize the permission strings for expo-location
, but none of them seemed to work. Here’s what I tried:
1. Using the expo-location
Plugin Options
The first method I tried was defining the permission strings directly in the expo-location
plugin configuration in app.json
or app.config.js
. My configuration looked like this:
[
"expo-location",
{
"locationAlwaysAndWhenInUsePermission": "We need your location to provide personalized experiences.",
"locationAlwaysPermission": "Location access is required for accurate tracking.",
"locationWhenInUsePermission": "Location is needed while using the app to provide better services."
}
]
I expected these custom messages to replace the default strings, but unfortunately, they didn’t take effect during the build process.
**2. Adding Strings Directly in **ios.infoPlist
Next, I added the permission strings directly in the ios.infoPlist
section of my app.json
file:
"ios": {
"infoPlist": {
"NSLocationAlwaysAndWhenInUseUsageDescription": "We need your location to provide personalized experiences.",
"NSLocationAlwaysUsageDescription": "Location access is required for accurate tracking.",
"NSLocationWhenInUseUsageDescription": "Location is needed while using the app to provide better services."
}
}
However, this method also failed to override the default permission strings.
3. Combining Both Methods
Thinking that combining the two methods might resolve the issue, I configured both the expo-location
plugin options and the ios.infoPlist
entries simultaneously. Unfortunately, even this didn’t work. The default permission messages persisted, and my app continued to get rejected by Apple.
**The Solution: **expo prebuild --clean
After hours of trial and error, I discovered the real solution: running the expo prebuild --clean
command. This command resets the iOS project files and forces Expo to rebuild them with the latest configuration changes. Here’s how it works:
Steps to Fix the Issue:
A. Define Custom Permission Strings: Ensure that your custom permission strings are defined in the expo-location
plugin configuration within app.json
or app.config.js
. For example:
[ "expo-location", { "locationAlwaysAndWhenInUsePermission": "We need your location to provide personalized experiences.", "locationAlwaysPermission": "Location access is required for accurate tracking.", "locationWhenInUsePermission": "Location is needed while using the app to provide better services." } ]
B. Run the Prebuild Command: Execute the following command in your terminal:
npx expo prebuild --platform ios --clean
This command regenerates the iOS native files and ensures that the latest configuration changes are applied.
C. Build Your App: After running the prebuild
command, proceed to build your app as usual:
npx expo run:ios
D. Submit to the App Store: Once the build is complete, submit your app to the App Store for review. In my case, Apple accepted the app without any further issues.
Why This Works
The expo prebuild --clean
command essentially resets and regenerates the iOS native project files. This ensures that:
- Any cached configurations or old settings are cleared.
- The custom permission strings defined in your
expo-location
plugin configuration are properly applied to the native files. - Apple’s requirements for clear and customized permission messages are met.
Key Takeaways
- Use the
expo-location
Plugin Configuration: Define your custom permission strings directly in the plugin configuration. There’s no need to manually editios.infoPlist
. - Run
expo prebuild --clean
: This command is crucial for ensuring that your configuration changes take effect on iOS. Without it, the default permission strings may persist. - Test Before Submitting: Always test your app locally and verify that the custom permission strings are displayed correctly before submitting to the App Store.
- Avoid Unnecessary Edits: Adding redundant configurations in multiple places (e.g.,
ios.infoPlist
and the plugin) can lead to confusion. Stick to the recommended approach.
Conclusion
If you’re struggling to change the default permission strings in Expo, the solution might be simpler than you think. By defining the custom strings in the expo-lo
cation
plugin configuration and running expo prebuild --clean
, you can ensure that your changes take effect. This approach saved me hours of frustration and allowed my app to pass Apple’s review process without further issues.
Expo’s tools are powerful, but understanding how to leverage commands like prebuild
can make a huge difference in your development workflow. I hope this guide helps you resolve similar challenges and streamlines your app submission process. Happy coding! ๐