Workaround ldid issue, improve app icons

This commit is contained in:
opa334 2022-09-12 18:20:39 +02:00
parent 92e4981ac0
commit ad2b6b6c9f
3 changed files with 56 additions and 3 deletions

View File

@ -496,8 +496,46 @@ int signApp(NSString* appPath)
} }
else 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 // app has entitlements, keep them
ldidRet = runLdid(@[@"-s", certArg, appPath], nil, &errorOutput); 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); NSLog(@"ldid exited with status %d", ldidRet);

View File

@ -95,8 +95,15 @@
// Configure the cell... // Configure the cell...
cell.textLabel.text = [[TSApplicationsManager sharedInstance] displayNameForAppPath:appPath]; cell.textLabel.text = [[TSApplicationsManager sharedInstance] displayNameForAppPath:appPath];
cell.detailTextLabel.text = appVersion; cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ • %@", appVersion, appId];
cell.imageView.image = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:2.0]; 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; return cell;
} }

View File

@ -59,7 +59,15 @@
- (NSString*)versionStringForAppPath:(NSString*)appPath - (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 - (NSError*)errorForCode:(int)code