With Xcode15, app crash when call presentLimitedLibraryPicker

First, App has linked with PhotosUI and Photos. And, this problem never happened when complied with Xcode14.1 and Swift.

New APP is compiled with Xcode15.0.1. Code is not changed. Step:

  1. Set access "Selected Photos" for APP.
  2. Restart APP. Try to access photos with PHPhotoLibrary functions , and then a system dialog appears. There are two buttons: "Select More Photos..." and "Keep Current Selection".
  3. Choose "Keep Current Selection". (If choose "Select More Photos...", the app will not crash.)
  4. Call "presentLimitedLibraryPicker(from controller: UIViewController)"

Crash log:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHPhotoLibrary presentLimitedLibraryPickerFromViewController:]: unrecognized selector sent to instance 0x1064d66f0'

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)
    }
}

I've had same issue. my case was occured in an UI Module. I solved the issue by importing PhotoUI Framework to the module.

Reference by https://developer.apple.com/forums/thread/737847

With Xcode15, app crash when call presentLimitedLibraryPicker
 
 
Q