Search code examples
iosswiftlyft-api

Syntax errors in Lyft API for iOS - won't compile?


I am trying to use the Lyft API for iOS with Swift 4 and Xcode 9.3.

When I use the pod LyftSDK, the framework files do not compile per this issue, which I fixed (but it seemed bizarre that a major API would not compile in a production build). It's currently an open issue on the Lyft-iOS-SDK GitHub, #17. I'm also using the pod Lyft because I was unsure of which to use.

In my view controller, I've imported: import Lyft import LyftSDK

But then when I go to use let lyftButton = LyftButton() I get the compilation error Use of unresolved identifier 'LyftButton'.

How do I use this API with Swift? Do I need both pods for it to work? I'm following the documentation line for line and can't get it to work how it's supposed to. None of the other APIs and CocoaPods I'm using have this issue.


Solution

  • I solved this by doing the following:

    In LyftSDK/Core/LyftButton.swift, change Line 47 from private var pressUpAction: ((Void) -> Void)? to private var pressUpAction: (() -> Void)?.

    In LyftSDK/Core/LyftAPIURLEncoding.swift, replace Line 32 with:

    var localVariable = urlComponents 
    urlComponents?.queryItems = (localVariable?.queryItems ?? []) + queryItems