NSPhotoLibraryAddUsageDescription错误

Man*_*nsa 4 xcode camera plist ios

我希望有人可以在这里提供帮助。我有这个Xcode / Unity项目,每次尝试构建它时,都会出现此错误:

该应用已崩溃,因为它尝试访问没有使用说明的隐私敏感数据。该应用程序的Info.plist必须包含一个NSPhotoLibraryAddUsageDescription键,该键具有字符串值,该字符串值向用户说明该应用程序如何使用此数据。

我了解在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>
Run Code Online (Sandbox Code Playgroud)

如您所见,我在其中确实有说明?!?!

在Xcode中查看info.plist时,它看起来像这样

在此处输入图片说明

真的希望有人可以在这件事上为我提供帮助,并在此先感谢:-)

iOS*_*iOS 6

您需要在info.plist中添加以下代码

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Here write description why you accessing photo library</string>
Run Code Online (Sandbox Code Playgroud)

隐私-照片库使用说明适用于读写库,NSPhotoLibraryAddUsageDescription仅适用于读取。如果您的应用只需要阅读,请添加NSPhotoLibraryAddUsageDescription

有关更多详细信息,请参见以下链接,https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73

请参阅以下屏幕截图:

1)右键单击Info.plist文件

->选择打开方式选项

->单击源代码

在此处输入图片说明

2)现在,将以上代码复制并粘贴到此处

在此处输入图片说明


iPa*_*tel 3

您需要在 iOS 11 中添加文件NSPhotoLibraryAddUsageDescriptioninfo.plist

如果您想在照片库中添加照片/图像,则必须将此密钥添加到 info.plist 文件中