Skip to content

Instantly share code, notes, and snippets.

@demonnico
Created December 9, 2013 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demonnico/fa9dc613683a1e7337fa to your computer and use it in GitHub Desktop.
Save demonnico/fa9dc613683a1e7337fa to your computer and use it in GitHub Desktop.
check all app's version info in your iphone.
#import <dlfcn.h>
- (NSMutableArray *)browseInstalled
{
NSMutableArray *installedArray = installedApplications();
return installedArray;
}
typedef NSDictionary *(*PMobileInstallationLookup)(NSDictionary *params, id callback_unknown_usage);
NSMutableArray *installedApplications()
{
void *lib = dlopen("/System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation", RTLD_LAZY);
if (lib)
{
PMobileInstallationLookup pMobileInstallationLookup = (PMobileInstallationLookup)dlsym(lib, "MobileInstallationLookup");
if (pMobileInstallationLookup)
{
NSArray *wanted = nil;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"Any", @"ApplicationType", wanted, @"BundleIDs",nil];
NSMutableArray *postArray = [NSMutableArray array];
NSDictionary *dict = pMobileInstallationLookup(params, NULL);
NSArray *allkeys = [dict allKeys];
for (int index = 0, count = [allkeys count]; index < count; index++) {
NSString *key = [allkeys objectAtIndex:index];
// ignore all aple app
if ([key rangeOfString:@"com.apple"].location == NSNotFound) {
NSDictionary *value = [dict objectForKey:key];
NSString *bundleVersion = [value objectForKey:@"CFBundleVersion"];
if (bundleVersion == nil) {
bundleVersion = @"1.0";
}
// bundleVersion = @"1.0"; // for test
NSDictionary *postDictionary = [NSDictionary dictionaryWithObjectsAndKeys:key, @"bundleid", bundleVersion, @"version", nil];
[postArray addObject:postDictionary];
}
}
TTDEBUGLOG(@"%@", postArray);
return postArray;
}
}
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment