Moya: Cannot use optional chaining on non-optional value of type 'NSURL'

Created on 15 Sep 2016  路  13Comments  路  Source: Moya/Moya

Just updated from 7.0.0 to 7.0.2 and received an error in:

public extension MoyaProvider {

    public final class func DefaultEndpointMapping(target: Target) -> Endpoint<Target> {
        guard let stringURL = target.baseURL.URLByAppendingPathComponent(target.path)?.absoluteString  else {
            fatalError("\(target) url is not valid")
        }
        return Endpoint(URL: stringURL, sampleResponseClosure: {.NetworkResponse(200, target.sampleData)}, method: target.method, parameters: target.parameters)
    }
}

URLByAppendingPathComponent is non-optional, but there is a "?".
What am I doing wrong? :)

question

Most helpful comment

@Denis1992 please use specific Moya version, like:

pod 'Moya', '7.0.0'

All 13 comments

I think you are still using Swift 2.2, correct? 7.0.2 is a Swift 2.3 release (in which URLByAppendingPathComponent _is_ optional. :)

So what should i do to fix that ? @BasThomas

Use 7.0.0 on Swift 2.2 instead, upgrading to 7.0.2 once you switch to Swift 2.3 :)

Hi,
pod 'Moya', '~> 7.0.0'
pod install
Using Moya (7.0.2)

Drop to 6.5.0 working
O_o

I think you did a pod update before? I don't think pod install automatically downgrades to the specific pod version. You should be able to update to 7.0.0 again now, I think?

No,
pod 'Moya', '~> 7.0.0'
pod update
Installing Moya 7.0.2 (was 6.5.0)

@Denis1992 please use specific Moya version, like:

pod 'Moya', '7.0.0'

@sunshinejr thx.

Fixed now? ^^

@BasThomas yep, thx for answer :)

馃檶

README needs to be updated...

screen shot 2016-10-13 at 4 58 40 pm

You are right @v-ken, it should be fixed now. Thanks for mentioning! 馃檱

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tynox picture Tynox  路  3Comments

mwawrusch picture mwawrusch  路  3Comments

holysin picture holysin  路  3Comments

pedrovereza picture pedrovereza  路  3Comments

sunshinejr picture sunshinejr  路  3Comments