Skip to content

Commit

Permalink
Fix deprecation warnings about UTType API
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ronnqvist committed Dec 3, 2024
1 parent 31d5c3c commit 7f7b106
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Sources/SwiftDocC/Servers/FileServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import SymbolKit
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
#if canImport(UniformTypeIdentifiers)
import UniformTypeIdentifiers
#endif
#if os(Windows)
import WinSDK
#endif
Expand Down Expand Up @@ -116,15 +119,7 @@ public class FileServer {

#if os(macOS)

let unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext as CFString, nil)
guard let fileUTI = unmanagedFileUTI?.takeRetainedValue() else {
return defaultMimeType
}
guard let mimeType = UTTypeCopyPreferredTagWithClass (fileUTI, kUTTagClassMIMEType)?.takeRetainedValue() else {
return defaultMimeType
}

return (mimeType as NSString) as String
return UTType(filenameExtension: ext)?.preferredMIMEType ?? defaultMimeType

#elseif os(Windows)

Expand Down

0 comments on commit 7f7b106

Please sign in to comment.