Info.plist에 넣기

iOS 14 이상에서 변경된 것

권한 확인

import Photos

print(PHPhotoLibrary.authorizationStatus(for: .addOnly).rawValue)
print(PHPhotoLibrary.authorizationStatus(for: .readWrite).rawValue)

readWrite와 addOnly를 구분해서 권한 확인 가능

권한 요청

PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
// PHPhotoLibrary.requestAuthorization(for: .addOnly) { status in
    switch status {
    case .notDetermined:
        break
    case .restricted:
        break
    case .denied:
        break
    case .authorized:
        break
    case .limited:
        break
    @unknown default:
        break
    }
}