Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to UniformTypeIdentifiers #48623

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Image/RCTImageStoreManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTType.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#import <React/RCTAssert.h>
#import <React/RCTImageUtils.h>
#import <React/RCTLog.h>
Expand Down Expand Up @@ -202,7 +202,7 @@ - (id)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate
CFStringRef UTI = CGImageSourceGetType(sourceRef);
CFRelease(sourceRef);

NSString *MIMEType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
NSString *MIMEType = [UTType typeWithIdentifier:(__bridge NSString *)UTI].preferredMIMEType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

'UTTypeCopyPreferredTagWithClass' is deprecated: first deprecated in iOS 15.0 - Use the UTType class instead.

NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL
MIMEType:MIMEType
expectedContentLength:imageData.length
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/Libraries/Image/RCTImageUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <tgmath.h>

#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import <React/RCTLog.h>
#import <React/RCTUtils.h>
Expand Down Expand Up @@ -339,10 +339,10 @@ BOOL RCTUpscalingRequired(
CFMutableDataRef imageData = CFDataCreateMutable(NULL, 0);
if (RCTImageHasAlpha(cgImage)) {
// get png data
destination = CGImageDestinationCreateWithData(imageData, kUTTypePNG, 1, NULL);
destination = CGImageDestinationCreateWithData(imageData, (__bridge CFStringRef)UTTypePNG.identifier, 1, NULL);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

'kUTTypePNG' is deprecated: first deprecated in iOS 15.0 - Use UTTypePNG or UTType.png (swift) instead.

} else {
// get jpeg data
destination = CGImageDestinationCreateWithData(imageData, kUTTypeJPEG, 1, NULL);
destination = CGImageDestinationCreateWithData(imageData, (__bridge CFStringRef)UTTypeJPEG.identifier, 1, NULL);
[properties setValue:@(quality) forKey:(id)kCGImageDestinationLossyCompressionQuality];
}
if (!destination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <React/RCTFileRequestHandler.h>

#import <MobileCoreServices/MobileCoreServices.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import <React/RCTUtils.h>
#import <ReactCommon/RCTTurboModule.h>
Expand Down Expand Up @@ -55,10 +55,7 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ

// Get mime type
NSString *fileExtension = [request.URL pathExtension];
NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExtension, NULL);
NSString *contentType =
(__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType);
NSString *contentType = [UTType typeWithFilenameExtension:fileExtension].preferredMIMEType;

// Send response
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.frameworks = "MobileCoreServices"
s.frameworks = "UniformTypeIdentifiers"

s.dependency "RCT-Folly", folly_version
s.dependency "RCTTypeSafety"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Text/React-RCTText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,mm}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"
s.framework = ["MobileCoreServices"]
s.framework = ["UniformTypeIdentifiers"]
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }

s.dependency "Yoga"
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <React/RCTTextView.h>

#import <MobileCoreServices/UTCoreTypes.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import <React/RCTUtils.h>
#import <React/UIView+React.h>
Expand Down Expand Up @@ -282,10 +282,10 @@ - (void)copy:(id)sender
error:nil];

if (rtf) {
[item setObject:rtf forKey:(id)kUTTypeFlatRTFD];
[item setObject:rtf forKey:UTTypeFlatRTFD.identifier];
}

[item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];
[item setObject:attributedText.string forKey:UTTypeUTF8PlainText.identifier];

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.items = @[ item ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "RCTParagraphComponentView.h"
#import "RCTParagraphComponentAccessibilityProvider.h"

#import <MobileCoreServices/UTCoreTypes.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#import <react/renderer/components/text/ParagraphComponentDescriptor.h>
#import <react/renderer/components/text/ParagraphProps.h>
#import <react/renderer/components/text/ParagraphState.h>
Expand Down Expand Up @@ -306,10 +306,10 @@ - (void)copy:(id)sender
error:nil];

if (rtf) {
[item setObject:rtf forKey:(id)kUTTypeFlatRTFD];
[item setObject:rtf forKey:UTTypeFlatRTFD.identifier];
}

[item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];
[item setObject:attributedText.string forKey:UTTypeUTF8PlainText.identifier];

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.items = @[ item ];
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Pod::Spec.new do |s|
s.header_dir = header_dir
s.module_name = module_name
s.weak_framework = "JavaScriptCore"
s.framework = "MobileCoreServices"
s.framework = "UniformTypeIdentifiers"
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"OTHER_CFLAGS" => "$(inherited) " + folly_compiler_flags + new_arch_flags,
Expand Down
Loading