mirror of
https://github.com/somegeekintn/SimDirs.git
synced 2026-04-27 14:57:40 +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"
|
#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 ()
|
@interface AppDelegate ()
|
||||||
|
|
||||||
@property (nonatomic, weak) IBOutlet NSWindow *window;
|
@property (nonatomic, weak) IBOutlet NSWindow *window;
|
||||||
|
|
@ -147,6 +154,8 @@
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSURL *launchMapInfoURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
NSURL *launchMapInfoURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
||||||
|
|
||||||
|
NSMutableDictionary *versionInfoTable = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
launchMapInfoURL = [launchMapInfoURL URLByAppendingPathComponent: @"data/Library/MobileInstallation/LastLaunchServicesMap.plist"];
|
launchMapInfoURL = [launchMapInfoURL URLByAppendingPathComponent: @"data/Library/MobileInstallation/LastLaunchServicesMap.plist"];
|
||||||
if (launchMapInfoURL != nil && [fileManager fileExistsAtPath: [launchMapInfoURL path]]) {
|
if (launchMapInfoURL != nil && [fileManager fileExistsAtPath: [launchMapInfoURL path]]) {
|
||||||
NSData *plistData = [NSData dataWithContentsOfURL: launchMapInfoURL];
|
NSData *plistData = [NSData dataWithContentsOfURL: launchMapInfoURL];
|
||||||
|
|
@ -167,9 +176,19 @@
|
||||||
[pathKeys enumerateObjectsUsingBlock: ^(id inObject, NSUInteger inIndex, BOOL *outStop) {
|
[pathKeys enumerateObjectsUsingBlock: ^(id inObject, NSUInteger inIndex, BOOL *outStop) {
|
||||||
NSString *appPath = appInfo[inObject[@"pathKey"]];
|
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");
|
//NSLog(@"test %@ - %@", appPath, [fileManager fileExistsAtPath: appPath] ? @"YES" : @"NO");
|
||||||
if (appPath != nil && [fileManager fileExistsAtPath: appPath]) {
|
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,11 +196,46 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (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
|
- (void) updateDeviceInfoForAppsFromLogs: (NSMutableDictionary *) inDeviceInfo
|
||||||
{
|
{
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSURL *installLogURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
NSURL *installLogURL = [[NSURL alloc] initFileURLWithPath: inDeviceInfo[@"path"]];
|
||||||
|
|
||||||
|
NSMutableDictionary *versionInfoTable = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
installLogURL = [installLogURL URLByAppendingPathComponent: @"data/Library/Logs/MobileInstallation/mobile_installation.log.0"];
|
installLogURL = [installLogURL URLByAppendingPathComponent: @"data/Library/Logs/MobileInstallation/mobile_installation.log.0"];
|
||||||
if (installLogURL != nil && [fileManager fileExistsAtPath: [installLogURL path]]) {
|
if (installLogURL != nil && [fileManager fileExistsAtPath: [installLogURL path]]) {
|
||||||
NSString *installLog = [[NSString alloc] initWithContentsOfURL: installLogURL usedEncoding: nil error: nil];
|
NSString *installLog = [[NSString alloc] initWithContentsOfURL: installLogURL usedEncoding: nil error: nil];
|
||||||
|
|
@ -200,25 +254,76 @@
|
||||||
if ([bundleID rangeOfString: @"com.apple"].location == NSNotFound) {
|
if ([bundleID rangeOfString: @"com.apple"].location == NSNotFound) {
|
||||||
NSString *path = [installParts objectAtIndex: 2];
|
NSString *path = [installParts objectAtIndex: 2];
|
||||||
|
|
||||||
|
|
||||||
if (path != nil && [fileManager fileExistsAtPath: path]) {
|
if (path != nil && [fileManager fileExistsAtPath: path]) {
|
||||||
NSString *pathTitle;
|
NSString *pathTitle;
|
||||||
|
NSString *versionInfo = nil;
|
||||||
|
|
||||||
if ([path rangeOfString: @"Data/Application"].location != NSNotFound) {
|
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) {
|
else if ([path rangeOfString: @"Bundle/Application"].location != NSNotFound) {
|
||||||
pathTitle = @"Bundle Location";
|
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 {
|
else {
|
||||||
pathTitle = @"???";
|
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