therakiburkhan/rkutils
A comprehensive, cross-platform Swift package with extensions and utilities for UIKit, AppKit, and Foundation.
Features
- π Cross-Platform - Works on iOS, macOS, tvOS, watchOS, visionOS, and Linux
- π¨ UIKit & AppKit - Consistent APIs with platform parity
- π¦ Zero Dependencies - Lightweight and efficient
- π§ͺ Well Tested - Comprehensive test coverage (194 tests)
- π Production Ready - Battle-tested in production apps
Installation
Swift Package Manager
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/TheRakiburKhan/RKUtils.git", from: "3.1.1")
]Xcode
- File > Add Package Dependencies...
- Enter:
https://github.com/TheRakiburKhan/RKUtils.git - Select version 3.1.1+ and add to your target
Target Configuration
.target(
name: "YourTarget",
dependencies: [
.product(name: "RKUtils", package: "RKUtils")
]
)Quick Examples
Foundation Extensions
import RKUtils
// String
"test@example.com".isValidEmail // true
"2024-12-08".toDate(stringFormat: "yyyy-MM-dd")
// Date
Date().toString(format: "yyyy-MM-dd")
Date().relativeTime() // "2 hours ago" (Apple platforms only)
// Numbers
1234.abbreviated // "1.2K"
3.14159.roundedString(toPlaces: 2) // "3.14"
10.times { print("Hello") }
// Bundle
Bundle.main.releaseVersionNumber // "1.0.0"
Bundle.main.bundleDisplayName // "My App"
Bundle.main.isSimulator // true/falseUIKit (iOS/tvOS/visionOS)
import RKUtils // Single import for all platforms
// UIView styling
view.setCornerRadius(cornerRadius: 10)
view.setBorder(width: 2, color: .red)
view.setShadow(color: .black, opacity: 0.3, radius: 4)
view.setLinearGradientBackground(colors: [.blue, .purple])
view.applyBlurEffect(style: .regular)
// UIColor
let color = UIColor(hexString: "#FF5733")
let lighter = color.lighter(by: 0.2)
let darker = color.darker(by: 0.3)
// UITextField
textField.setSecureTextToggleToRight(.systemBlue)
textField.textPublisher().sink { text in print(text) }
textField.setLeftPaddingPoints(16)
// Type-safe table views
tableView.register(cell: MyCell.self)
let cell = tableView.dequeueReusableCell(MyCell.self, for: indexPath)AppKit (macOS)
import RKUtils // Same import!
// NSView - Same API as UIView!
view.setCornerRadius(cornerRadius: 10)
view.setBorder(width: 2, color: .red)
view.setShadow(color: .black, opacity: 0.3, radius: 4)
view.setLinearGradientBackground(colors: [.blue, .purple])
view.applyBlurEffect(material: .contentBackground)
// NSColor - Same API as UIColor!
let color = NSColor(hexString: "#FF5733")
let lighter = color.lighter(by: 0.2)
// NSSecureTextField
secureTextField.setSecureTextToggleToRight(.systemBlue)
// Type-safe registration
tableView.register(cell: MyCell.self)
let cell = tableView.dequeueReusableCell(cell: MyCell.self, owner: self)SwiftUI
import SwiftUI
import RKUtils
struct ContentView: View {
var body: some View {
Text("Hello")
.foregroundColor(.white)
.padding()
.background(
Color(hexString: "#007AFF")
.lighter(by: 0.2)
)
}
}Platform Requirements
| Platform | Version | Features | | -------- | ------- | ------------------ | | iOS | 14.0+ | Full | | macOS | 11.0+ | Full | | tvOS | 14.0+ | Full | | watchOS | 7.0+ | Foundation + SwiftUI | | visionOS | 1.0+ | Full | | Linux | Any | Core utilities\* |
Swift: 6.0+ | Xcode: 16.0+
<details> <summary><b>*Linux Limitations</b></summary>
Unavailable on Linux (Apple frameworks only):
- CoreLocation (CLLocationCoordinate2D)
- CoreGraphics (CGRect)
- SwiftUI (Color)
- Advanced formatters (measurements, relative dates)
Linux gets simplified fallbacks for time formatting. See Platform Support for details.
</details>
Documentation
- π Official Documentation - Multi-platform documentation
- iOS/UIKit Documentation - macOS/AppKit Documentation
- π CHANGELOG - Version history and migration guides
- π Migration Guide - Upgrade from v2.x to v3.0
- π Issues - Report bugs or request features
All extensions include inline documentation. Use Xcode's Quick Help (β₯ + Click) for details.
What's New in v3.0
Single Target Architecture
v3.0 simplifies everything with a single unified target:
// Before (v2.x)
import RKUtilsUI // iOS
import RKUtilsMacOS // macOS
// After (v3.0)
import RKUtils // All platforms!Benefits:
- β One library, one import
- β Unified documentation
- β Simpler Package.swift
- β Same APIs, better experience
See the Migration Guide for upgrade instructions.
Contributing
Contributions welcome! Please read Contributing Guidelines before submitting PRs.
License
MIT License - see LICENSE for details.
Copyright Β© 2025 Rakibur Khan
<p align="center"> <a href="https://github.com/TheRakiburKhan/RKUtils/stargazers">βοΈ Star</a> β’ <a href="https://github.com/TheRakiburKhan/RKUtils/issues">π Issues</a> β’ <a href="https://github.com/TheRakiburKhan/RKUtils/pulls">π Pull Requests</a> </p>
<p align="center">Made with β€οΈ by <a href="https://github.com/TheRakiburKhan">Rakibur Khan</a></p>
Package Metadata
Repository: therakiburkhan/rkutils
Default branch: main
README: README.md