DeviceKit icon indicating copy to clipboard operation
DeviceKit copied to clipboard

iPad running iPhone app returns true to isiPhone

Open lewis-smith opened this issue 6 months ago • 3 comments

I'm not sure if this is a bug or intended, but thought I'd raise it for awareness.

I'm running on the 2026 beta 1, so this may resolve in time anyway.

/// Returns whether the device is an iPhone (real or simulator)
    public var isPhone: Bool {
      return (isOneOf(Device.allPhones)
              || isOneOf(Device.allSimulatorPhones)
              || (UIDevice.current.userInterfaceIdiom == .phone && isCurrent)) && !isPod
    }
(lldb) po Device.current
iPad Mini (A17 Pro)
(lldb) po Device.current.isPhone
true
(lldb) po isOneOf(Device.allPhones)
false
(lldb) po isOneOf(Device.allSimulatorPhones)
false
(lldb) po UIDevice.current.userInterfaceIdiom == .phone
true

lewis-smith avatar Jun 11 '25 13:06 lewis-smith

FWIW I think this should not be as intended. An iPad running in iPhone mode can't have a connected Watch session (which is how I found this) and probably has other differences too.

I'm happy to raise a PR either to change the documentation or remove the logic about the userInterfaceIdiom, but it would be good to get feedback from the project owners on if there is any philosophy on this.

lewis-smith avatar Jun 11 '25 13:06 lewis-smith

You are right. The UIDevice.current.userInterfaceIdiom == .phone check should be removed.

If you could open a PR that would be really great!

Zandor300 avatar Jul 01 '25 14:07 Zandor300

Hi there, can I work on this issue?

damien-rivet avatar Oct 02 '25 09:10 damien-rivet