Latest test shows that in an app compiled with Xcode 15.0.1, if the select photo screen hasn't opened by system dialog , calling presentLimitedLibraryPicker will lead to a crash.
import UIKit
import Photos
import PhotosUI
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let status = PHPhotoLibrary.authorizationStatus(for: .readWrite)
switch status {
case .notDetermined:
PHPhotoLibrary.requestAuthorization(for: .readWrite) { _ in
print("2")
}
default:
print("1")
}
}
@IBOutlet weak var testButton: UIButton!
@IBAction func testAction(_ sender: Any) {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self)
}
}