Xcode – This app has attempted to access privacy-sensitive data without a usage description.

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> Object-C 基础

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> Object-C 线程

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> OpenGL ES

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> GPUImage

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> AVFoundation

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> CocoaPods


一.APP崩溃提示


2021-08-07 11:55:52.705362+0800 LearnAVFoundation[10202:1163555] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSLocationAlwaysUsageDescription key with a string value explaining to the user how the app uses this data

二.解决办法

需要在 info.plist 文件添加一个 NSLocationAlwaysUsageDescription的 key,然后添加一个描述。

Xcode - This app has attempted to access privacy-sensitive data without a usage description.
Xcode - This app has attempted to access privacy-sensitive data without a usage description.

三.小技巧

例如我们使用 PHPhotoLibrary 访问相册也会出现类似的崩溃,崩溃日志如下:

2021-08-07 11:59:31.125562+0800 LearnAVFoundation[10211:1164953] success = 0, error = Error Domain=NSCocoaErrorDomain Code=2047 "Photos Access not allowed (authorization status 0)" UserInfo={NSLocalizedDescription=Photos Access not allowed (authorization status 0)}

2021-08-07 11:59:31.128983+0800 LearnAVFoundation[10211:1164951] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
Xcode - This app has attempted to access privacy-sensitive data without a usage description.

发现共同点没有??我们只需要根据日志,添加对应的 key / value 添加到 info.plist 即可,对于上面的崩溃问题,我们需要添加NSPhotoLibraryUsageDescription 到 info.plist 即可;


四.猜你喜欢


未经允许不得转载:猿说编程 » Xcode – This app has attempted to access privacy-sensitive data without a usage description.
喜欢(2) 打赏

评论抢沙发

评论前必须登录!

不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!!

开始学习

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏