What's the library should I import for UTTypeImage, which is the replacement of kUTTypeImage in iOS 15?

Before iOS 15, I used UIImagePickerController to capture images and video, and I got mediaType from [UIImagePickerController.InfoKey : Any], then I used kUTTypeImage (in the MobileCoreServices library) to identify the mediaType.

However, When it comes to iOS 15, Xcode complains that kUTTypeImage was deprecated in iOS 15.0. Use UTTypeImage instead. So, I replaced kUTTypeImage with UTTypeImage, but Xcode didn't know it.

Tried searching for some information, but didn't get any clue. I guess I should import the right library, but what is it?

Here is part of the code:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        guard let mediaType = info[.mediaType] as? String else { return }
        switch mediaType {
        case String(kUTTypeImage):
        // blabla
        case String(kUTTypeMovie):
        // blabla

and here are some screenshots: enter image description here

enter image description here


It's a bit confusing. First, you'll need to import UniformTypeIdentifiers. Then, replace kUTTypeImage with UTType.image (the Swift version of UTTypeImage).