All Projects → devicekit → Devicekit

devicekit / Devicekit

Licence: mit
DeviceKit is a value-type replacement of UIDevice.

Programming Languages

swift
15916 projects
python
139335 projects - #7 most used programming language
ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Devicekit

Efqrcode
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.
Stars: ✭ 4,121 (+15.56%)
Mutual labels:  hacktoberfest, tvos
Thorium
Platform for starship simulator controls
Stars: ✭ 109 (-96.94%)
Mutual labels:  hacktoberfest, simulator
Space Nerds In Space
Multi-player spaceship bridge simulator. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
Stars: ✭ 516 (-85.53%)
Mutual labels:  hacktoberfest, simulator
Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (-96.66%)
Mutual labels:  tvos, simulator
tracelog
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.
Stars: ✭ 52 (-98.54%)
Mutual labels:  tvos, swiftpm
Hexapod
Blazing fast hexapod robot simulator for the web.
Stars: ✭ 370 (-89.62%)
Mutual labels:  hacktoberfest, simulator
Awesome Emulators Simulators
A curated list of software emulators and simulators of PCs, home computers, mainframes, consoles, robots and much more...
Stars: ✭ 94 (-97.36%)
Mutual labels:  hacktoberfest, simulator
Metalperformanceshadersproxy
A proxy for MetalPerformanceShaders which takes to a stub on a simulator and to the real implementation on iOS devices.
Stars: ✭ 41 (-98.85%)
Mutual labels:  simulator, device
react-device-frameset
React device frameset component
Stars: ✭ 30 (-99.16%)
Mutual labels:  device, simulator
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (-28.18%)
Mutual labels:  hacktoberfest, tvos
Sdwebimageswiftui
SwiftUI Image loading and Animation framework powered by SDWebImage
Stars: ✭ 844 (-76.33%)
Mutual labels:  tvos, swiftpm
SwiftUIFormValidator
Declarative form validator for SwiftUI.
Stars: ✭ 34 (-99.05%)
Mutual labels:  tvos, swiftpm
Fiber2d
Cross-platform 2D Game Engine in pure Swift
Stars: ✭ 415 (-88.36%)
Mutual labels:  tvos, swiftpm
Gazebo
Open source robotics simulator.
Stars: ✭ 404 (-88.67%)
Mutual labels:  hacktoberfest, simulator
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+4.04%)
Mutual labels:  tvos, swiftpm
Hexapod Robot Simulator
A hexapod robot simulator built from first principles
Stars: ✭ 577 (-83.82%)
Mutual labels:  hacktoberfest, simulator
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (-93.94%)
Mutual labels:  hacktoberfest, tvos
SwiftSimctl
Swift client-server tool to call xcrun simctl from your simulator. Automate push notification testing!
Stars: ✭ 50 (-98.6%)
Mutual labels:  simulator, tvos
Deviice
Swift library to easily check the current device and some more info about it.
Stars: ✭ 51 (-98.57%)
Mutual labels:  device, device-family
Ics
iCalendar (ics) file generator for node.js
Stars: ✭ 324 (-90.91%)
Mutual labels:  hacktoberfest

GitHub license CocoaPods Compatible Carthage Compatible codecov CocoaPods Maintainability Platform

Branch Build Status Versions
master Build Status ≥ 2.0
Swift 4 - 4.2 Build Status ≥ 1.3 < 1.13
Swift 3 Build Status ≥ 1.0 < 1.3
Swift 2.3 Build Status < 1.0

DeviceKit is a value-type replacement of UIDevice.

Current version 4.5.2

See our detailed changelog for the latest features, improvements and bug fixes.

Features

  • Equatable
  • Device identification
  • Device family detection
  • Device group detection
  • Simulator detection
  • Battery state
  • Battery level
  • Various device metrics (e.g. screen size, screen ratio, PPI)
  • Low Power Mode detection
  • Guided Access Session detection
  • Screen brightness
  • Display Zoom detection
  • Detect available sensors (Touch ID, Face ID)
  • Detect available disk space
  • Apple Pencil support detection

Requirements

  • iOS 9.0+ (linking against iOS 9.3 required)
  • tvOS 9.0+ (linking against tvOS 9.2 required)
  • watchOS 2.0+

Installation

DeviceKit can be installed in various ways.

CocoaPods

Swift 5

pod 'DeviceKit', '~> 4.0'

iOS 8.0 support

pod 'DeviceKit', '3.2'

Swift 4.0 - Swift 4.2

pod 'DeviceKit', '~> 1.3'

Swift 3

pod 'DeviceKit', '~> 1.2.3'

Swift 2.3 (Unsupported)

pod 'DeviceKit', :git => 'https://github.com/devicekit/DeviceKit.git', :branch => 'swift-2.3-unsupported'

Swift Package Manager

Swift 5

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "4.0.0"),
    /// ...
]

iOS 8.0 support

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "3.2.0"),
    /// ...
]

Carthage

Swift 5

github "devicekit/DeviceKit" ~> 4.0

iOS 8.0 support

github "devicekit/DeviceKit" ~> 3.2

Swift 4.0 - Swift 4.2

github "devicekit/DeviceKit" ~> 1.3

Swift 3

github "devicekit/DeviceKit" ~> 1.2.3

Swift 2.3 (Unsupported)

github "devicekit/DeviceKit" "swift-2.3-unsupported"

Manually

To install it manually, drag the DeviceKit project into your app project in Xcode. Or add it as a git submodule by running:

$ git submodule add https://github.com/devicekit/DeviceKit.git

Usage

First make sure to import the framework:

import DeviceKit

Here are some usage examples. All devices are also available as simulators:

.iPhone6 => .simulator(.iPhone6)
.iPhone6s => .simulator(.iPhone6s)

You can try these examples in Playground.

Note:

To try DeviceKit in the playground, open the DeviceKit.xcworkspace and build DeviceKit.framework for any simulator first by selecting "DeviceKit" as your current scheme.

Get the Device You're Running On

let device = Device.current

print(device)     // prints, for example, "iPhone 6 Plus"

if device == .iPhone6Plus {
  // Do something
} else {
  // Do something else
}

Get the Device Family

let device = Device.current
if device.isPod {
  // iPods (real or simulator)
} else if device.isPhone {
  // iPhone (real or simulator)
} else if device.isPad {
  // iPad (real or simulator)
}

Check If Running on Simulator

let device = Device.current
if device.isSimulator {
  // Running on one of the simulators(iPod/iPhone/iPad)
  // Skip doing something irrelevant for Simulator
} 

Get the Simulator Device

let device = Device.current
switch device {
case .simulator(.iPhone6s): break // You're running on the iPhone 6s simulator
case .simulator(.iPadAir2): break // You're running on the iPad Air 2 simulator
default: break
}

Make Sure the Device Is Contained in a Preconfigured Group

let groupOfAllowedDevices: [Device] = [.iPhone6, .iPhone6Plus, .iPhone6s, .iPhone6sPlus, .simulator(.iPhone6), .simulator(.iPhone6Plus),.simulator(.iPhone6s),.simulator(.iPhone6sPlus).simulator(.iPhone8),.simulator(.iPhone8Plus),.simulator(.iPhoneX),.simulator(.iPhoneXS),.simulator(.iPhoneXSMax),.simulator(.iPhoneXR)]

let device = Device.current
 
if device.isOneOf(groupOfAllowedDevices) {
  // Do your action
}

Get the Current Battery State

Note:

To get the current battery state we need to set UIDevice.current.isBatteryMonitoringEnabled to true. To avoid any issues with your code, we read the current setting and reset it to what it was before when we're done.

if device.batteryState == .full || device.batteryState >= .charging(75) {
  print("Your battery is happy! 😊")
}

Get the Current Battery Level

if device.batteryLevel >= 50 {
  install_iOS()
} else {
  showError()
}

Get Low Power mode status

if device.batteryState.lowPowerMode {
  print("Low Power mode is enabled! 🔋")
} else {
  print("Low Power mode is disabled! 😊")
}

Check if a Guided Access session is currently active

if device.isGuidedAccessSessionActive {
  print("Guided Access session is currently active")
} else {
  print("No Guided Access session is currently active")
}

Get Screen Brightness

if device.screenBrightness > 50 {
  print("Take care of your eyes!")
}

Get Available Disk Space

if Device.volumeAvailableCapacityForOpportunisticUsage ?? 0 > Int64(1_000_000) {
  // download that nice-to-have huge file
}

if Device.volumeAvailableCapacityForImportantUsage ?? 0 > Int64(1_000) {
  // download that file you really need
}

Source of Information

All model identifiers are taken from the following website: https://www.theiphonewiki.com/wiki/Models or extracted from the simulator app bundled with Xcode.

Contributing

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.

Contributors

The complete list of people who contributed to this project is available here. DeviceKit wouldn't be what it is without you! Thank you very much! 🙏

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].