Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't change permissions on the test executable directly, because app resources can't be modified after installing your app. That would be a security hole. So, that's why you need to copy it to a tmp/caches/documents directory, to then make it runnable.</p> <p>I'm not sure if your app needs to support multitasking, and if you need to detect the jailbreak <em>at the start of the first run</em>, or if it's ok to wait until the app closes. But, if you can turn off multitasking, then you could implement this method (little executable named <code>test</code> in this example):</p> <pre class="lang-objc prettyprint-override"><code>- (void)applicationWillTerminate:(UIApplication *)application { NSString* path = [NSTemporaryDirectory() stringByAppendingPathComponent: @"test"]; int result = execlp([path UTF8String], [path UTF8String], NULL); // if we got here, then the attempt to run the external process failed, so make a note of this: [[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithBool: NO] forKey: @"is_jailbroken"]; NSLog(@"test returns %d", result); } </code></pre> <p>If the <code>execlp()</code> call succeeds, then yes, your process will be replaced. But, the process is about to shut down anyway. When I do this, I do not see an actual crash log, so I'm not sure if Apple would complain about this. There's no <em>appearance</em> of crashing to the user.</p> <p>If you can't exec the separate process, then your app will continue to the line of code that allows you to log the fact that the phone is apparently not jailbroken, which can be noted the next time your app starts.</p> <p>If you <strong>do</strong> need to support multitasking, then you could try putting the above code into a multitasking callback like <code>applicationDidEnterBackground:</code>. If the phone is normal, the exec call fails (and returns), so your app will not terminate (exit). I would assume (?) that Apple reviewers don't test your app on jailbroken phones. For those people with jailbroken phones, your app will then exit, instead of going into the background. Maybe that's good enough for your needs?</p> <p>Also, just FYI, there's other ways to test for a jailbroken system, that are probably pretty reliable (I'm not sure if you want to be able to detect a jailbroken phone 100% of the time, or detect the standard jailbroken configuration)</p> <p><a href="https://stackoverflow.com/questions/1140856/determining-if-an-iphone-is-jail-broken-programatically">Determining if an iPhone is Jail broken Programmatically</a></p> <p><a href="https://stackoverflow.com/questions/413242/how-do-i-detect-that-an-sdk-app-is-running-on-a-jailbroken-phone">How do I detect that an iOS app is running on a jailbroken phone?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload