http://www.iloss.me/2011/11/03/%E8%8E%B7%E5%8F%96ios%E5%AE%89%E8%A3%85%E7%9A%84%E8%BD%AF%E4%BB%B6/
http://www.cnblogs.com/visen-0/archive/2011/08/22/2148847.html
http://www.iloss.me/2011/10/27/%E6%A3%80%E6%B5%8Biphone%E8%AE%BE%E5%A4%87%E6%98%AF%E5%90%A6%E8%B6%8A%E7%8B%B1/
首先,必須確定iPhone是越獄的,並且你的下面代碼啟動並執行目錄為/Applications/.
NSFileManager* fileManager = [NSFileManager defaultManager];
NSMutableArray* applist = [NSMutableArray arrayWithCapacity:10];
for (NSString *path in [fileManager directoryContentsAtPath:@"/var/mobile/Applications"]) {
for (NSString *subpath in [fileManager directoryContentsAtPath:
[NSString stringWithFormat:@"/var/mobile/Applications/%@", path]]) {
if ([subpath hasSuffix:@".app"])
{
NSString* infoplist = [NSString stringWithFormat:@"/var/mobile/Applications/%@/%@/Info.plist", path, subpath];
NSLog(@"sdfsadfa0%@",infoplist);
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:infoplist];
NSLog(@"sdfsadfa1%@",dict);
[applist addObject:[dict objectForKey:@"CFBundleDisplayName"]];
}
}
如何查看是否越獄?最簡單的方法就是查看你裝置上是否多了越獄的目錄
detectDevice.h
@interface UIDevice (Helper)
- (BOOL)isJailbroken;
@end
detectDevice.m
@implementation UIDevice (Helper)
- (BOOL)isJailbroken {
BOOL jailbroken = NO;
NSString *cydiaPath = @"/Applications/Cydia.app";
NSString *aptPath = @"/private/var/lib/apt/";
if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {
jailbroken = YES;
}
if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {
jailbroken = YES;
}
return jailbroken;
}
@end
然後在你代碼中調用[UIDevice currentDevice] isJailbroken], 如果返回YES說明被破解了,為NO,則沒被破解