Swiftpack.co -  Clafou/DevicePpi as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Gets the PPI resolution of the iOS device
.package(url: "https://github.com/Clafou/DevicePpi.git", from: "1.2.12")


This library provides run-time detection of the PPI (pixels per inch) resolution of the main display of an iOS device.

It is useful for applications that display content in true size, for example:


As Apple releases new iOS devices this library needs to be continously updated to add new devices to its built-in list. It cannot guarantee an accurate PPI value for new devices that it does not yet know, but in such cases it provides a "best guess" PPI based on heuristics (UIUserInterfaceIdiom and UIScreen values) and an error code which you can treat as a non-fatal error.

let ppi: Double = {
    switch Ppi.get() {
    case .success(let ppi):
        return ppi
    case .unknown(let bestGuessPpi, let error):
        // A bestGuessPpi value is provided but may be incorrect
        // Treat as a non-fatal error -- e.g. log to your backend and/or display a message
        return bestGuessPpi


iOS 8 or later.


Swift Package Manager

Add a package dependency with this URL:



Alternatively, DevicePpi can be added to your project via CocoaPods.

pod 'DevicePpi'


The list of devices and their PPI is updated as new models are announced. Currently, the following devices are included:


  • iPhone 4S
  • iPhone 5
  • iPhone 5C
  • iPhone 5S
  • iPhone 6
  • iPhone 5 Plus
  • iPhone 6S
  • iPhone SE
  • iPhone 7
  • iPhone 7 Plus
  • iPhone 8
  • iPhone 8 Plus
  • iPhone X
  • iPhone XS
  • iPhone XS Max
  • iPhone XR
  • iPhone 11
  • iPhone 11 Pro
  • iPhone 11 Pro Max
  • iPhone SE (2nd generation)
  • iPhone 12 mini
  • iPhone 12
  • iPhone 12 Pro
  • iPhone 12 Pro Max

iPod touch

  • iPod touch (5th generation)
  • iPod touch (6th generation)
  • iPod touch (7th generation)


  • iPad 2
  • iPad mini
  • iPad (3rd generation)
  • iPad (4th generation)
  • iPad Air
  • iPad mini 2
  • iPad mini 3
  • iPad Air 2
  • iPad mini 4
  • iPad Pro (9.7″)
  • iPad Pro (12.9″)
  • iPad (5th generation)
  • iPad Pro (12.9″, 2nd generation)
  • iPad Pro (10.5″)
  • iPad (6th generation)
  • iPad Pro (11″)
  • iPad Pro (12.9″, 3rd generation)
  • iPad Air (3rd generation)
  • iPad mini (5th generation)
  • iPad (7th generation)
  • iPad Pro (11″, 2nd generation)
  • iPad Pro (12.9″, 4th generation)
  • iPad (8th generation)
  • iPad Air (4th generation)
  • iPad Pro (11″, 3rd generation)
  • iPad Pro (12.9″, 5th generation)

Devices that are too old to support iOS 8 or later (this library's deployment target) are not included. These are: iPhone (original model), iPhone 3GS, iPhone 4, and the first, 2nd and 3rd generation of iPod touch.


Sébastien Molines


DevicePpi is available under the MIT license. See the LICENSE file for more info.


Stars: 8
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API