Compatible backports of commonly used type properties for `URL` that are only available from iOS 16.0+ / macOS 13.0+ / tvOS 16.0+ / watchOS 9.0+.

Overview

URLCompatibilityKit

URLCompatibilityKit is a lightweight Swift package that adds compatible backports of commonly used type properties, type and instance properties for URL that are only available from iOS 16.0+ / macOS 13.0+ / tvOS 16.0+ / watchOS 9.0+.

Avoid conditional compiler directives in your code!

Without URLCompatibilityKit With URLCompatibilityKit
let fileURL: URL

if #available(iOS 16.0, *) {
    fileURL = URL
        .documentsDirectory
        .appending(path: "myfile")
} else {
    fileURL = try FileManager.default
        .url(
            for: .documentDirectory,
            in: .userDomainMask,
            appropriateFor: nil,
            create: false
        )
        .appendingPathComponent(
            "myfile", isDirectory: false
        )
}
import URLCompatibilityKit

let fileURL = URL
    .documentsDirectory
    .appending(path: "myfile")

It currently includes backward-compatible versions of the following APIs:

Type Properties

  • URL.applicationDirectory
  • URL.applicationSupportDirectory
  • URL.cachesDirectory
  • URL.desktopDirectory
  • URL.documentsDirectory
  • URL.downloadsDirectory
  • URL.homeDirectory
  • URL.libraryDirectory
  • URL.moviesDirectory
  • URL.musicDirectory
  • URL.picturesDirectory
  • URL.sharedPublicDirectory
  • URL.temporaryDirectory
  • URL.trashDirectory
  • URL.userDirectory

Type Methods

  • URL.currentDirectory() -> URL
  • homeDirectory(forUser: String) -> URL?

Instance Methods

  • append(path:) // equivalent to using URL.DirectoryHint = .inferFromPath
  • appending(path:) // equivalent to using URL.DirectoryHint = .inferFromPath

Once you're ready to make iOS 16 your minimum deployment target, you can safely unlink URLCompatibilityKit from your project without making any additional changes to your code base (besides removing all import URLCompatibilityKit statements).

URLCompatibilityKit marks its added APIs either as obsolete or as deprecated when integrated into an iOS 16-based project, so you'll get a reminder that it's no longer needed once you're able to use the matching system APIs directly.

Installation

URLCompatibilityKit is distributed using the Swift Package Manager. To install it, use Xcode’s File > Add Packages... menu command to add it to your iOS app project.

Then import URLCompatibilityKit wherever you’d like to use it:

import URLCompatibilityKit
You might also like...
This is a course project for CodePath Professional iOS Development class.

Parstagram - Part I This is an Instagram clone with a custom Parse backend that allows a user to post photos and view a global photos feed. Time spent

Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.
Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.

iOS (Swift 5): Test MVVM avec Combine et UIKit L'architecture MVVM et la programmation réactive fonctionnelle sont très utlisées dans le développement

iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit
iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit

iOS (Swift 5): MVVM test with Combine and UIKit MVVM and functional reactive programming (FRP) are very used in iOS development inside companies. Here

USC's ITP342 iOS Development Swift Final Project

READMEBlogs USC's ITP342 iOS Development Swift Final Project NOTE: You'll need to attach your own Firebase to the app LINK TO APP ZIP FILE: https://dr

USC's ITP342 iOS Development Swift Final Project

READMEBlogs USC's ITP342 iOS Development Swift Final Project NOTE: You'll need to attach your own Firebase to the app LINK TO APP ZIP FILE: https://dr

Create a simple MVVM-C iOS architecture with Swift for starters

iOS-Architecture-MVVM MVVM+Coordinators IOS Architecture Tutorial By Bobby Pehtr

This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.
This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.

日本語 UIPiPView This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS. Using this library, information that is updated in real

NewsAppMVVM - A Swift iOS App created to practice MVVM Design Pattern
NewsAppMVVM - A Swift iOS App created to practice MVVM Design Pattern

NewsAppMVVM A Swift iOS App created to practice MVVM Design Pattern. This app re

Releases(1.0.0)
Owner
Marco Eidinger
Software engineer working on open source and enterprise mobile SDKs for iOS and macOS developers written in Swift
Marco Eidinger
This a simple swiftui app where i used mvvm architecture, coredata swiftui and so on..

SwiftUI MVVM COREDATA NOTE APP This a simple swiftui app where i used mvvm architecture, coredata swiftui and so on... #FEATURES SWIFTUI MVVM COREDATA

Isaias Cuvula 1 Jul 20, 2022
Tech blog about Put Generic Protocol as Variable Type. How Combine Publisher put into AnyPublisher

How to Put Generic Protocol as Variable Type Have you ever put a Protocol on a variable? I believe you do. The Delegate pattern is using a lot in UIKi

Tsungyu Yu 8 Aug 17, 2021
An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing.

ClampedInteger An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing. Examples let big = ClampedIntege

Berik Visschers 0 Jan 17, 2022
A simple menubar app can give you quick access to some macOS functions

OneClick This simple menubar app can give you quick access to some macOS functio

mik3 32 Dec 19, 2022
FinderEx - MacOS Finder Sync Extension to Allow Adding Custom Actions

FinderEx MacOS Finder Sync Extension to Allow Adding Custom Actions Description

null 4 Jul 21, 2022
Port of BetterPS to Apple WebKit for macOS.

BetterPS-Safari Port of BetterPS to Apple WebKit for macOS. Note: .xcodeproj file will not be uploaded for privacy reasons. Please initiate a new proj

null 2 Jun 29, 2022
This is an iOS Safari Extension Sample that adds a "Develop menu" to Safari on iOS to allow you to analyze websites.

Develop Menu for Mobile Safari This is an iOS Safari Extension that adds a "Develop menu" to Safari on iOS to allow you to analyze websites. This is a

Watanabe Toshinori 1 Dec 7, 2022
List of awesome iOS & Swift stuff!!

Awesome iOS Developer Feel free to fork this repository and pull requests!! ?? Content Coding Convention Swift Lint Design Pattern Adaptor Delegation

Jungpyo Hong 666 Jan 8, 2023
An assignment for ios Dev intern position

iOS Assignment An assignment for ios Dev intern position Design Process A UI design for the project is made in FIGMA. Link here Figma Sneek Peek Descr

Divyam Solanki 11 Apr 28, 2022
SwiftUI iOS component for Step Indications.

StepperView SwiftUI iOS component for Step Indications Table of Contents Features Documentation Installation CocoaPods Carthage Swift Package Manager

Badarinath Venkatnarayansetty 851 Dec 29, 2022