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

ChatGPT 3.5 国内中文镜像站免费使用啦

零基础 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,然后添加一个描述。

图片[1]-Xcode – This app has attempted to access privacy-sensitive data without a usage description.-猿说编程
图片[2]-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.
图片[3]-Xcode – This app has attempted to access privacy-sensitive data without a usage description.-猿说编程

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


四.猜你喜欢


ChatGPT 3.5 国内中文镜像站免费使用啦
© 版权声明
THE END
喜欢就支持一下吧
点赞2 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容