Skip to content

Commit 8527f15

Browse files
author
Mike Richter
committed
Support Xcode 11's directory hierarchy #18463
1 parent 84525ee commit 8527f15

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Source/class-dump.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,16 @@ int main(int argc, char *argv[])
613613
static NSString *resolveFrameworkRoot(NSFileManager *fileManager,
614614
NSString *const sdkRoot) {
615615

616-
NSString *platformsString = @"Platforms";
617-
NSRange range = [sdkRoot rangeOfString:platformsString];
616+
NSRange range = [sdkRoot rangeOfString:@"/Platforms/"];
618617
if (range.location != NSNotFound) {
619-
NSString *platforms = [sdkRoot substringToIndex:(range.location + platformsString.length)];
620-
NSString *root = [platforms stringByAppendingString:@"/iPhoneOS.platform/Developer/Library/CoreSimulator/"
621-
@"Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot"];
622-
if ([fileManager fileExistsAtPath:root]) {
623-
return root;
618+
// In Xcode 11, the directories were reordered. Prefer the Xcode 11 order.
619+
NSUInteger start = range.location + range.length;
620+
for (NSString *simulator in [NSArray arrayWithObjects:@"iPhoneOS.platform/Library/Developer", @"iPhoneOS.platform/Developer/Library", nil]) {
621+
NSString *candidate = [simulator stringByAppendingString:@"/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot"];
622+
NSString *root = [sdkRoot stringByReplacingCharactersInRange:NSMakeRange(start, [sdkRoot length] - start) withString:candidate];
623+
if ([fileManager fileExistsAtPath:root]) {
624+
return root;
625+
}
624626
}
625627
}
626628

0 commit comments

Comments
 (0)