NSArray *bundles2Check = [NSArrayarrayWithObjects:@"com.travelsky.umetrip.pro",@"com.travelsky.umetrip",@"com.blahblah.nonexistent",nil];
for (NSString *identifier in bundles2Check)
if (APCheckIfAppInstalled(identifier))
NSLog(@"App installed: %@", identifier);
else
NSLog(@"App not installed: %@", identifier);
BOOL APCheckIfAppInstalled(NSString *bundleIdentifier)
{
// static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
staticNSString *const cacheFileName =@"com.apple.mobile.installation~iPhone.plist";
NSString *relativeCachePath = [[@"Library"stringByAppendingPathComponent:@"Caches"]stringByAppendingPathComponent: cacheFileName];
NSArray *nameArray = [[NSArray alloc] initWithContentsOfFile:relativeCachePath];
NSDictionary *dic =[[NSDictionaryalloc]initWithContentsOfFile:relativeCachePath];
NSLog(@"dic===%@",dic);
NSDictionary *cacheDict = nil;
NSString *path = nil;
// Loop through all possible paths the cache could be in
for (short i = 0; 1; i++)
{
switch (i) {
case0:// Jailbroken apps will find the cache here; their home directory is /var/mobile
path = [NSHomeDirectory()stringByAppendingPathComponent: relativeCachePath];
break;
case1:// App Store apps and Simulator will find the cache here; home (/var/mobile/) is 2 directories above sandbox folder
path = [[NSHomeDirectory()stringByAppendingPathComponent:@"../.."]stringByAppendingPathComponent: relativeCachePath];
break;
case2:// If the app is anywhere else, default to hardcoded /var/mobile/
path = [@"/var/mobile"stringByAppendingPathComponent: relativeCachePath];
break;
default:// Cache not found (loop not broken)
return NO;
break; }
BOOL isDir = NO;
// path =@"/Users/luppy01/Library/Application Support/iPhone Simulator/6.0/Library/Caches/com.apple.mobile.installation.plist";
// path =@"/Users/luppy01/Library/Application Support/iPhone Simulator/7.0/Applications/0B627EE2-B818-4A7F-9A08-D7F856ACE4A8/Library/Caches/com.apple.mobile.installation.plist";
// if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir) // Ensure that file exists
if ([[NSFileManagerdefaultManager]fileExistsAtPath: path ] )// Ensure that file exists
cacheDict = [NSDictionarydictionaryWithContentsOfFile: path];
if (cacheDict)// If cache is loaded, then break the loop. If the loop is not "broken," it will return NO later (default: case)
break;
}
NSDictionary *system = [cacheDictobjectForKey:@"System"];// First check all system (jailbroken) apps
if ([system objectForKey: bundleIdentifier])returnYES;
NSDictionary *user = [cacheDictobjectForKey:@"User"];// Then all the user (App Store /var/mobile/Applications) apps
if ([user objectForKey: bundleIdentifier])returnYES;
// If nothing returned YES already, we'll return NO now
returnNO;
}
实现`MobileInstallation.framework`相关方法
比较早的东西呢,拿出来和大家分享一下。
最近又开始研究越狱开发了,所以顺手把之前做的这个拿来。
Mobile Installation 是 iOS 中负责安装 IPA 和管理安装app的 Framework
91助手,同步推,itools,pp助手,等等都是用这写api
这是获取安装程序列表的一个demo:
http://www.iloss.me/post/kai-fa/2014-03-07-mobileinstallation
分析过程(ida)之前发过一次,时间久了找不到了。
完整代码: github