Skip to content

Commit

Permalink
Support Xcode betas with xcode-locator
Browse files Browse the repository at this point in the history
Previously if you had 2 builds of the same version of Xcode, for example
10.2.0 beta 1 and 10.2.0 beta 2, there was no way to disambiguate them.
This change appends the `CFBundleVersion` of each Xcode version to allow
you to specify that if desired.
  • Loading branch information
keith committed Feb 7, 2019
1 parent e2e2353 commit 3d61f58
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/osx/xcode_locator.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ - (id)description {
// 2. Not older (at least as high version number).
static void AddEntryToDictionary(
XcodeVersionEntry *entry,
NSString *bundleVersion,
NSMutableDictionary<NSString *, XcodeVersionEntry *> *dict) {
BOOL inApplications =
[entry.url.path rangeOfString:@"/Applications/"].location != NSNotFound;
NSString *entryVersion = entry.version;
if (bundleVersion) {
entryVersion = [entryVersion stringByAppendingFormat:@".%@", bundleVersion];
}
NSString *subversion = entryVersion;
if (dict[entryVersion] && !inApplications) {
return;
Expand Down Expand Up @@ -172,16 +176,19 @@ static void AddEntryToDictionary(
errors = YES;
continue;
}

NSString *expandedVersion = ExpandVersion(version);
NSLog(@"Version strings for %@: short=%@, expanded=%@",
url, version, expandedVersion);

NSString *bundleVersion = [bundle.infoDictionary
objectForKey:@"CFBundleVersion"];
NSURL *developerDir =
[url URLByAppendingPathComponent:@"Contents/Developer"];
XcodeVersionEntry *entry =
[[XcodeVersionEntry alloc] initWithVersion:expandedVersion
url:developerDir];
AddEntryToDictionary(entry, dict);
AddEntryToDictionary(entry, bundleVersion, dict);
}
return errors ? nil : dict;
}
Expand Down

0 comments on commit 3d61f58

Please sign in to comment.