Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MobileIron: Rename bundle id in CFBundleURLTypes #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions iReSign/iReSign/iReSignAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
static NSString *kProductsDirName = @"Products";
static NSString *kInfoPlistFilename = @"Info.plist";
static NSString *kiTunesMetadataFileName = @"iTunesMetadata";
static NSString *kKeyCFBundleURLTypes = @"CFBundleURLTypes";
static NSString *kKeyCFBundleURLName = @"CFBundleURLName";
static NSString *kKeyCFBundleURLSchemes = @"CFBundleURLSchemes";


@implementation iReSignAppDelegate

Expand Down Expand Up @@ -251,8 +255,37 @@ - (BOOL)changeBundleIDForFile:(NSString *)filePath bundleIDKey:(NSString *)bundl

if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
plist = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *orgBundleID = plist[bundleIDKey];
[plist setObject:newBundleID forKey:bundleIDKey];

if (plist[kKeyCFBundleURLTypes]!=nil) {
NSMutableArray *cfBundleURLTypes = [NSMutableArray arrayWithArray:plist[kKeyCFBundleURLTypes]];
for(int j=0; j<cfBundleURLTypes.count; j++) {
NSObject *object = cfBundleURLTypes[j];
if ([object isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary:(NSDictionary*)object];
NSObject *object1 = d[kKeyCFBundleURLName];
if (object1!=nil && [object1 isKindOfClass:[NSString class]] && [((NSString*)object1) isEqualToString:orgBundleID]) {
[d setObject:newBundleID forKey:kKeyCFBundleURLName];
}
NSObject *object2 = d[kKeyCFBundleURLSchemes];
if (object2!=nil && [object2 isKindOfClass:[NSArray class]]) {
NSString *orgAcBundleID = [NSString stringWithFormat:@"ac%@",orgBundleID];
NSMutableArray *cfBundleURLSchemes = [NSMutableArray arrayWithArray:(NSArray*)object2];
for(int i=0; i<cfBundleURLSchemes.count; i++) {
NSObject *object3 = cfBundleURLSchemes[i];
if ([object3 isKindOfClass:[NSString class]] && [((NSString*)object3) isEqualToString:orgAcBundleID]) {
cfBundleURLSchemes[i] = [NSString stringWithFormat:@"ac%@",newBundleID];
}
}
[d setObject:cfBundleURLSchemes forKey:kKeyCFBundleURLSchemes];
}
cfBundleURLTypes[j] = d;
}
}
[plist setObject:cfBundleURLTypes forKey:kKeyCFBundleURLTypes];
}

NSData *xmlData = [NSPropertyListSerialization dataWithPropertyList:plist format:options options:kCFPropertyListImmutable error:nil];

return [xmlData writeToFile:filePath atomically:YES];
Expand Down