Skip to content

Repository files navigation

简体中文

Ask DeepWiki

ReerKit

ReerKit is a collection of native Swift extensions that provide convenient methods, syntactic sugar, and performance improvements for various native data types, UIKit, and Cocoa classes for iOS, macOS, tvOS, watchOS, and Linux platforms. All system type extensions in the framework have the re infix added to avoid ambiguity issues when calling the same name extension, such as

SGVsbG\n8gV29ybGQh".re.base64Decoded

"123".re.md5String

view.re.addSwiftUIView(Color.red)

There are also a of other convenient features available.

// Access dictionary contents using dot notation implemented by dynamic member lookup
let dict: [String: Any] = ...
dict.dml.user_name.re.string <=> dict["user_name"] as? String

// Weak reference container, automatically removes elements when they are destroyed.
WeakSet, WeakMap

// Set grayscale mode for UIView
view.re.isGrayModeEnabled = true

// Data Structure Encapsulation
BinaryTree, Tree, LinkedList, Queue, BoundedQueue, Stack, OrderedSet, OrderDictionary

// Lock Encapsulation
MutexLock, ReadWriteLock, Synchronizing, UnfaireLock

// PropertyWrappers
Clamped, Locked, Rounded, RWLocked, Trimmed

// Property macros, automatically generate associated-object or UserDefaults get/set accessors
@AssociatedValue var isAppeared: Bool = false
@Defaults("isAppeared") var isAppeared: Bool

// Other Utility
RSA, AES, CountdownTimer, Debouncer, Throttler, DeinitObserver, KeyboardManager, Keychain, Reachability, NanoID, MulticastDelegate

// Additionally, it provides a large number of extension methods and vars for frameworks such as the standard library, UIKit, and Foundation.
String+REExtensions
UIView+REExtensions
Array+REExtensions
Date+REExtensions
...

Usage

Link of Documents build by DocC

Or click here to download the doccarchive file

Requirements

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 4.0+

visionOS 1.0+

Ubuntu 14.04+

Swift 5.9+

XCode 15.4+

Installation

Carthage

To integrate ReerKit into your Xcode project using Carthage, specify it in your `Cartfile`:

github "ReerKit/ReerKit" ~> 1.2.7
Swift Package Manager

You can use Swift Package Manager to install ReerKit by adding the proper description in your `Package.swift` file:

import PackageDescription
let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/reers/ReerKit.git", from: "1.2.7")
    ]
)

Next, add `ReerKit` to your targets dependencies as shown below:

.target(
    name: "YOUR_TARGET_NAME",
    dependencies: [
        "ReerKit",
    ]
),

Then run `swift package update`.

Property macros are available through Swift Package Manager builds. The legacy Xcode project does not load the `ReerKitMacros` plugin.

@Defaults("isAppeared")
var isAppeared: Bool

@Defaults("launchCount", container: .standard) var launchCount: Int = 0

@AssociatedValue var isAppeared: Bool = false

Use property initializers for custom default values. When a default value is omitted, supported basic types use built-in defaults such as `false`, `0`, `""`, `Date()`, `Data()`, `URL(string: "/")!`, `UUID()`, and `Decimal(0)`.

`@Defaults` also works on type (`static`/`class`) properties.

Manual

Add the ReerKit folder to your Xcode project to use all extensions or specific extensions.