Expo项目中app.json的infoPlist配置NSContactsUsageDescription不生效
解决Expo React Native应用访问通讯录崩溃的问题
根据你描述的情况,虽然已在app.json中配置了通讯录权限说明,但仍出现崩溃,可能是配置未正确注入原生项目、重复配置冲突或构建缓存问题导致的,以下是具体排查和解决步骤:
1. 确认原生项目的Info.plist是否包含权限描述
先检查生成的iOS原生项目中的Info.plist文件(路径为ios/Drinklink/Info.plist),确认是否存在NSContactsUsageDescription键及正确的描述文本。如果该键不存在,说明配置没有被正确同步到原生项目。
2. 重新执行预构建命令
删除ios文件夹后,不要直接执行pod install,需通过Expo的预构建命令重新生成原生项目:
expo prebuild --clean
该命令会根据app.json的配置重新生成iOS项目文件,确保权限描述正确注入。
3. 统一权限配置方式
你当前同时在ios.infoPlist和expo-contacts插件配置中添加了通讯录权限描述,可能存在配置冲突。Expo官方插件(如expo-contacts)会自动将插件内的contactsPermission映射为iOS的NSContactsUsageDescription,建议只保留插件中的配置,删除ios.infoPlist中的NSContactsUsageDescription项。
修正后的app.json关键部分示例:
"ios": { "supportsTablet": true, "bundleIdentifier": "com.drinklink.dev", "buildNumber": "1.0.29" }, "plugins": [ [ "expo-image-picker", { "photosPermission": "The app accesses your photos to allow you to set a profile picture. This makes it easier for them to identify you. It is only ever used for this single purpose.", "cameraPermission": "The app accesses your camera to allow you to set a profile picture. This makes it easier for them to identify you. It is only ever used for this single purpose." } ], [ "expo-contacts", { "contactsPermission": "Drinklink uses your contacts to make it easier to find your friends to buy drinks for. This data is never saved or used elsewhere." } ] ]
4. 清除所有相关缓存
除了删除node_modules和yarn.lock,还需清除Expo的运行缓存:
npx expo start --clear
如果使用EAS Build打包,还需清除构建缓存:
eas build --clear-cache
完成以上步骤后重新构建项目,应该就能解决通讯录权限导致的崩溃问题。
内容的提问来源于stack exchange,提问作者Janelle Thorn Contreras
相关产品推荐
相关产品推荐

