Name: DeviceKit
Owner: Kik Interactive
Description: DeviceKit is a value-type replacement of UIDevice.
Forked from: rounds/DeviceKit
Created: 2017-01-16 17:39:15.0
Updated: 2017-01-16 17:39:18.0
Pushed: 2016-10-25 07:24:35.0
Size: 162
Language: Swift
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Device
is a value-type replacement of UIDevice
.
DeviceKit can be installed in various ways.
ce 'https://github.com/CocoaPods/Specs.git'
form :ios, '8.0'
frameworks!
'DeviceKit', '~> 0.3.5'
ub "dennisweissmann/DeviceKit" ~> 0.3.5
To install it manually drag the DeviceKit project into your app project in Xcode or add it as a git submodule. In your project folder enter:
t submodule add https://github.com/dennisweissmann/DeviceKit.git
Here are some usage examples. All devices are also available as simulators:
one6 => .Simulator(.iPhone6)
one6s => .Simualtor(.iPhone6s)
etc.
device = Device()
t(device) // prints, for example, "iPhone 6 Plus"
evice == .iPhone6Plus {
// Do something
se {
// Do something else
device = Device()
evice.isPod {
// iPods (real or simulator)
se if device.isPhone {
/ iPhone (real or simulator)
se if device.isPad {
/ iPad (real or simulator)
device = Device()
evice.isSimulator {
// Running on one of the simulators(iPod/iPhone/iPad)
// Skip doing something irrelevant for Simulator
device = Device()
ch device {
.Simulator(.iPhone6s): break // You're running on the iPhone 6s simulator
.Simulator(.iPadAir2): break // You're running on the iPad Air 2 simulator
ult: break
groupOfAllowedDevices: [Device] = [.iPhone6, .iPhone6Plus, .iPhone6s, .iPhone6sPlus, .Simulator(.iPhone6), .Simulator(.iPhone6Plus), .Simulator(.iPhone6s), .Simulator(.iPhone6sPlus)]
device = Device()
evice.isOneOf(groupOfAllowedDevices) {
// Do you action
evice.batteryState == .Full || device.batteryState >= .Charging(75) {
print("Your battery is happy! ?")
evice.batteryLevel >= 50 {
install_iOS()
se {
showError()
If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of DeviceKit yourself and want others to use it too, please submit a pull request.