Photo Library permissions - Why is my app not showing in the Settings app? (iOS 12.1 Xcode 10.1)

1.5k Views Asked by At

My app isn't showing in the iPhone's Settings app (similar issue on both physical device & simulator). I'm using Xcode 10.1 & iOS 12.1.

It needs to save photos to the user's photo library so I added the right keys (listed below) in the info.plist but I never get the Photo library permission prompt.

NSAppleMusicUsageDescription
NSCameraUsageDescription
NSMicrophoneUsageDescription
NSPhotoLibraryAddUsageDescription
NSPhotoLibraryUsageDescription

(I think some of them aren't needed at all but adding them still didn't fix anything).

I tried to force-open the Settings app like shown below. That opens the Settings app but the app I'm working on doesn't appear there.

guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
      print("Couldn't load settingsURL")
      return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
      UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                            print("Settings opened: \(success)")
      })
}

As a result, I cannot debug the permissions and the app continues to crash when I try to write an image to the photo library.

Any suggestions are welcome.

1

There are 1 best solutions below

1
On

Solved: I figured that the app only appears in Settings after the first request for permission occurs.

Using this code solved it.

PHPhotoLibrary.requestAuthorization { (status) in
    print("Status: \(status)")
}

After I called this once, the app showed properly in Settings and it doesn't crash anymore when saving the image to disk.