iosswiftibm-watsonalchemyalchemyapi

Swift (iOS) TokenAuthenticationStrategy gives me an unresolved identifier error for AlchemyLanguage API


I get an error unresolved identifier when I try to follow the steps to use AlchemyLanguage iOS API with Swift. I have imported WatsonDeveloperCloud and have the following two lines:

let token = TokenAuthenticationStrategy(token: "myApiKeyGoesHere")
let alchemyLanguageInstance = AlchemyLanguage(tokenAuthenticationStrategy: token)

Solution

  • Here is how to instantiate an AlchemyLanguage object in the most recent version of the Watson Developer Cloud iOS SDK:

    let alchemyLanguage = AlchemyLanguage(apiKey: "<api-key>")
    

    Unfortunately, the readme was not updated to reflect a change in December that renamed the TokenAuthenticationStrategy class to APIKeyAuthenticationStrategy and the AlchemyLanguage(tokenAuthenticationStrategy:) init method to AlchemyLanguage(authStrategy:). I opened an issue to track this problem on the Watson Developer Cloud iOS SDK repository.