Saturday, March 9, 2024
HomeiOS Developmentmacos - Methods to detect if an iOS app is working on...

macos – Methods to detect if an iOS app is working on an M1 mac?


Apple’s framework means that you can detect if the app is working as an iOS app on Mac through the use of the method information flag isiOSAppOnMac.

This flag is on the market from iOS 14.0 and due to this fact must be encapsulated to solely run on these variations. Observe that since model 14.0 can be the first model for iOS on Mac, you’ll be able to safely assume that it can’t be on a Mac if the model is prior 14.0.

// Swift
var isiOSAppOnMac = false
if #accessible(iOS 14.0, *) {
    isiOSAppOnMac = ProcessInfo.processInfo.isiOSAppOnMac
}
print("(isiOSAppOnMac ? "iOS app on Mac" : "not iOS on Mac")!")

Or in case you favor Goal-C:

// Goal-C
BOOL isiOSAppOnMac = false;
if (@accessible(iOS 14.0, *)) {
    isiOSAppOnMac = [NSProcessInfo processInfo].isiOSAppOnMac;
}
NSLog(@"%@", isiOSAppOnMac ? @"iOS app on Mac" : @"not iOS app on Mac");

Reference:
Apple: Working Your iOS Apps on macOS



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments