Official Release of the IBM Watson SDK for Swift

Anthony Oliveri
Jan 15 · 2 min read
Image source:

After spending a long time in beta, the is now officially released! This SDK provides an easy, intuitive way to integrate into your iOS apps or Swift servers on Linux. Although you can access the Watson APIs with standard REST requests, this SDK abstracts away all of the underlying HTTP infrastructure (including authentication and JSON encoding/decoding), so that you can communicate directly with Watson services in a more “swifty” way.

Here is the that the Swift SDK supports right now.

Setting up and installing

First, that you want to use on the IBM Cloud. For this example, let’s use to understand the emotional and social context of what your users are saying. After you’ve created your service instance, a set of credentials is created for you.

For an iOS app, you can install Tone Analyzer directly with , or install the entire SDK with . For Linux, use .

Configuring

Next, import the service at the top of your source files. The import statement differs depending on which dependency management tool you used.

  • Cocoapods: import ToneAnalyzer
  • Carthage: import IBMWatsonToneAnalyzerV3
  • Swift Package Manager: import ToneAnalyzerV3

Now, create an instance of the service you want to use:

Substitute the values for myApiKey and toneAnalyzer.serviceURL using the API Key and URL obtained from the service instance you created (see the earlier screenshot for reference). The version parameter specifies the minor version of the backend API, which is explained further in the .

Using the APIs

Now comes the fun part! You can use the instance of the Watson service created in the previous step to call any of the . Let’s use our ToneAnalyzer service to see how customers are feeling based on text they use within the app.

This example uses simple print statements, but you can use that information however you see fit for your business. All of the APIs are , so you can easily discover what kind of information is available to you.


The IBM Watson Swift SDK is open source and , so feel free to view the documentation and source code, open issues, submit feature requests, or even make improvements of your own via pull requests!

IBM Watson

AI Platform for the Enterprise

Anthony Oliveri

Written by

Software Engineer at IBM

IBM Watson

AI Platform for the Enterprise