A Swift library that provides seamless backward compatibility for modern APIs on older OS versions.
It’s based on Dave DeLong’s elegant approach to backwards compatibility in Swift. Definitely read that before diving in.
import Backport
// Basic usage
let view = MyView()
view.backport.modernFeature()
// SwiftUI
Text("Hello")
.backport.modernModifier()
// Custom extensions
extension Backport where Content: UIView {
func modernShadow() -> Content {
// Implementation
return content
}
}Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/inekipelov/swift-backport", from: "0.1.0")
]MIT License - see LICENSE file for details.