Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So here's an instant solution for <strong>jailbroken devices,</strong> which makes it possible to directly install any <code>.ipa</code> file from within your application. The steps you have to take is:</p> <p>I. Gain root access. You can achieve this by calling <code>setuid(0);</code> from your <code>main()</code> function. You'll need to set the sticky permission bit on your executable and use a startup script too.</p> <p>II. Unzip the <code>.ipa</code> file. Yes, that's right - IPAs are just disguised ZIP files. You can use the opensource <a href="http://nih.at/libzip/">libzip</a> library for this.</p> <p>III. There'll be a directory called <code>Payload</code> inside. The actual app bundle (let's call it <code>MyApp.app</code>) will reside in that folder.</p> <p>IV. Create a directory in the <code>/var/mobile/Applications</code> directory on the filesystem. This will be the container sandbox of the app to be installed. By convention, the name of this directory should be an UUID. For example, you can use the following code snippet for this:</p> <pre><code>CFUUIDRef uuidObj = CFUUIDCreate(NULL); CFStringRef uuid = CFUUIDCreateString(NULL, uuidObj); CFRelease(uuidObj); NSString *appPath = [@"/var/mobile/Applications" stringByAppendingPathComponent:(id)uuid]; [fmgr createDirectoryAtPath:appPath withIntermediateDirectories:YES attributes:nil error:NULL]; CFRelease(uuid); </code></pre> <p>V. Find the app bundle by looping through the contents of the <code>Payload</code> directory (obtained in step II). Copy it over to the newly created sandbox (of which the name is the UUID string). Also copy the <code>iTunesMetadata.plist</code> and <code>iTunesArtwork</code> files in order iTunes to display a nice icon for the app and to notify you of updates. Fix the permissions of the executable of the application as well to make it executable:</p> <pre><code>NSString *execName = [appInfoPlist objectForKey:@"CFBundleExecutable"]; NSString *execPath = [bundle stringByAppendingPathComponent:execName]; chmod(execPath.UTF8String, 0755); </code></pre> <p>VI. You'll need to tell SpringBoard to locate your app and then to reload its installed app cache to make the icon of the freshly installed appear on the home screen. For this, you first update the list of the applications in the MobileInstallation property list file. Here the <code>bundle</code> variable refers to the filesystem location of the app bundle, something like <code>/var/mobile/applications/LONG_UUID_STRING/MyApp.app</code>.</p> <pre><code>#define kMobileInstallationPlistPath @"/var/mobile/Library/Caches/com.apple.mobile.installation.plist" NSMutableDictionary *appInfoPlist = [NSMutableDictionary dictionaryWithContentsOfFile:[bundle stringByAppendingPathComponent:@"Info.plist"]]; [appInfoPlist setObject:@"User" forKey:@"ApplicationType"]; [appInfoPlist setObject:bundle forKey:@"Path"]; [appInfoPlist setObject:@{ @"CFFIXED_USER_HOME" : appPath, @"HOME" : appPath, @"TMPDIR" : [appPath stringByAppendingPathComponent:@"tmp"] } forKey:@"EnvironmentVariables"]; [appInfoPlist setObject:appPath forKey:@"Container"]; NSData *data = [NSData dataWithContentsOfFile:kMobileInstallationPlistPath]; NSMutableDictionary *mobileInstallation = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainersAndLeaves format:NULL error:NULL]; NSString *bundleID = [appInfoPlist objectForKey:@"CFBundleIdentifier"]; [[mobileInstallation objectForKey:@"User"] setObject:appInfoPlist forKey:bundleID]; [mobileInstallation writeToFile:kMobileInstallationPlistPath atomically:NO]; </code></pre> <p>Then remove the cached app information SpringBoard stores:</p> <pre><code>remove("/var/mobile/Library/Caches/com.apple.mobile.installation.plist"); remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons"); remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons.plist"); remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons"); remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons.plist"); remove("/var/mobile/Library/Caches/SpringBoardIconCache"); remove("/var/mobile/Library/Caches/SpringBoardIconCache-small"); remove("/var/mobile/Library/Caches/com.apple.IconsCache"); </code></pre> <p>Then notify SpringBoard to reload the list of all applications:</p> <pre><code>Class __LSApplicationWorkspace = objc_getClass("LSApplicationWorkspace"); [(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] invalidateIconCache:nil]; [(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] registerApplication:[NSURL fileURLWithPath:bundle]]; notify_post("com.apple.mobile.application_installed"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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