From 34798f94b1acac52ecf6c5deefc7bccc21daaff1 Mon Sep 17 00:00:00 2001 From: Robert Sayre Date: Tue, 16 Apr 2019 11:22:15 -0700 Subject: [PATCH 1/2] Conditionally use deprecated signature for NSDictionary:initWithContentsOfURL --- tools/osx/xcode_locator.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/osx/xcode_locator.m b/tools/osx/xcode_locator.m index 71b0b1427bf2be..78262eae96e9c8 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]; From 804e9eb3b0acf1d9ee79cbf5cd579e48ca316377 Mon Sep 17 00:00:00 2001 From: Robert Sayre Date: Wed, 17 Apr 2019 14:44:26 -0700 Subject: [PATCH 2/2] Fix formatting. --- tools/osx/xcode_locator.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/osx/xcode_locator.m b/tools/osx/xcode_locator.m index 78262eae96e9c8..7ab878a88e5cd1 100644 --- a/tools/osx/xcode_locator.m +++ b/tools/osx/xcode_locator.m @@ -182,7 +182,8 @@ static void AddEntryToDictionary( // 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]; + versionPlistContents = [[NSDictionary alloc] initWithContentsOfURL:versionPlistUrl + error:nil]; #else versionPlistContents = [[NSDictionary alloc] initWithContentsOfURL:versionPlistUrl]; #endif