Keywords: Expo | Info.plist | App Store Connect | Purpose String | iOS Review
Abstract: This article provides an in-depth analysis of the "Missing Purpose String in Info.plist File" error encountered when submitting iOS apps built with the Expo framework to App Store Connect. It begins by examining the root cause: Apple's requirement, effective from spring 2019, for all apps accessing user data to include clear purpose strings in their Info.plist files. Drawing from the best-practice answer, the guide details steps to add necessary key-value pairs by modifying the app.json configuration file in Expo projects. Furthermore, it explores compatibility considerations across different iOS versions, covering the use of keys such as NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription, and NSLocationAlwaysAndWhenInUseUsageDescription. Through code examples and step-by-step instructions, this article aims to assist developers in swiftly resolving this issue to ensure smooth app approval.
Error Background and Cause Analysis
When developers submit iOS apps built with the Expo framework to App Store Connect, they may receive a review email from Apple indicating a "Missing Purpose String in Info.plist File" error. This error arises because the app's code references APIs that access sensitive user data, such as location, without providing corresponding purpose strings in the Info.plist file. Apple has enforced this requirement since spring 2019 to enhance user privacy, ensuring apps offer clear and complete explanations when requesting permissions.
It is important to note that this error can occur even if the app does not directly use location features. This is often due to integrated third-party libraries or SDKs that include references to these APIs. For instance, some advertising or analytics frameworks may enable location services by default to optimize functionality. Thus, developers must add purpose strings to the Info.plist, even if the app logic does not explicitly call these APIs.
Solution in the Expo Framework
In Expo projects, the Info.plist file is typically auto-generated and managed by Expo CLI, so developers do not need to edit native files directly. Instead, they can add the required key-value pairs by modifying the app.json configuration file. The steps are as follows:
- Open the
app.jsonfile in the project root directory. - Locate or add the
iosconfiguration section within theexpoobject. - Inside the
iosobject, set theinfoPlistproperty to include the necessary purpose string key-value pairs.
Below is a complete code example demonstrating how to configure purpose strings in app.json:
"expo": {
"ios": {
"bundleIdentifier": "com.example.myapp",
"infoPlist": {
"NSLocationAlwaysAndWhenInUseUsageDescription": "This app needs access to your location to provide location-based services, such as navigation or local recommendations.",
"NSLocationWhenInUseUsageDescription": "This app requires location information only while in use to enhance feature experiences."
}
}
}In this example, we added two keys: NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription. These correspond to scenarios for always-on and when-in-use location permissions in iOS 11 and above. The value for each key should be a user-friendly string that clearly explains why the app needs access to location data. For instance, it could describe "for providing personalized weather information" or "to support map navigation features."
Compatibility and Best Practices
To ensure compatibility across different iOS versions, developers may need to include additional keys. According to Apple's documentation, NSLocationAlwaysUsageDescription has been deprecated since iOS 11 but is still required for devices running iOS 10 and below. Therefore, it is recommended to include all of the following keys in infoPlist:
NSLocationAlwaysAndWhenInUseUsageDescription: For iOS 11 and above, to request always-on location permission.NSLocationWhenInUseUsageDescription: For iOS 11 and above, to request when-in-use location permission.NSLocationAlwaysUsageDescription: For iOS 10 and below, as a fallback option.
Here is an enhanced configuration example that supports multiple versions:
"expo": {
"ios": {
"bundleIdentifier": "com.example.myapp",
"infoPlist": {
"NSLocationAlwaysAndWhenInUseUsageDescription": "The app needs continuous location access to provide background services, such as fitness tracking.",
"NSLocationWhenInUseUsageDescription": "The app uses location only when active, for example, to find nearby places.",
"NSLocationAlwaysUsageDescription": "The app requires location permissions to support full feature sets."
}
}
}When setting these strings, ensure the content is truthful and clear, avoiding vague or misleading language. Apple's review team may assess the reasonableness of the strings, so it is advisable to tailor descriptions based on the app's actual functionality. For example, if the app only requests location when in use, do not claim a need for continuous access in NSLocationAlwaysAndWhenInUseUsageDescription.
Error Handling and Next Steps
Upon receiving an error email about missing purpose strings, developers should promptly address the issue to prevent review delays or rejections. Although the email states that the delivery was successful, unresolved errors could lead to more severe problems in future updates. After fixing the issue, rebuild the app using Expo CLI and resubmit it to App Store Connect.
The specific workflow is as follows:
- Modify the
app.jsonfile to add the necessaryinfoPlistconfiguration. - Run the
expo build:ioscommand to rebuild the iOS app. - Upload the new binary file to App Store Connect via Xcode or Application Loader.
- Submit the updated version for review in App Store Connect.
If the error persists, check if integrated third-party libraries are outdated or contain unnecessary APIs. In such cases, consider contacting the library developers to request fixes or seek alternative solutions. Additionally, regularly consult Apple's official documentation and Expo changelogs to stay updated on privacy policy changes.
In summary, by correctly configuring infoPlist in app.json, developers can efficiently resolve the "Missing Purpose String in Info.plist File" error, ensuring compliance with Apple's privacy standards for smooth app approval and improved user experience.