NSPhotoLibraryAddUsageDescription错误

问题描述 投票:3回答:3

我希望有人能够帮助在这里。我有这样的Xcode /团结项目,每一次我尝试建立它,我得到这个错误:

这个应用程序已经崩溃,因为它试图在没有一个使用说明来访问隐私敏感数据。该应用程序的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>[email protected]</string>
      <string>[email protected]</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:[email protected]/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它看起来像这样

enter image description here

真希望有人能帮助我在这个问题上,以及在此先感谢:-)

ios xcode camera plist
3个回答
4
投票

您需要添加下面的代码中的info.plist

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Here write description why you accessing photo library</string>

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

欲了解更多详情,请参阅此链接,https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73

请参见下面的截图:

1)右键单击Info.plist文件

- >选择打开作为选项

- >点击源代码

enter image description here

2)现在,复制和粘贴在这里上面的代码。

enter image description here


3
投票

您需要在iOS的11加NSPhotoLibraryAddUsageDescriptioninfo.plist文件。

如果你想在你的照片库中添加照片/图片,然后你必须添加此键Info.plist文件


1
投票

我发现,你还需要添加

<key>NSCameraUsageDescription</key>
<string>Photo Library Access Warning</string>

或者它仍然会崩溃。你需要所有三个此刻年 - 2018年三月

© www.soinside.com 2019 - 2024. All rights reserved.