iOS SDK API for NSLocale makes old properties inaccessible to iOS 8 & 9

Number:rdar://28363526 Date Originated:2016-09-19
Status:Closed Resolved:
Product:iOS SDK Product Version:
Classification:Serious Bug Reproducible:Always
The compiler (tested with Swift 2.3) complains about using NSLocale properties when deploying to iOS 8/9 even though the same property names were available before.

Steps to Reproduce:

// Create target to deploy to iOS 8.x or 9.x
import Foundation
// here the compiler will complain:
let symbol = NSLocale.autoupdatingCurrentLocale().currencySymbol

Expected Results:
Upgrading to Swift 2.3 would continue to work. Maybe a few adjustments here and there.

Actual Results:
The compiler informs me that currencyCode and others are marked as available for iOS 10+ only and that my code has to take this into account. 

The thing is: since this is a runtime switch and not a compile time switch, I cannot compile with the new SDK for the old version; I have to provide an alternative code path for devices running iOS 8/9. But the only alternative is to use the property with the same name. Only the compiler won't allow.

iOS 8.1


Xcode 8.0



Response by Apple

Engineering has determined that this issue behaves as intended based on the following information:

These properties are new in iOS 10, and you could add equivalent properties for older OSes using an extension like the one shown below:

currencyCode was an API that was added in iOS 10; it cannot be back-deployed safely since it did not exist before iOS 10.

It is effectively a wrapper around -[NSLocale objectForKey:NSLocaleCurrencySymbol] which returns a type safe return value.

So, you could have an extension of:

extension NSLocale { var compatabilityCurrencySymbol: String? { return objectForKey(NSLocaleCurrencySymbol) as? String } }

By christian.tietze at Sept. 27, 2016, 7:58 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!