I'm trying to access the photo library to import a profile image in swift 4.
but i got this error :
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.
I asked for permission in every single way.
I try :
<key>NSPhotoLibraryUsageDescription</key>
<string>this permission for profile photo only</string>
and the code :
let imagePicker = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}
@objc func importUserImage() {
print("import driver")
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
self.present(imagePicker, animated: true)
}
I try
<key>NSPhotoLibraryAddUsageDescription</key>
<string>this permission for profile photo only</string>
I even try to do it in code
import UIKit
import Photos
import UserNotifications
class LoginViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
PHPhotoLibrary.requestAuthorization { (status) in
// cruch here
}
}
}
I deleted the app and reinstall it , still crash
Did i forget something? or what i'm doing wrong ?