swift – The right way to establish which m1 Mac mannequin that the iOS app is working on?


I’m working my iOS app on M1 based mostly Macs with out modifying something (Catalyst and many others). I do know that once I run the app, the system treats it as whether it is being performed on iPad.

Once I run these traces of code

print("LOG: (ProcessInfo.processInfo.isiOSAppOnMac)")
print("LOG: (ProcessInfo.processInfo.operatingSystemVersionString)")
print("LOG: (UIDevice.present.mannequin)")
print("LOG: (UIDevice.present.systemVersion)")
var measurement = 0
sysctlbyname("hw.machine", nil, &measurement, nil, 0)
var machine = [CChar](repeatElement(0, depend: Int(measurement)))
sysctlbyname("hw.machine", &machine, &measurement, nil, 0)
print("LOG: (String(cString: machine))")

These get printed if I select My Mac (Designed for iPad) because the goal.

LOG: true
LOG: Model 15.7 (Construct 21G115)
LOG: iPad
LOG: 15.7
LOG: iPad8,6

These get printed if I select iPhone 14 Professional because the goal.

LOG: false
LOG: Model 16.0 (Construct 20A360)
LOG: iPhone
LOG: 16.0
LOG: arm64

I want to decide present gadget mannequin when the app is working on M1 macs to feed analytics precisely.

Is that this attainable? As per my investigation, I couldn’t discover something past that ProcessInfo.processInfo.isiOSAppOnMac flag, is that this right ?


Leave a Reply