iOS Development
Device Identification
iOS Coding
Apple Devices
Swift Programming

How to get device make and model on iOS?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On iOS, the device manufacturer is always Apple, but the exact hardware model is not exposed as a friendly marketing name by default. The practical solution is to read the machine identifier from the system, then map that identifier to a human-readable device name when you need something more precise than iPhone or iPad.

Start with UIDevice for Broad Device Info

UIDevice can tell you the product family and operating system version.

swift
1import UIKit
2
3let device = UIDevice.current
4print(device.model)
5print(device.systemName)
6print(device.systemVersion)

This is useful for general diagnostics, but device.model only returns broad values such as iPhone or iPad. It does not tell you the specific generation.

Read the Hardware Identifier with uname

For precise hardware identification, read the machine code from utsname.

swift
1import Foundation
2
3func hardwareIdentifier() -> String {
4    var systemInfo = utsname()
5    uname(&systemInfo)
6
7    return withUnsafePointer(to: &systemInfo.machine) {
8        $0.withMemoryRebound(to: CChar.self, capacity: 1) {
9            String(cString: $0)
10        }
11    }
12}
13
14print(hardwareIdentifier())

Typical values look like iPhone15,2 or iPad14,1. That identifier is what you map to a friendly model name.

Map Identifiers to Human-Readable Models

You can maintain a dictionary for known devices and fall back to the identifier when the mapping is missing.

swift
1import Foundation
2
3func modelName(for identifier: String) -> String {
4    let models: [String: String] = [
5        "iPhone15,2": "iPhone 14 Pro",
6        "iPhone15,3": "iPhone 14 Pro Max",
7        "iPad14,1": "iPad mini 6"
8    ]
9
10    return models[identifier] ?? identifier
11}
12
13let id = hardwareIdentifier()
14print(modelName(for: id))

Always keep the fallback. New devices appear regularly, and a missing mapping should not break the app.

Handle the Simulator Explicitly

The simulator reports host-oriented identifiers such as x86_64 or arm64, which are not real device models.

swift
1let id = hardwareIdentifier()
2if id == "x86_64" || id == "arm64" {
3    print("Running in Simulator")
4}

If your app shows device diagnostics to users or support teams, label simulator output clearly so it is not confused with actual hardware.

Keep the Logic Centralized

Wrap this behavior in a small helper type so the app has one place to update when new models appear.

swift
1import Foundation
2
3struct DeviceInfo {
4    let identifier: String
5    let name: String
6
7    static func current() -> DeviceInfo {
8        let id = hardwareIdentifier()
9        return DeviceInfo(identifier: id, name: modelName(for: id))
10    }
11}
12
13let current = DeviceInfo.current()
14print(current.name)

This prevents mapping tables from being duplicated across analytics, support, and diagnostics code.

Think About Privacy and Necessity

Precise model information can be useful for troubleshooting crash clusters or narrowing device-specific bugs, but it should not be collected casually. If broad family information is enough, UIDevice.current.model may be the better choice. Only collect exact identifiers when the product need is clear and documented.

Common Pitfalls

  • Expecting UIDevice.current.model to return a precise model generation such as iPhone 14 Pro.
  • Hardcoding a mapping table without a fallback for unknown future identifiers.
  • Forgetting simulator identifiers and mislabeling test runs as physical devices.
  • Duplicating model-mapping logic across the codebase instead of centralizing it.
  • Collecting detailed hardware identifiers when the product only needs broad device family data.

Summary

  • Use UIDevice for broad device and OS information.
  • Use uname to retrieve the machine identifier for exact hardware detection.
  • Map known identifiers to human-readable model names.
  • Keep a fallback because new devices will appear before your map is updated.
  • Centralize the logic and collect detailed model data only when it serves a real purpose.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.