diff --git a/tools/osx/xcode_locator.m b/tools/osx/xcode_locator.m index 71b0b1427bf2be..90c00fafcc5b74 100644 --- a/tools/osx/xcode_locator.m +++ b/tools/osx/xcode_locator.m @@ -177,8 +177,16 @@ static void AddEntryToDictionary( url, version, expandedVersion); NSURL *versionPlistUrl = [url URLByAppendingPathComponent:@"Contents/version.plist"]; - NSDictionary *versionPlistContents = [[NSDictionary alloc] initWithContentsOfURL:versionPlistUrl - error:nil]; + + // macOS 10.13 changed the signature of initWithContentsOfURL, + // and deprecated the old one. + NSDictionary *versionPlistContents; +#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 + versionPlistContents = [[NSDictionary alloc] initWithContentsOfURL:versionPlistUrl error:nil]; +#else + versionPlistContents = [[NSDictionary alloc] initWithContentsOfURL:versionPlistUrl]; +#endif + NSString *productVersion = [versionPlistContents objectForKey:@"ProductBuildVersion"]; if (productVersion) { expandedVersion = [expandedVersion stringByAppendingFormat:@".%@", productVersion];