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.
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.
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.
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.
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.
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.
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.modelto return a precise model generation such asiPhone 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
UIDevicefor broad device and OS information. - Use
unameto 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
- How to get enum from raw value in Swift?
- How to get hosting Activity from a view?
- How to get input value from a UIAlertController text field?
- How to get input value from a UIAlertController text field?
- How to get iOS device's WiFi IP address?
- How to get Latitude and Longitude of the mobile device in android?
- How to get mathemical PI constant in Swift
- How to get my IP address programmatically on iOS/macOS?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.