kylef / JSONWebToken.swift

Swift implementation of JSON Web Token (JWT).
http://jwt.io
BSD 2-Clause "Simplified" License
763 stars 226 forks source link

Ambiguous reference to member 'encode(claims:algorithm:headers:) #101

Closed SwiftExpert closed 6 years ago

SwiftExpert commented 6 years ago

Hi. when im using encode function i get this error: Ambiguous reference to member 'encode(claims:algorithm:headers:)'

Swift version issue i guess? are you planning to upload a new version?

screen shot 2018-01-31 at 10 49 09 am

kylef commented 6 years ago

I think it could be that it is treating the dictionary as [String: String] where the encode method expects [String: Any]. Does casting this possible help?

["email": ""] as [String: Any]
SwiftExpert commented 6 years ago

Tried doing it, didnt help. but figured it out. i needed to unwrap "secret".data(using: .utf8)" it returns an optional Data object. though i don't know how the error("Ambiguous reference") relates to it...

rickrizzo commented 6 years ago

Had this error too. It'd be great if the README were updated to reflect this fix