I am developing for a jailbroken app and I don't care if it's rejected by the App store. I have found a way to completely wipe out my iPhone using this way Is there a way to completely wipe out iPhone data programatically?. There is a problem with this method however. It makes my iphone worthless and I have to recover it using itunes. I just want to factory restore my iphone programmatically.
-
2*Factory settings* would mean the exact configuration that the device came with, but if you've ever updated the OS on the device you're not likely to be able to go back to its original state. So presumably, you mean something other than *factory settings*. – Caleb Mar 04 '13 at 16:26
1 Answers
There is a private API SBDataReset in SpringboardServices private framework. It wipes all data.
You can check the following code for example how to use it.
An application which uses this API should have "com.apple.springboard.wipedevice" entitlement to work.
BTW. One more alternative is to use MDM protocol. It has a wipe command. However, it requires way more machinery (MDM server, enroll a user).
Update 1
It looks like sample code in the link is out date. I looked into Preferences and couple of other pieces of iOS software which uses SBDataReset and it looks like new argument was introduced to SBDataReset.
Try following code (sorry, I don't have jailbroken iOS device right now, so I can't try it on my own)
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#include <dlfcn.h>
#include <stdio.h>
// Framework Paths
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"
#define UIKITPATH "/System/Library/Framework/UIKit.framework/UIKit"
#define WIPE_MODE_NORMAL 4
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Fetch the SpringBoard server port
mach_port_t *p;
void *uikit = dlopen(UIKITPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(uikit, "SBSSpringBoardServerPort");
p = SBSSpringBoardServerPort();
dlclose(uikit);
// Getting DataReset proc
void *sbserv = dlopen(SBSERVPATH, RTLD_LAZY);
int (*dataReset)(mach_port_t* port, int wipeMode) = dlsym(sbserv, "SBDataReset");
dataReset(p, WIPE_MODE_NORMAL);
dlclose(sbserv);
[pool release];
}
Please notice, that there is second parameter for SBDataReset function.
It looks like 4 is normal wipe mode and 6 is brick wipe mode.
DISCLAIMER This code is provided AS IS. I have no idea what will happen if device will be wiped in brick mode.

- 22,758
- 18
- 92
- 184
-
It does'nt delete anything.All it does is restart my iphone :( I need to erase all data on the phone as well as restore it just like we can do by selecting the second option in the iphone settings reset tab – zzzzz Mar 05 '13 at 09:13
-
2+1 This seems like the best solution you'll find for this. I do just want to mention one small caveat, that I mentioned in iOsBoy's other similar question. On JB devices, [pressing the Erase All Content and Settings button in Settings screws things up](http://www.jailbreakqa.com/questions/106644/reset-all-settings-problem). I don't fully understand why, but I've see it happen. If this private API just does what that button does, then you may have problems. I think Victor did his duty to warn you about trying this, I just wanted to mention this issue for other brave souls who try it. – Nate Mar 05 '13 at 22:27
-
@VictorRonin I think your API has same effect as invoking the factory restore from settings.Because using any of the both ways the iphone gets stuck if I try to restore it when it is jailbroken.How do I get rid of this problem.Why does jailbreaking make factory reset impossible? Do I delete some files before running your API ? Any suggestions? – zzzzz Mar 06 '13 at 09:43
-
1@iOSBoy & Nate: Yes, this API is the main thing which is called by Preferences application. So, if pressing Erase All doesn't work correctly from preferences, it won't work correctly while this call either. – Victor Ronin Mar 06 '13 at 16:20
-
1@iOsBoy, as I said, I don't know which modifications made to the phone during the jailbreak cause the problems when using this erase feature. This is less of a programming issue, and more of a jailbreak detail, so I'm thinking that you might want to post the question *"what happens during a jailbreak that makes Erase All Content and Settings fail?"* on jailbreakqa.com. With that answer, *maybe* you'll be better armed to solve this problem. thebigboss.org also might have some info. – Nate Mar 06 '13 at 22:08
-
Is it possible to do something similar in iOS 10 - I knwo this is an old thread - Just trying this out in latest OS - this looks like have been locked down – vivianaranha Jun 13 '17 at 21:10
-
@vivianaranha Actually, this whole thread is related to jailbroken phones. – Victor Ronin Jun 14 '17 at 02:33
-
1add `
com.apple.springboard.wipedevice ` and before return add `NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; [runLoop run];` tested on 12.4 – loader Dec 09 '21 at 09:14