2017-10-06 90 views
0

我希望有人可以在這裏幫忙。我有這樣的Xcode /團結項目,每次我試圖建立它,我得到這個錯誤:NSPhotoLibraryAddUsageDescription錯誤

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>[email protected]</string> 
     <string>[email protected]</string> 
     <string>[email protected]~ipad.png</string> 
     <string>AppIcon72x72~ipad.png</string> 
     <string>[email protected]~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

真的希望有人能幫助我在這個問題上,以及在此先感謝:-)

+0

錯誤表示您的plist需要具有'NSPhotoLibraryAddUsageDescription'條目,並且您的plist沒有它。對這個錯誤究竟有什麼不清楚? –

+2

[iOS 11中的照片捕獲權限問題]的可能重複(https://stackoverflow.com/questions/44527321/photo-capture-permission-problems-in-ios-11) –

回答

0

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

如果要在照片庫中添加照片/圖片,則必須將此密鑰添加到info.plist文件

+0

該文檔說:「NSPhotoLibraryUsageDescription(String - iOS)這個鍵可以讓你描述你的應用訪問用戶照片庫的原因,儘管這個按鍵管理着用戶照片庫的讀寫權限,但如果你的應用只需要添加資源到庫中,最好使用NSPhotoLibraryAddUsageDescription需要閱讀任何資產。「當用法鍵(每個文檔)管理讀寫訪問時,需要考慮爲什麼只需定義爲只寫的AddUsage鍵的任何想法? – JKaz

0

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

<key>NSPhotoLibraryAddUsageDescription</key> 
<string>Need to save photos</string> 

隱私 - 照片庫的使用說明是讀寫庫, NSPhotoLibraryAddUsageDescription僅用於讀取。如果您的應用程序需要只讀添加NSPhotoLibraryAddUsageDescription

0

我發現,你還需要添加

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

或它仍然會崩潰。 您目前需要全部三個 - 2018年3月