Skip to content

[image_picker_ios] Replace deprecated kUTTypeImage/kUTTypeMovie with UTType API - #12778

Open
ledexsoft wants to merge 2 commits into
flutter:mainfrom
ledexsoft:fix/image_picker_ios-modern-uttype
Open

[image_picker_ios] Replace deprecated kUTTypeImage/kUTTypeMovie with UTType API#12778
ledexsoft wants to merge 2 commits into
flutter:mainfrom
ledexsoft:fix/image_picker_ios-modern-uttype

Conversation

@ledexsoft

Copy link
Copy Markdown

Fixes iOS deprecation warnings surfaced when building with Flutter 3.44.8 / Xcode 26 (iOS 26 SDK):

warning: 'kUTTypeImage' is deprecated: first deprecated in iOS 15.0 - Use UTTypeImage instead [-Wdeprecated-declarations]
warning: 'kUTTypeMovie' is deprecated: first deprecated in iOS 15.0 - Use UTTypeMovie instead [-Wdeprecated-declarations]

(FLTImagePickerPlugin.m:130,133)

Cause

launchUIImagePickerWithSource: still adds kUTTypeImage / kUTTypeMovie directly to UIImagePickerController.mediaTypes. The legacy kUTType* constants were deprecated in iOS 15 in favor of the modern UTType API.

Fix

Replaces the deprecated constants with UTTypeImage.identifier / UTTypeMovie.identifier guarded by @available(iOS 14.0, *), keeping the legacy constants as the fallback for iOS 13 (the pod deployment target is 13.0). This mirrors the pattern already merged upstream in #10848 for the same plugin's kUTTypeGIF usages in FLTImagePickerImageUtil.m and FLTImagePickerPhotoAssetUtil.m, which appear to have missed these two call sites in FLTImagePickerPlugin.m.

Verification

Detected with Flutter 3.44.8 / Xcode 26 (iOS 26 SDK).

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla

google-cla Bot commented Sep 7, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the deprecated kUTTypeImage and kUTTypeMovie with UTTypeImage and UTTypeMovie on iOS 14.0+ to resolve deprecation warnings, importing the UniformTypeIdentifiers framework. Feedback suggests simplifying the conditional initialization of the media type variables by setting the fallback values as defaults, which eliminates the need for the else blocks.

Comment on lines 130 to 148
if (context.includeImages) {
[mediaTypes addObject:(NSString *)kUTTypeImage];
NSString *imageType;
if (@available(iOS 14.0, *)) {
imageType = UTTypeImage.identifier;
} else {
imageType = (NSString *)kUTTypeImage;
}
[mediaTypes addObject:imageType];
}
if (context.includeVideo) {
[mediaTypes addObject:(NSString *)kUTTypeMovie];
NSString *movieType;
if (@available(iOS 14.0, *)) {
movieType = UTTypeMovie.identifier;
} else {
movieType = (NSString *)kUTTypeMovie;
}
[mediaTypes addObject:movieType];
imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This code can be simplified by initializing the type variables with their fallback values directly, avoiding the need for the else blocks and making the code more concise and readable.

  if (context.includeImages) {
    NSString *imageType = (NSString *)kUTTypeImage;
    if (@available(iOS 14.0, *)) {
      imageType = UTTypeImage.identifier;
    }
    [mediaTypes addObject:imageType];
  }
  if (context.includeVideo) {
    NSString *movieType = (NSString *)kUTTypeMovie;
    if (@available(iOS 14.0, *)) {
      movieType = UTTypeMovie.identifier;
    }
    [mediaTypes addObject:movieType];
    imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
  }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied — the legacy kUTType constants are now the default value and the modern UTType overrides them on iOS 14+, which removes the else branches. Pushed in 9df0432.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant