xcode_locator supports -v mode, which outputs only system-supported xcode versions and their aliases in easily-parsed format
This is convenient as skylark does not have extensive string-parsing (regex) features, and when xcode-locator is invoked from a skylark rule, this format is cleanest and contains only relevant info.

--
MOS_MIGRATED_REVID=124372740
diff --git a/src/tools/xcode/xcodelocator/xcode_locator.m b/src/tools/xcode/xcodelocator/xcode_locator.m
index 09ebc00..4939259 100644
--- a/src/tools/xcode/xcodelocator/xcode_locator.m
+++ b/src/tools/xcode/xcodelocator/xcode_locator.m
@@ -92,20 +92,30 @@
 int main(int argc, const char * argv[]) {
   @autoreleasepool {
     NSString *versionArg = nil;
+    BOOL versionsOnly = NO;
     if (argc == 1) {
       versionArg = @"";
     } else if (argc == 2) {
-      versionArg = [NSString stringWithUTF8String:argv[1]];
-      NSCharacterSet *versSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
-      if ([versionArg rangeOfCharacterFromSet:versSet.invertedSet].length != 0) {
-        versionArg = nil;
+      NSString *firstArg = [NSString stringWithUTF8String:argv[1]];
+      if ([@"-v" isEqualToString:firstArg]) {
+        versionsOnly = YES;
+        versionArg = @"";
+      } else {
+        versionArg = firstArg;
+        NSCharacterSet *versSet =
+            [NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
+        if ([versionArg rangeOfCharacterFromSet:versSet.invertedSet].length != 0) {
+          versionArg = nil;
+        }
       }
     }
     if (versionArg == nil) {
-      printf("xcode_locator <version_number>\n"
+      printf("xcode_locator [-v|<version_number>]\n"
              "Given a version number, or partial version number in x.y.z format, will attempt "
              "to return the path to the appropriate developer directory.\nOmitting a version "
-             "number will list all available versions in JSON format.\n");
+             "number will list all available versions in JSON format, alongside their paths.\n"
+             "Passing -v will list all available fully-specified version numbers along with "
+             "their possible aliases, each on a new line. For example: '7.3.1:7,7.3,7.3.1'.\n");
       return 1;
     }
 
@@ -143,13 +153,21 @@
       return 0;
     }
 
-    // Print out list in json format.
-    printf("{\n");
-    for (NSString *version in dict) {
-      XcodeVersionEntry *entry = dict[version];
-      printf("\t\"%s\": \"%s\",\n", version.UTF8String, entry.url.fileSystemRepresentation);
+    if (versionsOnly) {
+      NSSet *distinctValues = [[NSSet alloc] initWithArray:[dict allValues]];
+      for (XcodeVersionEntry *value in distinctValues) {
+        printf("%s:", value.version.UTF8String);
+        printf("%s\n", [[dict allKeysForObject:value] componentsJoinedByString: @","].UTF8String);
+      }
+    } else {
+      // Print out list in json format.
+      printf("{\n");
+      for (NSString *version in dict) {
+        XcodeVersionEntry *entry = dict[version];
+        printf("\t\"%s\": \"%s\",\n", version.UTF8String, entry.url.fileSystemRepresentation);
+      }
+      printf("}\n");
     }
-    printf("}\n");
     return ([@"" isEqualToString:versionArg] ? 0 : 1);
   }
 }