Contents

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

  1. File > Add Package Dependencies...
  2. Enter: https://github.com/TheRakiburKhan/RKUtils.git
  3. 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/false

UIKit (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

- 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