iPhone device name
iPhone settings
iOS tips
iPhone customization
Apple tricks

How do you get an iPhone's device name

Interview Questions practice on Codemia

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

Browse interview questions

Introduction

Getting an iPhone’s device name can mean two different things: finding it as a user in Settings, or reading it programmatically in an iOS app. Those two cases used to line up more closely, but modern iOS privacy rules make the developer story more restrictive than many older code samples suggest.

For Users: The Name Is in Settings

If you just want to see or change the device name on the phone itself, the path is straightforward:

  1. Open Settings.
  2. Go to General.
  3. Tap About.
  4. Read or edit Name.

That user-assigned name is what appears in places such as AirDrop, Finder, and some Bluetooth or tethering contexts.

Programmatically in an App

In UIKit or SwiftUI code, the usual API is UIDevice.current.name.

swift
1import UIKit
2
3let deviceName = UIDevice.current.name
4print(deviceName)

This is the canonical API for reading the device name from an app.

However, there is an important caveat on newer iOS versions: third-party apps may not always receive the user-assigned device name by default. Depending on platform privacy rules and entitlements, the returned value can be a more generic device label rather than the personalized name the user sees in Settings.

That means older advice of “just call UIDevice.current.name and you will get Mark's iPhone” is no longer universally reliable.

Distinguish Device Name from Model Name

Developers often confuse the user-visible device name with the hardware model.

These are different:

  • device name: a user-assigned label such as Ada's iPhone
  • model family: a generic label such as iPhone
  • exact hardware identifier: values such as iPhone15,3

If you need the hardware identifier for diagnostics, that requires a different API path.

swift
import UIKit

print(UIDevice.current.model)

UIDevice.current.model returns a generic product family, not the personalized device name.

Getting the Exact Hardware Identifier

For debugging or support tooling, developers sometimes want the low-level device identifier instead.

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

This may print something like iPhone15,3. That is useful for compatibility logic, but it is not the same as the device’s user-facing name.

Why Privacy Changed the Story

Apple tightened access to some device-identifying information to reduce fingerprinting and unnecessary exposure of user-customized data. As a result, a third-party app may not be entitled to read the full personalized device name in the way developers once expected.

So the practical advice is:

  • if you are a user, check Settings
  • if you are a developer, use UIDevice.current.name but do not assume it always returns the personalized name
  • if you need device model information, use model or hardware-identifier APIs instead

That distinction keeps the implementation honest.

A Safe Debugging Example

If you want to log the available device information without over-assuming what each field means, keep it explicit:

swift
1import UIKit
2
3func printDeviceInfo() {
4    print("Name: \(UIDevice.current.name)")
5    print("Model: \(UIDevice.current.model)")
6    print("System: \(UIDevice.current.systemName) \(UIDevice.current.systemVersion)")
7}
8
9printDeviceInfo()

This makes it obvious which values are user-facing labels and which are platform metadata.

Common Pitfalls

The biggest pitfall is assuming UIDevice.current.name always returns the exact user-assigned name on every iOS version and app context. That assumption is outdated.

Another issue is confusing the device name with the hardware model or hardware identifier. They solve different problems.

Developers also sometimes use device names for persistent identification. That is a weak design because names can change and privacy rules may limit access.

Finally, if the app only needs a friendly label for display, consider whether it really needs the system device name at all.

Summary

  • Users can find the device name in Settings under General and About.
  • Apps read the available device name with UIDevice.current.name.
  • Modern iOS privacy behavior means that third-party apps may not always receive the user-assigned personalized name.
  • 'UIDevice.current.model and the hardware identifier are different values for different purposes.'
  • Be explicit about whether you need a user-visible name, a model family, or a diagnostic hardware identifier.

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.