Skip to content
An open kit providing useful functions across iOS, watchOS, macOS and tvOS, taking advantage of Swifts rich feature set.
Swift
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources
Tests/OpenKitTests
LICENSE
Package.swift
README.md

README.md

OpenKit

Build Status

An open kit providing useful functions across iOS, watchOS, macOS and tvOS, taking advantage of Swifts rich feature set.

OpenKit contains eight major components. To make these more comprehensible, each of them has its own documentation section, which is linked to in the sections below. There is also a section for custom iOS UI and one for all Extensions.

Features

Components

Alerting

Alerting defines a uniform way to show alerts, login prompts and other messages using easy to use and understand syntax.

OKAlerting.showAlert(title: "Test")
iOS watchOS macOS tvOS
let block : OKAlerting.Action.Block = { (action, textFieldValues) -> Void in 
    // Do something here
}

OKAlerting.showAlert(title: "Test",
                        message: "Toast",
                        showOKAction: true,
                        showCancelAction: true,
                        okBlock: block,
                        cancelBlock: nil,
                        additionalActions: [OKAlerting.Action(title: "Something Else", handler: block)],
                        textFieldConfigurations: [])
iOS watchOS macOS tvOS
let block : OKLoginReturnBlock = { (user, password) -> Void in 
    // Do something here
}

OKAlerting.showLoginPrompt(title: "Login",
                           message: "Enter your credentials",
                           userPlaceholder: "Username",
                           passwordPlaceholder: "Password",
                           completion: block,
                           cancellation: nil)
iOS watchOS macOS tvOS
-

Documentation

Appearance

iOS only

Appearance provides a standardized way to customize the appearance of applications. Handling most tasks automatically, notifying objects when the appearance style or system font size changes and providing easy ways to access these. It is highly customizable and has three default appearance styles: light (standard iOS), dark and black.

Documentation

Cryptography

OKCryptography is a wrapper around TweetNacl, providing the Curve25519XSalsa20Poly1305BoxAlgorithm, XSalsa20Poly1305SecretBoxAlgorithm and Ed25519Algorithm classes.

Documentation

Dispatch

OKDispatchHelper helps submitting blocks to dispatch queues.

OKDispatchHelper.dispatch(on: .main,
                          block: {
   // Do something here
})

Documentation

File System

OKFileSystemItem and its subclasses OKFile and OKDirectory provide easy access to the File System.

Documentation

Networking

Networking offers an easy way to send simple or advanced network requests.

Simple:

OKNetworking.request(url: "https://github.com/JannThomas/OpenKit",
                     completion: { (result, error) -> Void in 
    // Do something here
})

Advanced:

let block : OKNetworking.RequestCompletionBlock = { (result, error) -> Void in 
    // Do something here, for example: result.jsonValue?["Test"]["Toast"]
}

let headerFields : [OKNetworking.Request.HeaderField: String] = [.accept : "*/*",
                                                                 "CustomField" : "CustomValue"]

OKNetworking.request(url: "https://github.com/JannThomas/OpenKit",
                     options: [.requestMethod(value: .post), 
                               .headerFields(value: headerFields), 
                               .body(value: .xWwwFormUrlencoded(value: ["Key" : "Value"]))],
                     completion: block)

Documentation

Settings

iOS only

Settings manages, stores and displays settings in a standardized way that resembles Apple's Settings. It's also highly customizable. Completely custom UI is implementable.

Documentation

RegEx

OKRegexMatch handles regular expressions.

guard let matches = "Test".regexMatches(with: "(T)est") else {
   return
}

print(matches.first?.captureGroups.first) // "T"

Documentation

Custom iOS UI

OKLoadingIndicator OKRefreshControl
OKTimeIntervalChooserViewController (mode: .date) in OKSegmentedViewController in OKPopoverController OKTimeIntervalChooserViewController (mode: .timeInterval) in OKSegmentedViewController in OKPopoverController OKTimeIntervalChooserViewController (mode: .timeInDay) in OKBottomSheetPopoverController

Extensions

A big part of OpenKit are extensions. You can find all of them in the documentation, but here are the most important ones with examples.

Installation

Swift Package Manager

OpenKit relies on Swift Package Manager and is installed by adding a

To-Do

  • Fix watchOS XCTest Error
  • Implement OKFile
  • Introduce a JSDateTimeHelper class, which contains, for example, something like String.extractedSeconds
  • Make platform exclusive features available to other platforms (specifically Settings)
  • Uploading in Networking
You can’t perform that action at this time.