可以通過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);}\
)