UTIKit is an UTI (Uniform Type Identifier) wrapper for Swift.

Related tags

Utility UTIKit
Overview

UTIKit

CI status

UTIKit is an UTI (Uniform Type Identifier) wrapper for Swift.

Features

UTIKit is a full featured library including entire UTI functions.

  • Convertibility
    • Filename extension
    • MIME type
    • OSType (OS X only)
    • Pasteboard type (OS X only)
  • Equality
  • Conformance
  • and others…

Usage

Making from an UTI string

let jpeg = UTI("public.jpeg")

Making from a filename extension

let jpeg = UTI(filenameExtension: "jpeg")

Making from a MIME type

let jpeg = UTI(mimeType: "image/jpeg")

Getting filename extensions or MIME types

UTI(mimeType: "image/jpeg").filenameExtensions // => ["jpeg", "jpg", "jpe"]

UTI(filenameExtension: "jpeg").mimeTypes // => ["image/jpeg"]

Equality

UTI(mimeType: "image/jpeg") == UTI(filenameExtension: "jpeg") // => true

Conformance

switch UTI(kUTTypeJPEG) {
case UTI(kUTTypeImage):
    print("JPEG is a kind of images")
default:
    fatalError("JPEG must be a image")
}

Requirements

  • Swift 5.0 or later
  • iOS 8 or later
  • OS X 10.10 or later

Author

Hiroki Kato, [email protected]

License

UTIKit is available under the MIT license. See the LICENSE file for more info.

Comments
  • Update Podspecs for the

    Update Podspecs for the "redundant public"

    Hi @cockscomb, Can you update your Podspecs to include changes of https://github.com/cockscomb/UTIKit/commit/3f39c309e8fa30de9fed819b27e8766eee21cbb2 when update pod ? Thanks

    opened by iNono22 2
  • Swift 3.1 warning: Conditional downcast from 'CFString?'

    Swift 3.1 warning: Conditional downcast from 'CFString?'

    Hey @cockscomb, thanks for sharing this useful little library.

    I'm getting the following warning since upgrading our project to Swift 3.1:

    …/UTIKit/UTIKit/UTI.swift:241:82: Conditional downcast from 'CFString?' to 'String' is a bridging conversion; did you mean to use 'as'?

    opened by jamesbebbington 2
  • Support Xcode 7 with Swift 2

    Support Xcode 7 with Swift 2

    I have converted to Swift 2, with some points:

    • As documented, UTTypeCreatePreferredIdentifierForTag now return NULL if inTagClass is not a known tag class. With known constants for inTagClass, I think we can use forced unwrapping.
    • downcasting directly CFArray as? [String] now always fail. As a workaround, I added preceding as NSArray casts.
    opened by banjun 2
  • Swift3.0

    Swift3.0

    I'm submitting this request to master, but I believe that there should be a swift-3 branch instead. What I would propose as the timeline would be:

    1. Maintain 2.3 and 3.0 branches until Xcode 8 GM is released.
    2. Keep the 2.3 branch long term for legacy support.
    3. Merge 3.0 into master.
    4. When the next version of Swift is released, create a legacy swift-3.0 branch off of master.

    This way, user's of the framework can target a specific branch if they need legacy support, or master if they want the most current version.

    Thoughts?

    opened by davbeck 1
  • Updated project file for Swift 2.3

    Updated project file for Swift 2.3

    There are very few changes between Swift 2.2 and 2.3. In the case of UTIKit, nothing needs to be changed at a source level. However, if you try to build the app without running the migration in Xcode, for instance with Carthage, it will assume Swift 3 and generate a bunch of errors.

    opened by davbeck 1
  • Support Carthage

    Support Carthage

    opened by kumapo 1
  • Update to swift version 5.0 and Xcode 11

    Update to swift version 5.0 and Xcode 11

    Hi @cockscomb , I basically open the project in Xcode 11 and remove basics warning for compatibility with swift 5.0 I also already update pod version to 2.0.3. Thanks in advance for the new release.

    opened by iNono22 0
  • Bump tzinfo from 1.2.5 to 1.2.10

    Bump tzinfo from 1.2.5 to 1.2.10

    Bumps tzinfo from 1.2.5 to 1.2.10.

    Release notes

    Sourced from tzinfo's releases.

    v1.2.10

    TZInfo v1.2.10 on RubyGems.org

    v1.2.9

    • Fixed an incorrect InvalidTimezoneIdentifier exception raised when loading a zoneinfo file that includes rules specifying an additional transition to the final defined offset (for example, Africa/Casablanca in version 2018e of the Time Zone Database). #123.

    TZInfo v1.2.9 on RubyGems.org

    v1.2.8

    • Added support for handling "slim" format zoneinfo files that are produced by default by zic version 2020b and later. The POSIX-style TZ string is now used calculate DST transition times after the final defined transition in the file. The 64-bit section is now always used regardless of whether Time has support for 64-bit times. #120.
    • Rubinius is no longer supported.

    TZInfo v1.2.8 on RubyGems.org

    v1.2.7

    • Fixed 'wrong number of arguments' errors when running on JRuby 9.0. #114.
    • Fixed warnings when running on Ruby 2.8. #112.

    TZInfo v1.2.7 on RubyGems.org

    v1.2.6

    • Timezone#strftime('%s', time) will now return the correct number of seconds since the epoch. #91.
    • Removed the unused TZInfo::RubyDataSource::REQUIRE_PATH constant.
    • Fixed "SecurityError: Insecure operation - require" exceptions when loading data with recent Ruby releases in safe mode.
    • Fixed warnings when running on Ruby 2.7. #106 and #111.

    TZInfo v1.2.6 on RubyGems.org

    Changelog

    Sourced from tzinfo's changelog.

    Version 1.2.10 - 19-Jul-2022

    Version 1.2.9 - 16-Dec-2020

    • Fixed an incorrect InvalidTimezoneIdentifier exception raised when loading a zoneinfo file that includes rules specifying an additional transition to the final defined offset (for example, Africa/Casablanca in version 2018e of the Time Zone Database). #123.

    Version 1.2.8 - 8-Nov-2020

    • Added support for handling "slim" format zoneinfo files that are produced by default by zic version 2020b and later. The POSIX-style TZ string is now used calculate DST transition times after the final defined transition in the file. The 64-bit section is now always used regardless of whether Time has support for 64-bit times. #120.
    • Rubinius is no longer supported.

    Version 1.2.7 - 2-Apr-2020

    • Fixed 'wrong number of arguments' errors when running on JRuby 9.0. #114.
    • Fixed warnings when running on Ruby 2.8. #112.

    Version 1.2.6 - 24-Dec-2019

    • Timezone#strftime('%s', time) will now return the correct number of seconds since the epoch. #91.
    • Removed the unused TZInfo::RubyDataSource::REQUIRE_PATH constant.
    • Fixed "SecurityError: Insecure operation - require" exceptions when loading data with recent Ruby releases in safe mode.
    • Fixed warnings when running on Ruby 2.7. #106 and #111.
    Commits
    • 0814dcd Fix the release date.
    • fd05e2a Preparing v1.2.10.
    • b98c32e Merge branch 'fix-directory-traversal-1.2' into 1.2
    • ac3ee68 Remove unnecessary escaping of + within regex character classes.
    • 9d49bf9 Fix relative path loading tests.
    • 394c381 Remove private_constant for consistency and compatibility.
    • 5e9f990 Exclude Arch Linux's SECURITY file from the time zone index.
    • 17fc9e1 Workaround for 'Permission denied - NUL' errors with JRuby on Windows.
    • 6bd7a51 Update copyright years.
    • 9905ca9 Fix directory traversal in Timezone.get when using Ruby data source
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump cocoapods-downloader from 1.2.2 to 1.6.3

    Bump cocoapods-downloader from 1.2.2 to 1.6.3

    Bumps cocoapods-downloader from 1.2.2 to 1.6.3.

    Release notes

    Sourced from cocoapods-downloader's releases.

    1.6.3

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.2

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.1

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.0

    Enhancements
    • None.
    Bug Fixes
    • Adds a check for command injections in the input for hg and git.
      orta #124

    1.5.1

    Enhancements
    • None.
    Bug Fixes
    • Fix "can't modify frozen string" errors when pods are integrated using the branch option
      buju77 #10920

    1.5.0

    ... (truncated)

    Changelog

    Sourced from cocoapods-downloader's changelog.

    1.6.3 (2022-04-01)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.2 (2022-03-28)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.1 (2022-03-23)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.0 (2022-03-22)

    Enhancements
    • None.
    Bug Fixes
    • Adds a check for command injections in the input for hg and git.
      orta #124

    1.5.1 (2021-09-07)

    Enhancements
    • None.

    ... (truncated)

    Commits
    • c03e2ed Release 1.6.3
    • f75bccc Disable Bazaar tests due to macOS 12.3 not including python2
    • 52a0d54 Merge pull request #128 from CocoaPods/validate_before_dl
    • d27c983 Ensure that the git pre-processor doesn't accidentally bail also
    • 3adfe1f [CHANGELOG] Add empty Master section
    • 591167a Release 1.6.2
    • d2564c3 Merge pull request #127 from CocoaPods/validate_before_dl
    • 99fec61 Switches where we check for invalid input, to move it inside the download fun...
    • 96679f2 [CHANGELOG] Add empty Master section
    • 3a7c54b Release 1.6.1
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Add `conforms(to:)` API

    Add `conforms(to:)` API

    Two-case switch statements aren't nice when there's no expectation of future cases. I just want do a simple conformance check which results in a Bool, just like UTTypeConformsTo(_:_:), but without the CFString boilerplate.

    I could do it with

    let doesConform = uti ~= candidateParentUTI
    

    but it's quite cryptic.

    let doesConform = uti.conforms(to: candidateParentUTI)
    

    Would be better, undesputably so, IMHO.

    Thoughts?

    opened by amomchilov 0
  • mimeTyp that can't be recognise

    mimeTyp that can't be recognise

    Hi there, I'm using Xcode 10.1 swift 4.2 tested on simulator, iphone and playground

    when I init an UTI let uti = UTI("com.apple.uikit.image") print(uti.declaration)

    it prints// [:]

    - Background of the problem

    the reason I need this because when I copy an image from WhatsApp, WhatsApp will add one item that has three items in the `let paste = UIPasteboard.general.item // type of [[String : Any]]

    print (paste)

    // [["public.png": <UIImage: 0x2821b5730>, {1024, 1017}, "public.jpeg": <UIImage: 0x2821e5c70>, {1024, 1017}, "com.apple.uikit.image": <OS_dispatch_data: data[0x2810a6c40] = { leaf, size = 1015803, buf = 0x11c6fc000 }>]]`

    you can see WhatsApp add [["public.png" "public.jpeg", "com.apple.uikit.image"]]

    I always take only the first item of those three and their order changes sometimes, the problem occur when "com.apple.uikit.image" is the first item

    thanks

    opened by turk-jk 3
Owner
Hiroki Kato
Hiroki Kato
Swift type modelling the success/failure of arbitrary operations.

Result This is a Swift µframework providing Result<Value, Error>. Result<Value, Error> values are either successful (wrapping Value) or failed (wrappi

Antitypical 2.5k Dec 26, 2022
Type-Safe Associated Objects in Swift

Type-Safe Associated Objects in Swift TSAO is an implementation of type-safe associated objects in Swift. Objective-C associated objects are useful, b

Lily Ballard 135 Dec 21, 2022
Swift package for accessing SF Symbols in a type safe manner.

Swift Package Information Code Coverage Swift package for accessing SF Symbols in a type safe manner. Features ?? Contains all SF Symbols - 1.0, 2.0,

null 6 Dec 7, 2021
DeviceGuru is a simple lib (Swift) to know the exact type of the device

DeviceGuru DeviceGuru is a simple lib (Swift) to know the exact type of the device, e.g. iPhone 6 or iPhone 6s Easy to use Light weight From version 5

Inder Kumar 442 Dec 28, 2022
Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Mathias Quintero 9 Sep 25, 2022
🚀Comprehensive Redux library for SwiftUI, ensures State consistency across Stores with type-safe pub/sub pattern.

??Comprehensive Redux library for SwiftUI, ensures State consistency across Stores with type-safe pub/sub pattern.

Cheng Zhang 18 Mar 9, 2022
MediaType is a library that can be used to create Media Types in a type-safe manner.

This is a general purpose Swift library for a concept of typed treatment for Media Types. We use this library on clients and servers to speak the same dialect and to enjoy all the comfort strong types provide over raw strings.

21Gram Consulting 79 Jul 19, 2022
A Codable Undefinable type for handling JSON undefined values.

Undefinable Overview The purpose of this type is represent the JSON undefined state in Swift structs and classes. The Undefinable enum is a generic wi

David Monagle 3 Dec 18, 2022
A CMIO Camera Extension of the creative camera type, with configuration app

ArtFilm A CMIO Camera Extension of the creative camera type, with configuration app ArtFilm is the sample code for the blog post Getting To Grips With

Halle 7 Jan 1, 2023
Swift-ndi - Swift wrapper around NewTek's NDI SDK

swift-ndi Swift wrapper around NewTek's NDI SDK. Make sure you extracted latest

Alessio Nossa 12 Dec 29, 2022
💡 A light Swift wrapper around Objective-C Runtime

A light wrapper around Objective-C Runtime. What exactly is lumos? lumos as mentioned is a light wrapper around objective-c runtime functions to allow

Suyash Shekhar 139 Dec 19, 2022
A Swift property wrapper which stores the previous value

swift-with-previous A Swift property wrapper which stores the previous value. The previous value can be get by the projected value $propertyName. impo

IKEDA Sho 3 Feb 22, 2022
Swift wrapper for PuLP module.

SwiftPuLP Wraps Python Linear Programming PuLP module. Requirements Requires PuLP to be installed, and may require PYTHON_LIBRARY environment variable

Michel Tilman 0 Dec 24, 2021
Coz profiler Swift wrapper/bindings

Swift Coz (Linux Only) Coz profiler Swift wrapper/bindings. This is a Swift wrapper around the Coz profiler here: https://github.com/plasma-umass/coz

Krzysztof Majk 4 Aug 5, 2022
An unofficial wrapper around FSEvent tailored for Swift 5.

EonilFSEvents Eonil 2018 Maintenance. 2019 Maintenance. It's possible to use FSEvents directly in Swift, but it still involves many boilerplate works

eonil 87 Dec 24, 2022
A swift wrapper for NSTimer

Every.Swift - A Convenient NSTimer Wrapper Usage Provided that your class implement TimerManageable protocol you just do: self.every(3.seconds) {

Samhan Salahuddin 271 Apr 14, 2022
A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed.

Bookmark A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed. This class wraps Swift's URL

Darren Ford 8 Nov 3, 2022
Backports the new @Invalidating property wrapper to older platforms

ViewInvalidating A property wrapper that backports the new @Invalidating property wrapper to older versions of iOS/tvOS/macOS. For more information on

Suyash Srijan 61 Nov 23, 2022
Dungeon Crawl: Stone Soup iOS Webtiles wrapper

dcss-ios Dungeon Crawl: Stone Soup iOS Webtiles wrapper Summary This project aims to make DCSS webtiles a joy to play on any iOS device without an ext

Jon Lazar 2 Aug 10, 2022