首先注明:需要在越狱状态下
首先使用MonkeyDev建立一个Command-Line
的程序
然后添加libMobileGestalt.dylib

然后在monkeydev.entitlements
中添加权限com.apple.coretelephony.Identity.get

main.c
如图
#include <stdio.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
OBJC_EXTERN CFStringRef MGCopyAnswer(CFStringRef key) WEAK_IMPORT_ATTRIBUTE;
int main (int argc, const char * argv[])
{
CFStringRef result = MGCopyAnswer(CFSTR("InternationalMobileEquipmentIdentity"));
NSString *IMEI = (__bridge NSString *)result;
NSLog(@"%@",IMEI);
// insert code here...
printf("Hello, World!\n");
return 0;
}
Build
到手机上进行测试,成功获取到

打开手机查看是否和本机一致

完成!
Demo
网友评论