I am happy to announce that the iOS SDK now offers support for Linux platforms, in addition to the continued support of iOS platforms. We renamed the iOS SDK to Swift SDK to account for this exciting change.

If you used the iOS SDK prior to the renaming, you don’t need to change how you develop with the SDK. One thing that might change is that you could possibly receive this warning:

remote: This repository moved. Please use the new location:
remote:   git@github.com:watson-developer-cloud/swift-sdk.git
To git@github.com:watson-developer-cloud/ios-sdk.git
   44a0f0f..09573dd  your_branch_name -> your_branch_name

In order to dismiss and remove the warning Git returns following any Git changes pushed or pulled to the repository, run the following command within the repository’s directory to update the remote’s name:

  • By SSH: ‘git remote set-url origin git@github.com:watson-developer-cloud/swift-sdk.git’
  • By HTTPS: ‘git remote set-url origin https://github.com/watson-developer-cloud/swift-sdk.git’

You can choose to ignore the warning and continue developing the iOS SDK as before.

Per the Git documentation: “All git clone, git fetch, or git push operations targeting the previous location will continue to function as if made on the new location. However, to reduce confusion, we strongly recommend updating any existing local clones to point to the new repository URL.”

If you want to use Swift with Linux, you need to add the following code to the project’s `Package.swift` file to the project directory:

import PackageDescription                                                                                                                                    

let package = Package(
     name: "app-insights",
     dependencies: [
    	   .Package(url: "https://github.com/watson-developer-cloud/swift-sdk",
             majorVersion: 0)

To build the project, run `swift build` from the command line.

Here is an example of how to use the Conversation service in both Linux and iOS platforms. The code is the same for both platforms:

import ConversationV1
let username = "your-username-here"
let password = "your-password-here"let version = "YYYY-MM-DD" // use today's date for the most recent version
let conversation = Conversation(username: username, password: password, version: version)
let workspaceID = "your-workspace-id-here"
let failure = { (error: Error) in print(error) }
var context: Context? // save context to continue conversation
conversation.message(withWorkspace: workspaceID, failure: failure) { response in
    context = response.context

The following example shows how to continue an existing conversation with the Conversation service:

let text = "Turn on the radio."
let failure = { (error: Error) in print(error) }
let request = MessageRequest(text: text, context: context)
conversation.message(withWorkspace: workspaceID, request: request, failure: failure) {
    response in
    context = response.context

Please note that we currently offer basic support for Linux. Some services are not yet fully supported such as Alchemy Language, Alchemy Data News, Document Conversion, Text to Speech, Speech to Text, and Visual Recognition. However, we are constantly making changes, so stay up-to-date by following the GitHub repo to keep an eye out on our releases and changes!

Looking for inspiration on what to build? Take a look at our Cognitive Concierge app, an iOS app that uses the Conversation, Alchemy API, Speech to Text and Text to Speech services.

Join The Discussion

Your email address will not be published. Required fields are marked *