iOS逆向—-Mac m1芯片检测
由于Apple更新了m1芯片的Mac,导致iOS程序可以在Mac上直接运行,因此需要判断一下我们的App是跑在了Mac上还是跑在了iPhone上。
因为m1芯片的Mac上只能运行iOS14及以上系统(当然未来说不定有大能会移植低版本iOS系统到Mac上),因此我们只需要判断iOS14之后的系统即可:
var isMac = false
if #available(iOS 14.0, *) {
isMac = ProcessInfo.processInfo.isiOSAppOnMac
}
print(“\(isMac ? “App on Mac” : “App not on Mac”)!”)
当然,还可以直接获取设备型号:
#import <sys/utsname.h>
+ (void)deviceModel {
struct utsname systemInfo;
uname(&systemInfo);
NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSLog(@”%@”, deviceModel);
}
“MacBookAir10,1”: “MacBook Air (M1, 2020)”,
“MacBookPro17,1”: “MacBook Pro (13-inch, M1, 2020)”,
“Macmini9,1”: “Mac mini (M1, 2020)”,