Skip to content

Commit

Permalink
Add function to move PBXContainer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Aug 31, 2024
1 parent 7bc36ed commit 9621f11
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion XCode/NSObject+KeyExtraction.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,42 @@
return guid;
}


id moveContainerProperties(NSDictionary *input)
{
NSMutableDictionary *result =
[NSMutableDictionary dictionaryWithDictionary: input];
NSDictionary *objects = [result objectForKey: @"objects"];
NSEnumerator *en = [objects keyEnumerator];
id key = nil;
id keyToRemove = nil;

while ((key = [en nextObject]) != nil)
{
id d = [objects objectForKey: key];

if ([d isKindOfClass: [NSDictionary class]])
{
NSString *cn = [d objectForKey: @"isa"];

if ([cn isEqualToString: @"PBXContainer"])
{
// [result addEntriesFromDictionary: d];
// [result removeObjectForKey: @"isa"];
// keyToRemove = key;
NSLog(@"obj = %@", d);
}
}
}

if (keyToRemove != nil)
{
[result removeObjectForKey: keyToRemove];
}

return result;
}

// Recursive function to flatten the property list
id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString **rootObjectGUID)
{
Expand Down Expand Up @@ -274,7 +310,11 @@ - (NSDictionary *) recursiveKeysAndValuesForObject: (id)object

- (NSDictionary *) allKeysAndValues
{
return flattenPlist([self recursiveKeysAndValuesForObject: self]);
id r = flattenPlist([self recursiveKeysAndValuesForObject: self]);
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary: r];
id result = moveContainerProperties(d);

return result;
}

@end

0 comments on commit 9621f11

Please sign in to comment.