UIDevice extensions that fill in the missing pieces.

Overview

UIDeviceComplete

UIDevice extensions that fill in the missing pieces.

Build Status Swift 5.0 CodeCov CocoaPods compatible Carthage compatible Swift Package Manager compatible License

Whats this library about?

UIDeviceComplete is an iOS library intended to be a collection of extensions to UIDevice that provides functionality that UIDevice currently lacks like determining which iOS device you have (i.e iPhone X, iPhone 8, iPhone SE, iPad Pro, iPhone 7 etc) or determining the screen size of the device in inches.

Features

  • Detect specific device like iPhone 7, iPhone SE or iPad Pro
  • Get screen size of device in inches
  • Get iOS Device family (iPod, iPhone or iPad)

Dont see a feature you need?

Feel free to open an Issue requesting the feature you want or send over a pull request!

Use

All of the extensions are called off of the dc variable which stands for ([UI]DeviceComplete) object that this library extends onto UIDevice that way native methods of UIDevice and methods of this library can easily be seen, also lowering the possibility of naming conflicts.

Getting common device name

UIDevice.current.dc.commonDeviceName // iPad Pro (12.9 inch, Wi-Fi+LTE)

Detecting iOS Device models

let device = UIDevice.current.dc.deviceModel

switch device {
    case .iPhoneX:
        print("So hows that iPhone X notch thing working out? Right...")
    case .iPhone6Plus, .iPhone7Plus:
        print("Lots of screen realestate eh?")
    case .iPhoneSE, .iPhone5, iPhone5S:
        print("Less iPhone is more iPhone...")
    case .iPadPro:
        print("Why?")
    default:
        print("Not sure what this is...")
}

Detecting iOS Device Screen Size (Inches)

Screen size can be be queried with the following computed property returning a simple Double that represents the screen size in inches:

= 5.5 { print("Plus is always a plus") } else { print("Chances are this is an iPad or an iPhone (Texas Edition).") } ">
let screenSize: Double = UIDevice.current.dc.screenSize.sizeInches

if screenSize <= 4.0 {
    print("Modest screen size; not so modest price tag")
} else if screenSize >= 5.5 {
    print("Plus is always a plus")
} else {
    print("Chances are this is an iPad or an iPhone (Texas Edition).")
}

Detecting iOS Device Family

If the type of device family is all you are after i.e iPhone or iPad and the specific model is not important then DeviceFamily might be what you need.

let deviceFamily = UIDevice.current.dc.deviceFamily

switch deviceFamily {
    case .iPhone:
        print("...phone home?")
    case .iPad:
        print("when it comes to screen size; more is more")
    case .iPod:
        print("Why not?")
    default:
        print("No family...")
}

Installation

Carthage

If you use Carthage to manage your dependencies, simply add UIDeviceComplete to your Cartfile:

github "Nirma/UIDeviceComplete"

If you use Carthage to build your dependencies, make sure you have added UIDeviceComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIDeviceComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add this line to your Podfile:

use_frameworks!
pod 'UIDeviceComplete'

Contributing to this project

Contributions are highly welcome

If there is something you wish to fix about the project, or wish to add any other kind of enhancements, propose to add to the project. Please feel free to send over a pull request or open an issue for this project.

License

UIDeviceComplete is released under the MIT license. See LICENSE for details.

Comments
  • Compiling it by integrating it directly as source code not referencing using pod creates a compilation error!

    Compiling it by integrating it directly as source code not referencing using pod creates a compilation error!

    Hi,

    This is a great libary, I am not referencing it as a pod but integrating it as a Library but for some reason its creating a compilation issue for the first line in this function saying :

    Ambiguous use of 'dc'

        func ipadSize1024() -> Double {
            let deviceModel = UIDevice().dc.deviceModel // the error is on this line
            switch deviceModel {
            case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadMini5: return 7.9
            case .iPadPro10_5Inch: return 10.5
            case .iPadSevenGen: return 10.2
            default: return 9.7
            }
        }
    

    Is there any way of fixing this and yes I would like to use it directly not as a pod please :)

    Thank you,

    Wael

    opened by waelsaad 6
  • Add spring 2021 iPads

    Add spring 2021 iPads

    Not ready,

    iPad 13,4, 13,5, 13,8, 13,9 is WiFi iPad 13,6, 13,7, 13,10, 13,11 is Cellular

    But I think its too early to tell which is (probably) the higher RAM version

    opened by vincentneo 5
  • SPM Error: Cannot convert value of type 'Int' to expected element type 'SwiftVersion'

    SPM Error: Cannot convert value of type 'Int' to expected element type 'SwiftVersion'

    We love your library, very well thought out and written, but it has a problem with Swift Package Manager, you can reproduce it with Xcode 11.3. Can you have a look?

    Cannot convert value of type 'Int' to expected element type 'SwiftVersion'

    opened by alexruperez 5
  • XS Family Not Identifying

    XS Family Not Identifying

    using:

    Xcode 11.1GM (11A1027)
    iOS 13.1
    Simulator XS
    

    & code:

    switch device {
                case .iPhoneXR, .iPhone11:
                    print("test:sized for found:", device)
                    print("test:adjustments for: XR, 11")
                    break
                case .iPhone11Pro, .iPhoneX, .iPhoneXS:
                    print("test:sized for found:", device)
                    print("test:adjustments for: 11Pro, X, XS")
                    break
                default:
                    print("test:sized for default:", device)
                    break
     }
    

    the output for the XS: test:sized for default: unknown Same for the XS Max. other devices seem to be ok. Is this a bug?

    Ty

    opened by jminutaglio 5
  • Fix Xcode 14 System.name crashing on app launch

    Fix Xcode 14 System.name crashing on app launch

    In Xcode 14, cStrings need to be null-terminated. I updated this variable to work with null-terminated strings but not add extra spaces at the end.

    Closes #78

    opened by dmace2 4
  • Xcode 12 fixes

    Xcode 12 fixes

    @vincentneo This pull request was just sent over #51

    Maybe we should check everything and make sure there are no other existing issues for XCode 12.

    If there are no further issues then lets put out a new release!

    opened by Nirma 4
  • iPhone SE 2nd Gen not identifying

    iPhone SE 2nd Gen not identifying

    Xcode Version 11.4.1 (11E503a)
    iOS 13.1.4
    Simulator iPhone SE 2nd Gen
    
    

    & code:

    let device = UIDevice.current.dc.deviceModel

    Returns "unknown"

    opened by jminutaglio 4
  • Warnings when running in Xcode 12

    Warnings when running in Xcode 12

    The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99.
    
    opened by kevinrenskers 3
  • Use Github Actions instead of Travis CI

    Use Github Actions instead of Travis CI

    Travis CI now appears to be a paid service for iOS builds? I've switch to GitHub Actions for my personal projects, and thought if you would want to switch too for this project.

    opened by vincentneo 2
  • Impossible to add to objc project by default: SWIFT_VERSION not specified

    Impossible to add to objc project by default: SWIFT_VERSION not specified

    ❯ bundle exec pod install
    Analyzing dependencies
    Downloading dependencies
    Installing UIDeviceComplete (2.7.3)
    [!] Unable to determine Swift version for the following pods:
    
    - `UIDeviceComplete-library` does not specify a Swift version and none of the targets (`MyTarget`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
    

    Setting SWIFT_VERSION in my project fixes this. But specifying Swift version in the podspec would be more correct.

    opened by kambala-decapitator 2
  • v2.7.5 isn't available in cocoapods repo

    v2.7.5 isn't available in cocoapods repo

    My private pod depends on your library: s.dependency 'UIDeviceComplete', '~> 2.7'

    When I install pods, only v2.7.3 is fetched:

    ❯ bundle exec pod install --repo-update
    Updating local specs repositories
    Analyzing dependencies
    Downloading dependencies
    Installing UIDeviceComplete (2.7.3)
    ...
    

    Temporary workaround is to point to the repo directly in Podfile:

    pod 'UIDeviceComplete', :git => 'https://github.com/Nirma/UIDeviceComplete.git', :commit => '7fa25cf6c648a0c5fa4bb8c182fb91c7ded3e861'
    
    opened by kambala-decapitator 2
  • iPhone ProMax & Mini Screen sizes

    iPhone ProMax & Mini Screen sizes

    Regarding:

    // MARK: - Detecting Screen size in Inches
    extension Screen {
        public var sizeInches: Double? {
            switch (height, scale) {
            case (480, _): return 3.5
            case (568, _): return 4.0
            case (667, 3.0), (736, _): return 5.5
            case (667, 1.0), (667, 2.0): return 4.7
            case (812, 3.0): return 5.8
            case (896, 2.0): return 6.1
            case (896, 3.0): return 6.5
            case (1024, _): return ipadSize1024()
            case (1080, _): return 10.2
            case (1112, _): return 10.5
            case (1133, _): return 8.3
            case (1180, _): return 10.9
            case (1194, _): return 11.0
            case (1366, _): return 12.9
            default: return nil
            }
        }
    
        func ipadSize1024() -> Double {
            let deviceModel = UIDevice().dc.deviceModel
            switch deviceModel {
            case .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadMini5: return 7.9
            case .iPadPro10_5Inch: return 10.5
            default: return 9.7
            }
        }
    }
    
    

    iPhone 12 ProMax & 13 ProMax have a 6.7 iPhone 12 mini & 13 mini have a 5.4

    opened by jminutaglio 0
  • Display Zoom causes sizeInches to be nil (with iPhone 12 mini)

    Display Zoom causes sizeInches to be nil (with iPhone 12 mini)

    When running on an iPhone 12 mini

    UIDevice.current.dc.screenSize.height = 812 UIDevice.current.dc.screenSize.scale = 3 UIDevice.current.dc.screenSize.sizeInches = 5.8

    But with Display Zoom turned on I get these values:

    UIDevice.current.dc.screenSize.height = 693 UIDevice.current.dc.screenSize.scale = 3

    And since there is no match, sizeInches is nil.

    opened by kevinrenskers 1
Releases(2.9.0)
  • 2.9.0(Sep 8, 2022)

  • 2.8.2(Aug 17, 2022)

    This release contains a minor fix for Xcode 14 and the newly enforced rule around null terminated strings.

    Special thanks to @dmace2 for putting this together!

    Source code(tar.gz)
    Source code(zip)
  • 2.8.1(Mar 19, 2022)

    This release fixes incorrect detection of iPad Air (5th Generation) devices, as well as correcting of misspellings. Tests for the new devices are also added.

    This update was put together by @jminutaglio and @vincentneo.

    Source code(tar.gz)
    Source code(zip)
  • 2.8.0(Mar 11, 2022)

    Summary

    This release adds support for detecting iPhone SE Gen 3 and iPad Air Gen 5.

    This update was put together by @jminutaglio and @vincentneo

    Source code(tar.gz)
    Source code(zip)
  • 2.7.6(May 17, 2021)

    This release adds support for devices announced in the Spring 2021 event:

    • iPad Pro 11 inch (3rd Generation)
    • iPad Pro 12.9 inch (5th Generation)
    Source code(tar.gz)
    Source code(zip)
  • 2.7.5(Oct 18, 2020)

    This release adds support for:

    • iPad
      • iPad Air (4th generation)
      • iPad (8th generation)
    • iPhone
      • iPhone 12 mini
      • iPhone 12
      • iPhone 12 Pro
      • iPhone 12 Pro Max

    Do note that, the minimum supported iOS version is now iOS 11, instead of iOS 8.

    Source code(tar.gz)
    Source code(zip)
  • 2.7.3(Jul 19, 2020)

    This release should solve your problems while you work on your shiny new iOS 14 apps, using Xcode 12 beta. In addition, Mac Catalyst support has also been disabled, with no practical usability in its current form, as all fields would return unknown or invalid data.

    Source code(tar.gz)
    Source code(zip)
  • 2.7.2(May 24, 2020)

  • 2.7.1(May 7, 2020)

    This release adds detection support for iPhone SE (2nd Generation), iPad Pro 11 inch (2nd Generation) and iPad Pro 12.9 inch (4th Generation).

    Source code(tar.gz)
    Source code(zip)
  • 2.7.0(Jan 23, 2020)

    This release includes improved simulator detection support, as well as proper support of this library via Swift Package Manager for Xcode 11.

    Thanks to @pahnev for helping out regarding SPM!

    Source code(tar.gz)
    Source code(zip)
  • 2.6.5(Sep 26, 2019)

    In this release, the iPad 10.2 inch models are finally detectable, except you can't get them just yet.

    Also, iPhone 11s will now register as having a notch, as that's what they are.

    Source code(tar.gz)
    Source code(zip)
  • 2.6.0(Sep 21, 2019)

    The iPhone 11s are now detected with this new release. As the 10.2 inch iPad's identifiers are still yet to be known, it will added in the next minor release.

    Enjoy detecting your new iPhones!

    Source code(tar.gz)
    Source code(zip)
  • 2.5.0(Jun 15, 2019)

  • 2.4.0(Jun 5, 2019)

  • 2.3.0(Apr 9, 2019)

  • 2.2.0(Sep 25, 2018)

    This release contains new info for the Fall 2018 devices that were released.

    Thanks for putting this together! @tsukisa

    • Added iPhone XR, iPhone XS and iPhone XS Max to iPhone model
    • Update Swift version to 4.2
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jan 27, 2018)

    This release includes support for detecting additional iPad models and returning the screen size of an iPhone X in inches.

    Thanks @vincentneo for these changes, awesome work!

    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Jan 21, 2018)

  • 2.0.1(Sep 27, 2017)

  • 2.0.0(Sep 20, 2017)

    This release contains only project settings changes for supporting Swift 4. There are no code changes other than that but from this release forward only Swift 4 will be supported.

    Enjoy!

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Sep 5, 2017)

    This release improves the device description when calling UIdevice.current.dc.commonDeviceName.

    Now detailed device info is given, for example if UIdevice.current.dc.commonDeviceName is called on an iPhone SE the description String returned will now be: iPhone SE (GSM+CDMA) providing more specific info about the device.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Aug 9, 2017)

  • 1.0.0(Aug 7, 2017)

Owner
Nicholas Maccharoli
Day job is iOS / Swift dev mostly, Python and Golang enthusiast. Coding with love since 2007.
Nicholas Maccharoli
UIDevice extensions that fill in the missing pieces.

UIDeviceComplete UIDevice extensions that fill in the missing pieces. Whats this library about? UIDeviceComplete is an iOS library intended to be a co

Nicholas Maccharoli 408 Dec 11, 2022
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces

ADPuzzleAnimation Whats inside Custom animation for UIView inspired by Fabric - Answers animation. Easy to use To create your first animation you need

Anton 126 Dec 25, 2022
DeviceKit is a value-type replacement of UIDevice.

DeviceKit is a value-type replacement of UIDevice.

DeviceKit 3.9k Jan 6, 2023
This component implements transition animation to crumble view-controller into tiny pieces.

StarWars Animation This component implements transition animation to crumble view-controller into tiny pieces. Check this project on dribbble. Also, r

Yalantis 3.7k Dec 29, 2022
DeviceKit is a value-type replacement of UIDevice.

Branch Build Status Versions master ≥ 2.0 Swift 4 - 4.2 ≥ 1.3 < 1.13 Swift 3 ≥ 1.0 < 1.3 Swift 2.3 < 1.0 DeviceKit is a value-type replacement of UIDe

DeviceKit 3.9k Dec 30, 2022
An easy to use UI component to help display a signal bar with an added customizable fill animation

TZSignalStrengthView for iOS Introduction TZSignalStrengthView is an easy to use UI component to help display a signal bar with an added customizable

TrianglZ LLC 22 May 14, 2022
VKPinCodeView is simple and elegant UI component for input PIN. You can easily customise appearance and get auto fill (OTP) iOS 12 feature right from the box.

Features Variable PIN length Underline, border and custom styles The error status with / without shake animation Resetting the error status manually,

Vladimir Kokhanevich 95 Nov 24, 2022
UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.

THLabel THLabel is a subclass of UILabel, which additionally allows shadow blur, inner shadow, stroke text and fill gradient. Requirements iOS 4.0 or

Tobias Hagemann 654 Nov 27, 2022
SSLineChart provides you with the additional functionality of gradient color fill which cannot be found in any library specially Watchkit Libraries.

SSLineChart SSLineChart draws a UIImage of a chart with given values and provide additional functionality of gradient color fill. Setup Instructions C

Simform Solutions 42 Aug 23, 2022
RadioGroup - The missing iOS radio buttons group.

RadioGroup The missing iOS radio buttons group. Usage let radioGroup = RadioGroup(titles: ["First Option Title", "Another Option Title", "Last"]) radi

Yonat Sharon 188 Dec 20, 2022
🎛 QGrid: The missing SwiftUI collection view.

[NOTE] If you'd like to see QGrid in action, check out this demo of QDesigner (see video below). Install QDesigner: https://apps.apple.com/us/app/qdes

Q Mobile 1.5k Dec 23, 2022
The ISO 8601 period/duration types missing in Foundation

PeriodDuration This library introduces a close equivalent to Java's PeriodDuration, motivated by the lack of support for this standard in Foundation.

David Roman 19 Jun 22, 2022
Makes it easier to support older versions of iOS by fixing things and adding missing methods

PSTModernizer PSTModernizer carefully applies patches to UIKit and related Apple frameworks to fix known radars with the least impact. The current set

PSPDFKit Labs 217 Aug 9, 2022
The missing Apple Weather App for Mac.

BetterWeather The missing Weather App for your Mac and iPad. Installation for mac. Download the notarized, universal binary from here Click the curren

Aayush 21 Jul 31, 2022
A tool for finding missing and unused NSLocalizedStrings

nslocalizer This is a command line tool that is used for discovering missing and unused localization strings in Xcode projects. Contributing and Code

Samantha Demi 155 Sep 17, 2022
The missing light persistence layer for Swift

If you're planning on using Swift 4 in the near future, please consider using the new Codable protocols which provide the same functionality as Pantry

Nick O'Neill 842 Sep 11, 2022
A collection of missing SwiftUI components

SwiftUIKit A collection of components that will simplify and accelerate your iOS development. Components CurrencyTextField AdaptToKeyboard (not needed

youjinp 239 Nov 18, 2022
The Git interface you've been missing all your life has finally arrived.

GitUp Work quickly, safely, and without headaches. The Git interface you've been missing all your life has finally arrived. Git recently celebrated it

GitUp 10.6k Jan 4, 2023
Simple UIButton subclass with additional state change animations (e.g. backgroundColor) and missing features

SimpleButton UIButton subclass with animated, state-aware attributes. Easy to subclass and configure! Full API docs Usage Just create your own SimpleB

Andreas Tinoco Lobo 169 Sep 14, 2022
Eazy is the missing piece in your SwiftUI and UIKit application.

Eazy is the missing piece in your SwiftUI and UIKit application. It aims at harmonizing how your views communicate with the model and vice versa in a clear and consistent way. Eazy can be used on any Apple platform.

Johan Thorell 7 Sep 18, 2022