This project contains a simple application that demonstrates how to setup & integrate the IBM Watson iOS SDK (beta) into your iOS applications.
The IBM Watson iOS SDK (beta) helps simplify integration with many of the Watson Developer Cloud services, including the IBM Watson Dialog, Language Translation, Natural Language Classifier, Personality Insights, Speech To Text, Text to Speech, Alchemy Language, or Alchemy Vision services – all of which are available today, and can now be integrated with just a few lines of code.
In order to take advantage of the IBM Watson iOS SDK (beta), you must first setup IBM Watson services on Bluemix that the mobile SDK will leverage.
This sample app is leveraging the IBM Watson Language Translation service
- Head over to IBM Bluemix and create a new application. Choose the runtime for Node.js as your base.
- Next you need to add the Watson Language Translation Service to the app you just created. From the app dashboard, select "Add Service or API" and add the Language Translation Service to your app.
Next you need to get download the IBM Watson iOS SDK (beta). You can either download it directly as a zip file, or you can clone the git repository to your local machine. Follow installation instructions to compile the SDK for use on your own machine.
Now we need to pull the SDK into the app so we can start integrating Watson services.
- Download or clone the contents of this repo to your local machine.
- Open the Translator.xcodeproj project file in Xcode.
- Drag the WatsonDeveloperCloud.xcodeproj from the SDK you just downloaded into the Xcode project navigator (left side bar).
- You will be prompted to create a workspace. Do it.
- Compile the WatsonDeveloperCloud target
- Update the "Translator" target and add a link to the WatsonDeveloperCloud.framework
- Next, Compile and run the Translator project to launch it in the iOS Simulator
Integration of Watson services is as simple as creating an instance of the service class you want to use, then calling the methods that are exposed through the IBM Watson iOS SDK (beta).
For example, the entire sample app code inside of ViewController.swift is less than 100 lines of code, and most of that is even whitespace.
Integration of the IBM Watson Language Translation service is shown below:
let translation = LanguageTranslation(username:"your username", password: "your password")
translation.translate([inputText!], source: "en", target: model.target!) { text, error in
let translation = text![0]
print(translation)
}
Feel free to explore this project, and be sure to explore the IBM Watson iOS SDK (beta).