{"id":15029552,"url":"https://github.com/ekhoo/device","last_synced_at":"2025-05-14T01:03:14.970Z","repository":{"id":44499458,"uuid":"45272005","full_name":"Ekhoo/Device","owner":"Ekhoo","description":"Light weight tool for detecting the current device and screen size written in swift.","archived":false,"fork":false,"pushed_at":"2024-10-20T13:14:09.000Z","size":2162,"stargazers_count":1715,"open_issues_count":14,"forks_count":205,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-02T17:44:25.849Z","etag":null,"topics":["carthage","cocoapods","ios","ipad","iphone","macos","osx","swift","swift-3","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ekhoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-30T19:21:55.000Z","updated_at":"2025-03-24T12:59:52.000Z","dependencies_parsed_at":"2023-02-19T07:31:04.766Z","dependency_job_id":"78f97923-c4a9-4d2a-b6aa-b19d90c67378","html_url":"https://github.com/Ekhoo/Device","commit_stats":{"total_commits":173,"total_committers":36,"mean_commits":4.805555555555555,"dds":0.6416184971098267,"last_synced_commit":"9cc8be6ea9456260e6255ba176c47db894fd9814"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ekhoo%2FDevice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ekhoo%2FDevice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ekhoo%2FDevice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ekhoo%2FDevice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ekhoo","download_url":"https://codeload.github.com/Ekhoo/Device/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248201983,"owners_count":21064239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocoapods","ios","ipad","iphone","macos","osx","swift","swift-3","xcode"],"created_at":"2024-09-24T20:11:00.574Z","updated_at":"2025-04-10T10:47:39.000Z","avatar_url":"https://github.com/Ekhoo.png","language":"Swift","readme":"![Device](https://github.com/Ekhoo/Device/blob/master/Source/Asset/device.png)\n\n[![Version](https://img.shields.io/cocoapods/v/Device.svg?style=flat)](http://cocoapods.org/pods/Device)\n[![License](https://img.shields.io/cocoapods/l/Device.svg?style=flat)](http://cocoapods.org/pods/Device)\n[![Platform](https://img.shields.io/cocoapods/p/Device.svg?style=flat)](http://cocoapods.org/pods/Device)\n![](https://img.shields.io/badge/Supported-iOS8%20%7C%20OSX%2010.10-4BC51D.svg?style=flat-square)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)\n![](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)\n[![Twitter](https://img.shields.io/badge/Twitter-@LucasEkhoo-blue.svg?style=flat)](http://twitter.com/LucasEkhoo)\n\nDevice detect the current  device model and screen size.\n\n# Installation\n## CocoaPods\nDevice is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"Device\", '~\u003e 3.7.0'\n```\n\n## Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Device into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"Ekhoo/Device\" ~\u003e 3.7.0\n```\n\nRun `carthage update` to build the framework and drag the built `Device.framework` into your Xcode project.\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. \n\nOnce you have your Swift package set up, adding Device as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/Ekhoo/Device.git\", from: \"3.7.0\")\n]\n```\n\n# Usage\n## iOS\n### Device version\n```swift\nfunc myFunc() {\n        /*** Display the device version ***/\n        switch Device.version() {\n            /*** iPhone ***/\n            case .iPhone4:       print(\"It's an iPhone 4\")\n            case .iPhone4S:      print(\"It's an iPhone 4S\")\n            case .iPhone5:       print(\"It's an iPhone 5\")\n            case .iPhone5C:      print(\"It's an iPhone 5C\")\n            case .iPhone5S:      print(\"It's an iPhone 5S\")\n            case .iPhone6:       print(\"It's an iPhone 6\")\n            case .iPhone6S:      print(\"It's an iPhone 6S\")\n            case .iPhone6Plus:   print(\"It's an iPhone 6 Plus\")\n            case .iPhone6SPlus:  print(\"It's an iPhone 6 S Plus\")\n            case .iPhoneSE:      print(\"It's an iPhone SE\")\n            case .iPhone7:       print(\"It's an iPhone 7\")\n            case .iPhone7Plus:   print(\"It's an iPhone 7 Plus\")\n            case .iPhone8:       print(\"It's an iPhone 8\")\n            case .iPhone8Plus:   print(\"It's an iPhone 8 Plus\")\n            case .iPhoneX:       print(\"It's an iPhone X\")\n            case .iPhoneXS:      print(\"It's an iPhone Xs\")\n            case .iPhoneXS_Max:  print(\"It's an iPhone Xs Max\")\n            case .iPhoneXR:      print(\"It's an iPhone Xr\")\n\n            /*** iPad ***/\n            case .iPad1:           print(\"It's an iPad 1\")\n            case .iPad2:           print(\"It's an iPad 2\")\n            case .iPad3:           print(\"It's an iPad 3\")\n            case .iPad4:           print(\"It's an iPad 4\")\n            case .iPad5:           print(\"It's an iPad 5\")\n            case .iPad6:           print(\"It's an iPad 6\")\n            case .iPadAir:         print(\"It's an iPad Air\")\n            case .iPadAir2:        print(\"It's an iPad Air 2\")\n            case .iPadMini:        print(\"It's an iPad Mini\")\n            case .iPadMini2:       print(\"It's an iPad Mini 2\")\n            case .iPadMini3:       print(\"It's an iPad Mini 3\")\n            case .iPadMini4:       print(\"It's an iPad Mini 4\")\n            case .iPadPro9_7Inch:  print(\"It's an iPad Pro 9.7 Inch\")\n            case .iPadPro10_5Inch: print(\"It's an iPad Pro 10.5 Inch\")\n            case .iPadPro12_9Inch: print(\"It's an iPad Pro 12.9 Inch\")\n\n            /*** iPod ***/\n            case .iPodTouch1Gen: print(\"It's a iPod touch generation 1\")\n            case .iPodTouch2Gen: print(\"It's a iPod touch generation 2\")\n            case .iPodTouch3Gen: print(\"It's a iPod touch generation 3\")\n            case .iPodTouch4Gen: print(\"It's a iPod touch generation 4\")\n            case .iPodTouch5Gen: print(\"It's a iPod touch generation 5\")\n            case .iPodTouch6Gen: print(\"It's a iPod touch generation 6\")\n\n            /*** Simulator ***/\n            case .Simulator:    print(\"It's a Simulator\")\n\n            /*** Unknown ***/\n            default:            print(\"It's an unknown device\")\n        }\n    }\n```\n\n## Device screen size\n```swift\nfunc myFunc() {\n        /*** Display the device screen size ***/\n        switch Device.size() {\n            case .screen3_5Inch:  print(\"It's a 3.5 inch screen\")\n            case .screen4Inch:    print(\"It's a 4 inch screen\")\n            case .screen4_7Inch:  print(\"It's a 4.7 inch screen\")\n            case .screen5_5Inch:  print(\"It's a 5.5 inch screen\")\n            case .screen5_8Inch:  print(\"It's a 5.8 inch screen\")\n            case .screen6_1Inch:  print(\"It's a 6.1 inch screen\")\n            case .screen6_5Inch:  print(\"It's a 6.8 inch screen\")\n            case .screen7_9Inch:  print(\"It's a 7.9 inch screen\")\n            case .screen9_7Inch:  print(\"It's a 9.7 inch screen\")\n            case .screen10_5Inch: print(\"It's a 10.5 inch screen\")\n            case .screen12_9Inch: print(\"It's a 12.9 inch screen\")\n            default:              print(\"Unknown size\")\n        }\n}\n```\n\n## Device type\n```swift\nfunc myFunc() {\n        /*** Display the device type ***/\n        switch Device.type() {\n            case .iPod:         print(\"It's an iPod\")\n            case .iPhone:       print(\"It's an iPhone\")\n            case .iPad:         print(\"It's an iPad\")\n            case .Simulator:    print(\"It's a Simulated device\")\n            default:            print(\"Unknown device type\")\n        }\n}\n\n```\n\nor \n\n```swift\nfunc myFunc() {\n        /*** Display the device type ***/\n        if (Device.isPad()){\n            print(\"It's an iPad\")\n        }\n        else if (Device.isPhone()){\n            print(\"It's an iPhone\")\n        }\n        else if (Device.isPod()){\n            print(\"It's an iPod\")\n        }\n        else if (Device.isSimulator()){\n            print(\"It's a Simulated device\")\n        }\n}\n\n```\n\n## Mac\n### Mac version\n```swift\nfunc myFunc() {\n        /*** Display the mac version ***/\n        switch Device.type() {\n            case .iMac:         print(\"It's an iMac\")\n            case .macBook:      print(\"It's a MacBook\")\n            case .macBookAir:   print(\"It's a MacBook Air\")\n            case .macBookPro:   print(\"It's a MacBook Pro\")\n            default:            print(\"Unknown device type\")\n        }\n    }\n```\n\n## Mac screen size\n```swift\nfunc myFunc() {\n        /*** Display the mac screen size ***/\n        switch Device.size() {\n            case .screen11Inch:     print(\"It's a 11 inch screen\")\n            case .screen12Inch:     print(\"It's a 12 inch screen\")\n            case .screen13Inch:     print(\"It's a 13 inch screen\")\n            case .screen15Inch:     print(\"It's a 15 inch screen\")\n            case .screen17Inch:     print(\"It's a 17 inch screen\")\n            case .screen21_5Inch:   print(\"It's a 21.5 inch screen\")\n            case .screen27Inch:     print(\"It's a 27 inch screen\")\n            default:                print(\"Unknown size\")\n        }\n}\n```\n\n## Helpers\n```swift\nfunc myFunc() {\n        /*** Helpers ***/\n        if Device.size() == Size.screen4Inch {\n            print(\"It's a 4 inch screen\")\n        }\n\n        if Device.size() \u003e Size.screen4_7Inch {\n            print(\"Your device screen is larger than 4.7 inch\")\n        }\n\n        if Device.size() \u003c Size.screen4_7Inch {\n            print(\"Your device screen is smaller than 4.7 inch\")\n        }\n\n        if Device.size() == Size.screen27Inch {\n            print(\"It's a 27 inch screen\")\n        }\n        \n        if Device.size() \u003e Size.screen15Inch {\n            print(\"Your mac screen is larger than 15 inch\")\n        }\n        \n        if Device.size() \u003c Size.screen15Inch {\n            print(\"Your mac screen is smaller than 15 inch\")\n        }\n\n        if Device.isRetina() {\n            print(\"It's a retina display\")\n        }\n        \n}\n```\n\n# Video Tutorial by Alex Nagy (@rebeloper):\n- https://www.youtube.com/watch?v=cTZcOaGgD-E\n\n[![YouTube](https://user-images.githubusercontent.com/2488011/53433240-ba33a780-39fc-11e9-820b-9e1017adce18.png)](https://www.youtube.com/watch?v=cTZcOaGgD-E)\n\n## Privacy\nDevice does not collect any data. We provide this notice to help you fill out [App Privacy Details](https://developer.apple.com/app-store/app-privacy-details/). Since Device is not using any of privacy required reason API as listed by Apple [here](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api) xcprivacy manifest is not needed for this SDK.\n\n# Author\nLucas Ortis:\n- me@lucas-ortis.com\n- [@LucasEkhoo](https://twitter.com/LucasEkhoo)\n- [LinkedIn](https://fr.linkedin.com/in/lucasortis)\n\n# Maintenance\nPran Kishore:\n- kishorepran@gmail.com\n- [LinkedIn](https://www.linkedin.com/in/pran-kishore/)\n\n# License\n\nDevice is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekhoo%2Fdevice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekhoo%2Fdevice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekhoo%2Fdevice/lists"}