From ad2b6b6c9f3914e176bbce37085ea8d8a6a778de Mon Sep 17 00:00:00 2001 From: opa334 Date: Mon, 12 Sep 2022 18:20:39 +0200 Subject: [PATCH] Workaround ldid issue, improve app icons --- Helper/main.m | 38 ++++++++++++++++++++++++++++++++ Store/TSAppTableViewController.m | 11 +++++++-- Store/TSApplicationsManager.m | 10 ++++++++- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Helper/main.m b/Helper/main.m index 24e8240..411c640 100644 --- a/Helper/main.m +++ b/Helper/main.m @@ -496,8 +496,46 @@ int signApp(NSString* appPath) } else { + // Work around an ldid bug where it doesn't keep entitlements on stray binaries + NSMutableDictionary* storedEntitlements = [NSMutableDictionary new]; + NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:[NSURL fileURLWithPath:appPath] includingPropertiesForKeys:nil options:0 errorHandler:nil]; + NSURL* fileURL; + while(fileURL = [enumerator nextObject]) + { + NSString* filePath = fileURL.path; + + BOOL isDir; + [[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir]; + + if([filePath.lastPathComponent isEqualToString:@"Info.plist"]) + { + NSDictionary* infoDictionary = [NSDictionary dictionaryWithContentsOfFile:filePath]; + NSArray* tsRootBinaries = infoDictionary[@"TSRootBinaries"]; + if(tsRootBinaries && [tsRootBinaries isKindOfClass:[NSArray class]]) + { + for(NSString* rootBinary in tsRootBinaries) + { + if([rootBinary isKindOfClass:[NSString class]]) + { + NSString* rootBinaryPath = [[filePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:rootBinary]; + storedEntitlements[rootBinaryPath] = dumpEntitlementsFromBinaryAtPath(rootBinaryPath); + } + } + } + } + } + // app has entitlements, keep them ldidRet = runLdid(@[@"-s", certArg, appPath], nil, &errorOutput); + + [storedEntitlements enumerateKeysAndObjectsUsingBlock:^(NSString* binaryPath, NSDictionary* entitlements, BOOL* stop) + { + NSString* tmpEntitlementPlistPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"ent.xml"]; + [entitlements writeToURL:[NSURL fileURLWithPath:tmpEntitlementPlistPath] error:nil]; + NSString* tmpEntitlementArg = [@"-S" stringByAppendingString:tmpEntitlementPlistPath]; + runLdid(@[tmpEntitlementArg, certArg, binaryPath], nil, nil); + [[NSFileManager defaultManager] removeItemAtPath:tmpEntitlementPlistPath error:nil]; + }]; } NSLog(@"ldid exited with status %d", ldidRet); diff --git a/Store/TSAppTableViewController.m b/Store/TSAppTableViewController.m index ba96855..522d3c4 100644 --- a/Store/TSAppTableViewController.m +++ b/Store/TSAppTableViewController.m @@ -95,8 +95,15 @@ // Configure the cell... cell.textLabel.text = [[TSApplicationsManager sharedInstance] displayNameForAppPath:appPath]; - cell.detailTextLabel.text = appVersion; - cell.imageView.image = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:2.0]; + cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ • %@", appVersion, appId]; + cell.imageView.image = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:[UIScreen mainScreen].scale]; + cell.imageView.layer.borderWidth = 0.2; + cell.imageView.layer.borderColor = [UIColor blackColor].CGColor; + cell.imageView.layer.cornerRadius = 13.8; + + cell.preservesSuperviewLayoutMargins = NO; + cell.separatorInset = UIEdgeInsetsZero; + cell.layoutMargins = UIEdgeInsetsZero; return cell; } diff --git a/Store/TSApplicationsManager.m b/Store/TSApplicationsManager.m index 2ae492f..8816c09 100644 --- a/Store/TSApplicationsManager.m +++ b/Store/TSApplicationsManager.m @@ -59,7 +59,15 @@ - (NSString*)versionStringForAppPath:(NSString*)appPath { - return [self infoDictionaryForAppPath:appPath][@"CFBundleShortVersionString"]; + NSDictionary* infoDict = [self infoDictionaryForAppPath:appPath]; + NSString* versionString = infoDict[@"CFBundleShortVersionString"]; + + if(!versionString) + { + versionString = infoDict[@"CFBundleVersion"]; + } + + return versionString; } - (NSError*)errorForCode:(int)code