Home > database >  'Currency' is only available in iOS 16 or newer?
'Currency' is only available in iOS 16 or newer?

Time:09-20

After updating Xcode to 14 suddenly I'm unable to build our app, getting the error

'Currency' is only available in iOS 16 or newer

but we've been using Currency already as our backend model:

struct Currency: Equatable {
    let code: String
    let symbol: String
    let localizedString: String
}

We getting the error when using Currency here:

extension Locale {
    static let availableCurrencies: [Currency] = Currency.availableCurrencies
}

CodePudding user response:

The reason why the error is newly displaying in xcode 14 is, that Apple added their own struct Currency to Foundation which is only available in iOS 16. In some places it cannot determine which Currency you mean.

In our soulution we just renamed our struct Currency to struct CurrenyModel to resolve the naming conflict. You can use F2 (or Right Click -> Refactor -> Rename) when the name is selected to rename all references at once.

  • Related