Detect if an iPhone is jailbroken

27 Mar
2010

It’s pretty basic, it’s not an crack detector, but it’s handy when you’re sending debug data and your customer have some weird bug because of some custom winterboard/sbsettings/custom hack. You can argue against supporting that.

Note: It’s not working for “Installer”-only hacks. But they are rare those days, most other implementations use apt as their package system.

It’s a UIDevice Category. Call it via [[UIDevice currentDevice] isJailbroken].

@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

Related posts:

  1. Better iPhone/Mac logging with GTMLogger
  2. Blocks on the iPhone – PSAlertView
  3. iPhone Piracy
  4. [NSString description] via reflection
  5. implementation of -viewDidUnload caused

2 Responses to Detect if an iPhone is jailbroken

Avatar

IQpierce

October 11th, 2010 at 7:43 pm

Have you shipped an app with this code in it? I’m concerned that Apple might take issue with the phone checking the local file structure…

Avatar

studpete

October 12th, 2010 at 1:00 pm

Yes, shipped that. It’s no issue.

Comment Form

top

Switch to our mobile site