mirror of
https://github.com/somegeekintn/SimDirs.git
synced 2026-04-20 13:05:54 +00:00
where possible, show the marketing version and internal build version with each bundleID.
This commit is contained in:
parent
99fc6abf0b
commit
3b276c4875
1 changed files with 112 additions and 7 deletions
|
|
@ -8,6 +8,13 @@
|
|||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
// bundleID (e.g. com.foobar.spacefrenzy ), followed by app version label
|
||||
#define BUNDLE_VERSION_FORMAT @"%@ %@"
|
||||
|
||||
// market version label (internal version label)
|
||||
#define APP_VERSION_LABEL @"%@ (%@)"
|
||||
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property (nonatomic, weak) IBOutlet NSWindow *window;
|
||||
|
|
@ -146,6 +153,8 @@
|
|||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSURL *launchMapInfoURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
||||
|
||||
NSMutableDictionary *versionInfoTable = [[NSMutableDictionary alloc] init];
|
||||
|
||||
launchMapInfoURL = [launchMapInfoURL URLByAppendingPathComponent: @"data/Library/MobileInstallation/LastLaunchServicesMap.plist"];
|
||||
if (launchMapInfoURL != nil && [fileManager fileExistsAtPath: [launchMapInfoURL path]]) {
|
||||
|
|
@ -166,10 +175,20 @@
|
|||
|
||||
[pathKeys enumerateObjectsUsingBlock: ^(id inObject, NSUInteger inIndex, BOOL *outStop) {
|
||||
NSString *appPath = appInfo[inObject[@"pathKey"]];
|
||||
|
||||
// this section s/b ok. bundle location is always explored prior to sandbox location:
|
||||
NSString * versionInfo = [self getVersionInfo:appPath];
|
||||
if (versionInfo != nil) {
|
||||
versionInfoTable[bundleID] = versionInfo;
|
||||
}
|
||||
else {
|
||||
versionInfo = versionInfoTable[bundleID];
|
||||
}
|
||||
|
||||
|
||||
//NSLog(@"test %@ - %@", appPath, [fileManager fileExistsAtPath: appPath] ? @"YES" : @"NO");
|
||||
if (appPath != nil && [fileManager fileExistsAtPath: appPath]) {
|
||||
[self addPath: appPath withTitle: inObject[@"title"] forBundleID: bundleID withDeviceInfo: inDeviceInfo];
|
||||
[self addPath: appPath withTitle: inObject[@"title"] forBundleID: [NSString stringWithFormat:BUNDLE_VERSION_FORMAT, bundleID, versionInfo] withDeviceInfo: inDeviceInfo];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
@ -177,10 +196,45 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSString *) getVersionInfo: (NSString *) appPath
|
||||
{
|
||||
NSFileManager * fileManager = [NSFileManager defaultManager];
|
||||
NSString *match = @"*.app";
|
||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF like %@", match];
|
||||
NSArray *dirList = [fileManager contentsOfDirectoryAtPath:appPath error:nil];
|
||||
NSArray *appSubDir = [dirList filteredArrayUsingPredicate:predicate];
|
||||
|
||||
if ([appSubDir count] < 1)
|
||||
return nil;
|
||||
|
||||
NSString * infoPath = [NSString stringWithFormat:@"%@/%@/%@", appPath, appSubDir[0], @"Info.plist"];
|
||||
|
||||
if (! [fileManager fileExistsAtPath:infoPath]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSData *plistData = [fileManager contentsAtPath:infoPath];
|
||||
NSString *errorDesc = nil;
|
||||
NSPropertyListFormat format;
|
||||
NSDictionary *infoList = (NSDictionary *) [NSPropertyListSerialization
|
||||
propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format
|
||||
errorDescription:&errorDesc];
|
||||
if (infoList == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:APP_VERSION_LABEL, infoList[@"CFBundleShortVersionString"],
|
||||
infoList[@"CFBundleVersion"]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) updateDeviceInfoForAppsFromLogs: (NSMutableDictionary *) inDeviceInfo
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSURL *installLogURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
||||
|
||||
NSMutableDictionary *versionInfoTable = [[NSMutableDictionary alloc] init];
|
||||
|
||||
installLogURL = [installLogURL URLByAppendingPathComponent: @"data/Library/Logs/MobileInstallation/mobile_installation.log.0"];
|
||||
if (installLogURL != nil && [fileManager fileExistsAtPath: [installLogURL path]]) {
|
||||
|
|
@ -199,26 +253,77 @@
|
|||
|
||||
if ([bundleID rangeOfString: @"com.apple"].location == NSNotFound) {
|
||||
NSString *path = [installParts objectAtIndex: 2];
|
||||
|
||||
|
||||
if (path != nil && [fileManager fileExistsAtPath: path]) {
|
||||
NSString *pathTitle;
|
||||
NSString *versionInfo = nil;
|
||||
|
||||
if ([path rangeOfString: @"Data/Application"].location != NSNotFound) {
|
||||
pathTitle = @"Sandbox Location";
|
||||
// in first for-loop iteration, skip the sandbox
|
||||
continue;
|
||||
}
|
||||
else if ([path rangeOfString: @"Bundle/Application"].location != NSNotFound) {
|
||||
pathTitle = @"Bundle Location";
|
||||
NSLog(@"bundle id = [%@]", bundleID);
|
||||
NSLog(@"special path = [%@]", path);
|
||||
versionInfo = [self getVersionInfo:path];
|
||||
if (versionInfo != nil) {
|
||||
versionInfoTable[bundleID] = versionInfo;
|
||||
}
|
||||
|
||||
NSLog(@"extracted versionInfo = %@", versionInfo);
|
||||
|
||||
}
|
||||
else {
|
||||
pathTitle = @"???";
|
||||
}
|
||||
|
||||
[self addPath: path withTitle: pathTitle forBundleID: bundleID withDeviceInfo: inDeviceInfo];
|
||||
}
|
||||
[self addPath: path withTitle: pathTitle forBundleID:[NSString stringWithFormat:BUNDLE_VERSION_FORMAT, bundleID, versionInfo] withDeviceInfo: inDeviceInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (NSString *line in [installLog componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]) {
|
||||
logMentionRange = [line rangeOfString: @"Made container live for "];
|
||||
if (logMentionRange.location != NSNotFound) {
|
||||
NSArray *installParts = [[line substringFromIndex: logMentionRange.location + logMentionRange.length] componentsSeparatedByString: @" "];
|
||||
|
||||
if ([installParts count] == 3) { // expecting com.foo.bar at UUID
|
||||
NSString *bundleID = [installParts objectAtIndex: 0];
|
||||
|
||||
if ([bundleID rangeOfString: @"com.apple"].location == NSNotFound) {
|
||||
NSString *path = [installParts objectAtIndex: 2];
|
||||
|
||||
|
||||
if (path != nil && [fileManager fileExistsAtPath: path]) {
|
||||
NSString *pathTitle;
|
||||
NSString *versionInfo = nil;
|
||||
|
||||
if ([path rangeOfString: @"Data/Application"].location != NSNotFound) {
|
||||
pathTitle = @"Sandbox Location";
|
||||
versionInfo = versionInfoTable[bundleID];
|
||||
}
|
||||
else if ([path rangeOfString: @"Bundle/Application"].location != NSNotFound) {
|
||||
// in second for-loop iteration, skip the bundle location:
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
pathTitle = @"???";
|
||||
}
|
||||
|
||||
[self addPath: path withTitle: pathTitle forBundleID:[NSString stringWithFormat:BUNDLE_VERSION_FORMAT, bundleID, versionInfo] withDeviceInfo: inDeviceInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue