UTIKit

UTIKit Introduction

UTIKit is a Swift convenience API for working with Uniform Type Identifiers, commonly known as UTIs. It makes for a simplified and more intuitive way to handle file types and extensions in your iOS-based apps.

Features of UTIKit

  • Easily convert between UTI, file extension, and MIME types
  • Determines if a UTI matches another UTI or extension, like “public.image” and “png”
  • Provides a human-readable description of a UTI
  • Lists all known UTIs and their corresponding file extensions and MIME types
  • Supports iOS 8.0+

Installation of UTIKit

UTIKit can be swiftly integrated into your project using Swift Package Manager, Carthage or CocoaPods.

Swift Package Manager

.package(url: "https://github.com/cockscomb/UTIKit.git", from: "1.0.1")

Carthage

github "cockscomb/UTIKit"

CocoaPods

pod 'UTIKit'

Using UTIKit

Once installed, you can simply import UTIKit in any file where its facilities are required.

import UTIKit

Conversions


let uti = UTI(mimeType: "image/png")
print(uti?.description)
print(uti?.fileExtension)
print(uti?.preferredMimeType)

Matching


let fileUTI = UTI(tag: "public.png")
let isImage = fileUTI.conforms(to: .image)
print(isImage)

Thanks to UTIKit, working with UTIs in Swift has never been easier!