Created
December 9, 2013 14:41
-
-
Save demonnico/fa9dc613683a1e7337fa to your computer and use it in GitHub Desktop.
check all app's version info in your iphone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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