Git Product home page Git Product logo

thingy's Introduction

Thingy

A modern device detection and querying library.

Build Status GitHub license SPM Carthage compatible codecov

Features

  • Swift 5 support
  • Modern syntax
  • Documentation
  • Device detection
  • Device family detection
  • Device screens
  • Simulator detection
  • Simple querying

Requirements

Installation

Swift Packager Manager (SPM)

Use Xcode 11 to add Thingy as a package or update your Package.swift for manual setups:

import PackageDescription

let package = Package(
    name: "HelloWorld",
    dependencies: [
        .Package(url: "https://github.com/bojan/Thingy.git", "3.0.0")
    ]
)

Carthage

Add this to your Cartfile:

github "bojan/Thingy"

Manually

Add the repository as a submodule to your project.

git submodule add https://github.com/bojan/Thingy.git Vendor/Thingy

Open the newly created folder in Finder and drag Thingy.xcodeproj to your project.

In your project's settings, select your target and under General > Embedded Binaries, add the framework depending on the target OS (iOS, watchOS or tvOS).

Usage

Import the module where needed:

import Thingy

Device properties

Inspect the current device:

let myDevice = Device()

// Compare models or product families
if myDevice.family == .tv {
    print("This is an Apple TV device.")
}

if myDevice.model != .iPhoneXSMax {
    print("This is NOT an iPhone XS Max.")
}

// Pretty printed device properties

print(myDevice.family.marketingName) // e.g. iPad
print(myDevice.model.marketingName) // e.g. iPhone 7 Plus
print(myDevice.productLine.marketingName) // e.g. Air

Model comparison

let myDevice = Device()

do {
    let result = try myDevice.isEqual(to: Thingy.iPadPro12Inch)
}
catch {
    print("The devices are incompatible.")
}

do {
    let result = try myDevice.isOlder(than: Thingy.iPadPro10Inch)
}
catch {
    print("The devices are incompatible.")
}

Device size

let myDevice = Device()

if myDevice.display == .screen10_5Inch {
    print("This is the 10.5in iPad Pro.")
}

Contributions

All contributions and suggestions are welcome and very much appreciated.

Should you have a feature request or a problem that you may experience, feel free to open an issue.

If you are willing to contribute by adding a feature or squashing a bug or two, please submit a pull request.

Author

Bojan Dimovski

License

Thingy is available under the WTFPL license. Check the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.