我希望有人能在这里提供帮助。我有这个 Xcode/Unity 项目,每次我尝试构建它时都会收到此错误:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.
我知道在我的 info.plist 中我需要使用相机、图书馆等的描述,但据我所知,我有吗?
这是我的 info.plist:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>MyGame</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon57x57.png</string>
<string>AppIcon57x57@2x.png</string>
<string>AppIcon60x60@2x.png</string>
<string>AppIcon72x72@2x~ipad.png</string>
<string>AppIcon72x72~ipad.png</string>
<string>AppIcon76x76@2x~ipad.png</string>
<string>AppIcon76x76~ipad.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.mycompany.${PRODUCT_NAME}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true />
</dict>
<key>UIApplicationExitsOnSuspend</key>
<false />
<key>UILaunchStoryboardName~ipad</key>
<string>LaunchScreen-iPad</string>
<key>UILaunchStoryboardName~iphone</key>
<string>LaunchScreen-iPhone</string>
<key>UILaunchStoryboardName~ipod</key>
<string>LaunchScreen-iPhone</string>
<key>UIPrerenderedIcon</key>
<false />
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true />
<key>UIRequiresPersistentWiFi</key>
<false />
<key>UIStatusBarHidden</key>
<true />
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>Unity_LoadingActivityIndicatorStyle</key>
<integer>-1</integer>
<key>UnityCloudProjectID</key>
<string>xxx-xxx-xxx-xxx-xxx</string>
<key>UnityCrashSubmissionURL</key>
<string>https://a:b@perf-events.cloud.unity3d.com/symbolicate</string>
<key>NSCameraUsageDescription</key>
<string>Used for profile image</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used for profile image</string>
<key>FacebookAppID</key>
<string>xxxxx</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>facebook-unity-sdk</string>
<key>CFBundleURLSchemes</key>
<array>
<string>xxxxx</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
</dict>
</plist>
如你所见,我确实有描述?!?!
在 Xcode 中查看 info.plist 时,它看起来像这样
真的希望有人能在这件事上帮助我,在此先感谢:-)
最佳答案
需要在info.plist中添加如下代码
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Here write description why you accessing photo library</string>
Privacy - Photo Library Usage Description 适用于读写库, NSPhotoLibraryAddUsageDescription 仅供阅读。如果你的应用只需要读取添加 NSPhotoLibraryAddUsageDescription
请看下面的截图:
1) 右键点击Info.plist文件
-->选择打开方式选项
-->点击源代码
2) 现在将上面的代码复制并粘贴到这里。
关于ios - NSPhotoLibraryAddUsageDescription 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46601885/