简体   繁体   中英

'Currency' is only available in iOS 16 or newer?

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
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM