如何判断 iOS APP运行在 Mac 环境(M1、M2芯片)

使用NSProcessInfo (NSProcessInfoPlatform) 判断

@interface NSProcessInfo (NSProcessInfoPlatform)

@property (readonly, getter=isMacCatalystApp) BOOL macCatalystApp API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0));
@property (readonly, getter=isiOSAppOnMac) BOOL iOSAppOnMac API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));

@end

if (@available(iOS 14.0, *)) {
  isiOSAppOnMac = [NSProcessInfo processInfo].isiOSAppOnMac;
  NSLog(@"%@", isiOSAppOnMac?@"运行在Mac环境" : @"没有运行在Mac环境");
}

你可能感兴趣的:(如何判断 iOS APP运行在 Mac 环境(M1、M2芯片))