可以通过NSProcessInfo的属性判断是否是macCatalyst或者arm的mac运行iOSapp
@interfaceNSProcessInfo(NSProcessInfoPlatform)
@property(readonly,getter=isMacCatalystApp)BOOLmacCatalystAppAPI_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0));
@property(readonly,getter=isiOSAppOnMac)BOOLiOSAppOnMacAPI_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
@end
宏定义如下
///是否是手机app在电脑上运行
#define IsiOSAppOnMac (\
{\
BOOL IsiOSAppOnMac = NO;\
if (@available(iOS14.0, *)) {\
IsiOSAppOnMac = [NSProcessInfo processInfo].isiOSAppOnMac;\
}\
(IsiOSAppOnMac);}\
)