Repository navigation
Highlights
- Swift Package Manager. Add the package by URL. Drag-and-drop copying still works, but the package is the supported path.
- Swift 6 language mode with strict concurrency checking. No
@unchecked Sendable,nonisolated(unsafe), or@preconcurrency. - Public, documented API. Every public declaration has a DocC comment with a usage example. Build the docs with Product → Build Documentation in Xcode.
- New SwiftUI helpers:
shake(trigger:),shimmer(_:),redactedShimmer(_:),snapshot(scale:),roundedBorder(_:width:cornerRadius:), andColor(hex:). - New Foundation helpers:
chunked(into:),removingDuplicates(on:),clamped(to:),rounded(toPlaces:),orEmpty,asDictionary(),isValidURL,initials,truncated(to:), URL query helpers,Bundle.appVersionandbuildNumber, and calendar helpers onDate. - New UIKit helpers:
UIColor.hexString,UIView.addSubviews(_:), andUIView.pinToEdges(of:insets:), which follows right-to-left layout. - Catalog app with 56 live examples. Each one has a Play button and copyable code.
Requirements
| Swift | 6.0+ (Swift 6 language mode) |
| iOS | 17.0+ |
| macOS | 14.0+ (Foundation helpers only) |
| Dependencies | None |
Previous versions supported older iOS releases. 2.0.0 drops them.
Breaking changes
- Minimum platforms and language mode. iOS 17 and Swift 6 are now required.
changeDate(_:)returnsString?. It used to force-unwrap and crash on bad input.UIImage.toBase64StringisString?. It returnsnilif the image can't be encoded as PNG.ExFunctionis anenum. Its static methods are unchanged.dismissKeyboardOnTap()is unavailable in app extensions. It usesUIApplication.UINavigationBarhelpers useUINavigationBarAppearance. The default title color is now.label, so it adapts to dark mode.String.isEmailaccepts top-level domains up to 64 characters, matching the UIKit text field helper. It used to accept only up to 4.UIColor(hex:)treats invalid input as gray. Before, it could produce unexpected colors. It now also accepts#and 8-digit alpha.showAlertWithMessagetakes aduration(default three seconds). The completion handler now runs on the main actor.
Upgrading
// changeDate now returns an optional
if let formatted = "".changeDate("2026/1/05") {
label.text = formatted // "January 05, 2026"
}
// toBase64String is optional
let encoded: String? = image.toBase64String
// dismissKeyboardOnTap: keep it out of app extension targets
#if !APPLICATION_EXTENSION
view.dismissKeyboardOnTap()
#endifDeprecated, still working, and will be removed in a future major release:
showAleartViewwithTitle(_:message:)→showAlertView(title:message:)setCornerRadious()→setCornerRadius()
Behavior changes
Date.toString()andtoTimeString()use value-based format styles. The output format is the same, but they no longer share aDateFormatter.showAlertWithMessagewaits with a main-actorTask. It no longer uses a dispatch timer, so it is cancelled with its owner.UIImage.halfSizeImageandquarterhalfSizeImagerender at the screen's scale, so the output is sharper on Retina displays.scrollToBottomandscrollToToprespectadjustedContentInset, including the safe area.getRawJSON(from:)no longer drops non-ASCII characters.
Fixes
UIColor(hex:)accepts#and validates each character.getRawJSON(from:)handles non-ASCII text.- Force unwraps that could crash were removed from the library.
UILabel.attribute(_:effect:)no longer crashes when a label has no font.
Known limitations
UILabel.attribute(_:effect:)fixes font sizes when it runs. Call it again after a Dynamic Type change.showAlertWithMessagehides its message after the duration, which some users may miss. UseshowAlertView(title:message:)for messages users must read.
Full changelog
See [CHANGELOG.md](https://github.com/ANSCoder/Swift-Extension/blob/main/CHANGELOG.md).