SwifterSwift /SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity.
★ 15,250⑂ 1,660
15,250
stars
+0+-1+24
1,660
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions
README
SwifterSwift
Small, self-contained Swift extensions for the standard library, Foundation, UIKit, AppKit and other Apple frameworks.
Each extension lives in its own file and depends only on the standard library and Apple's frameworks, never on another part of SwifterSwift. Use the whole library, pick the areas you need, or copy a single file into your project.
Highlights
- Self-contained. One extension per file, with no shared helpers, so any file can be copied on its own.
- Tested. Every extension has its own Swift Testing suite, including edge cases such as empty input, Unicode, other locales and time zones.
- Documented. Every extension has a documentation comment with an example, and the full reference is built with DocC.
- Modular. One product per area, plus a SwifterSwift product that includes them all.
- Cross-platform. Apple platforms, plus Linux, Android, WebAssembly and Windows for the areas available there.
Requirements
| | Minimum version |
|---|---|
| Swift | 6.2 (Xcode 26) |
| iOS, iPadOS | 17 |
| macOS | 14 |
| Mac Catalyst | 17 |
| tvOS | 17 |
| watchOS | 10 |
| visionOS | 1 |
The standard library and Foundation areas also build on Linux, Android, WebAssembly and Windows.
Installation
SwifterSwift is distributed with Swift Package Manager.
Package.swift
Add the package to your dependencies:
swift
dependencies: [
.package(url: "https://github.com/SwifterSwift/SwifterSwift.git", from: "9.0.0")
]
Then add the products you need to your target:
swift
.target(
name: "MyApp",
dependencies: [
.product(name: "SwifterSwift", package: "SwifterSwift")
]
)
Xcode
Choose File › Add Package Dependencies…, enter https://github.com/SwifterSwift/SwifterSwift.git, and select the products to add to your target.
Quick start
swift
import SwifterSwift
let numbers = [10, 20, 30]
numbers[safe: 3] // nil
let url = URL(string: "https://example.com/search?q=swift")!
url.queryValue(for: "q") // "swift"
let frame = CGRect(x: 0, y: 0, width: 100, height: 50)
frame.center // (50.0, 25.0)
Products
| Product | Extends | Platforms |
|---|---|---|
| SwifterSwift | Everything below | All |
| SwifterSwiftStdlib | The Swift standard library | All |
| SwifterSwiftFoundation | Foundation | All |
| SwifterSwiftCoreGraphics | Core Graphics and Core Animation | Apple platforms |
| SwifterSwiftUIKit | UIKit | iOS, iPadOS, Mac Catalyst, tvOS, visionOS, and watchOS where UIKit types exist |
| SwifterSwiftAppKit | AppKit | macOS |
| SwifterSwiftCoreLocation | Core Location | Apple platforms |
| SwifterSwiftMapKit | MapKit | Apple platforms |
| SwifterSwiftSpriteKit | SpriteKit | Apple platforms |
| SwifterSwiftCryptoKit | CryptoKit | Apple platforms |
| SwifterSwiftHealthKit | HealthKit | iOS, iPadOS, macOS, watchOS, visionOS |
Every product builds on every platform. Where a framework isn't available, its product is empty.
[!NOTE]
The SwifterSwift and SwifterSwiftHealthKit products link HealthKit. If your app do