Skip to content

Commit

Permalink
fix: btfuse/fuse#32 replaced deprecated usages of UTI type identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed Dec 13, 2023
1 parent 5b35a44 commit 06167a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions BTFuse/BTFuse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
94B0A6932AB77790008C291A /* BTFuseAPIServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B0A6922AB77790008C291A /* BTFuseAPIServer.m */; };
94B7A9CF2AC89E39003D294D /* BTFuseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B7A9CE2AC89E39003D294D /* BTFuseTests.m */; };
94B7A9D02AC89E39003D294D /* BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94A886C22A714F6D0098530D /* BTFuse.framework */; platformFilter = ios; };
94DF9FB72B293C9C00757EA7 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -152,13 +153,15 @@
94B0A6922AB77790008C291A /* BTFuseAPIServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIServer.m; sourceTree = "<group>"; };
94B7A9CC2AC89E39003D294D /* BTFuseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BTFuseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
94B7A9CE2AC89E39003D294D /* BTFuseTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTests.m; sourceTree = "<group>"; };
94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
94A886BD2A714F6D0098530D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
94DF9FB72B293C9C00757EA7 /* UniformTypeIdentifiers.framework in Frameworks */,
94668BF02B202F4900976FC1 /* UIKit.framework in Frameworks */,
94668BEE2B202F3200976FC1 /* WebKit.framework in Frameworks */,
94668BD32B1EBBB300976FC1 /* libopenssl.a in Frameworks */,
Expand Down Expand Up @@ -330,6 +333,7 @@
B09295BDA9DD81FE38C25D6F /* Frameworks */ = {
isa = PBXGroup;
children = (
94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */,
94668BFF2B22CC1800976FC1 /* libecho.a */,
94668BEF2B202F4900976FC1 /* UIKit.framework */,
94668BED2B202F3200976FC1 /* WebKit.framework */,
Expand Down
6 changes: 4 additions & 2 deletions BTFuse/src/BTFuseSchemeHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import <BTFuse/BTFuseAPIResponse.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <BTFuse/BTFuseLogger.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

NSString* const SCHEME = @"btfuse";
NSString* const HOST = @"localhost";
Expand Down Expand Up @@ -75,8 +76,9 @@ - (void)webView:(WKWebView*)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlS
NSData* content = [NSData dataWithContentsOfFile:assetPath];

NSString* fileExtension = [requestURL pathExtension];
NSString* UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExtension, NULL);
NSString* contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType);
UTType* uti = [UTType typeWithIdentifier:(NSString*) fileExtension];

NSString* contentType = [uti preferredMIMEType];

if (content) {
NSURLResponse* response = [[NSURLResponse alloc] initWithURL:requestURL MIMEType: contentType expectedContentLength:content.length textEncodingName:@"utf-8"];
Expand Down

0 comments on commit 06167a3

Please sign in to comment.