Search code examples
iosswiftuber-api

Uber API compilation errors


I am installing the Uber API for iOS (Swift). However, I get the following error in the Codeable+Uber.swift file on the below block of code:

Use of undeclared type 'JSONDecoder'

extension JSONDecoder {
    /// JSON Decoder tailored to the Uber API JSON
    public static var uberDecoder: JSONDecoder {
        let decoder = JSONDecoder()
        decoder.dateDecodingStrategy = .secondsSince1970
        return decoder
    }
}

Solution

  • JSONDecoder was added in Swift 4 / Xcode 9.0. You are getting the error because you are using Swift 3 / Xcode 8

    All apps must use Xcode 9 with a Base SDK of iOS 11 starting in July.

    It's best to keep up-to-date at all times.