Skip to content

Commit

Permalink
Merge pull request #23 from sirjordank/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekish committed Sep 26, 2014
2 parents bb26ad1 + a63ccb2 commit 37b11a4
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions iReSign/iReSign/iReSignAppDelegate.m
Expand Up @@ -303,10 +303,34 @@ - (void)doCodeSigning {
}

if (appPath) {
NSString *resourceRulesPath = [[NSBundle mainBundle] pathForResource:@"ResourceRules" ofType:@"plist"];
NSString *resourceRulesArgument = [NSString stringWithFormat:@"--resource-rules=%@",resourceRulesPath];

NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", [certComboBox objectValue], resourceRulesArgument, nil];
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-fs", [certComboBox objectValue], nil];

NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
float systemVersionFloat = [[systemVersionDictionary objectForKey:@"ProductVersion"] floatValue];
if (systemVersionFloat < 10.9f) {

/*
Before OSX 10.9, code signing requires a version 1 signature.
The resource envelope is necessary.
To ensure it is added, append the resource flag to the arguments.
*/

NSString *resourceRulesPath = [[NSBundle mainBundle] pathForResource:@"ResourceRules" ofType:@"plist"];
NSString *resourceRulesArgument = [NSString stringWithFormat:@"--resource-rules=%@",resourceRulesPath];
[arguments addObject:resourceRulesArgument];
} else {

/*
For OSX 10.9 and later, code signing requires a version 2 signature.
The resource envelope is obsolete.
To ensure it is ignored, remove the resource key from the Info.plist file.
*/

NSString *infoPath = [NSString stringWithFormat:@"%@/Info.plist", appPath];
NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:infoPath];
[infoDict removeObjectForKey:@"CFBundleResourceSpecification"];
[infoDict writeToFile:infoPath atomically:YES];
}

if (![[entitlementField stringValue] isEqualToString:@""]) {
[arguments addObject:[NSString stringWithFormat:@"--entitlements=%@", [entitlementField stringValue]]];
Expand Down

0 comments on commit 37b11a4

Please sign in to comment.