Install Carthage and add the Watson SDK to your project
Install the Carthage dependency manager.
Use the Carthage dependency manager to install libraries that are used by your application. You can install Carthage from GitHub or use Homebrew to update it only if you use Xcode 7.x.
Important: If you previously installed the binary version of Carthage, you must delete /Library/Frameworks/CarthageKit.framework.
- To install Carthage from GitHub, download and run the latest release of the Carthage.pkg file: https://github.com/Carthage/Carthage/releases. Then follow the installation prompts.
- To install Carthage by using Homebrew (only on Xcode 7.x), run the commands
brew install Carthage.
If you want to run the latest development version of Carthage, which might be highly unstable or incompatible, clone the master branch of the repository and then run the command
Important: If you have two-factor authentication, Carthage requires an OTP header.
Add the Watson SDK to your project
- Open a Bash shell in the root directory of your project.
cat > cartfile
- Enter a new line. Then, press control + C to exit Edit mode.
- From the command line at the root of the project, run the command
carthage update --platform iOS. If you receive a compile failure for the framework AlamofireObjectMapper, run the command again.
The following image shows output from the package manager as it fetches and builds iOS library components:
Add the SDK to the Xcode project:
- Under the project name, create a new group in your Xcode project called
- Navigate to the root folder of your project in Xcode and select all the framework files in the /Carthage/Build/iOS/ directory of your project (AlchemyLanguageV1.framework, Alamofire, Freddy, RestKit, Starscream). Drag and drop those files from Finder into the new
Frameworkgroup in your project in Xcode.
Be sure you clear the option to copy items. By not copying the items, you create only a reference to those Framework files.
- In the Build Phases tab, add a new Copy Files phase and set its destination to
- For the frameworks that were added by Carthage, copy each framework individually. These are the files that you copy:
- Whitelist your calls to Watson services and remove the security for watsonplatform.net. Whitelisting allows only specified addresses to get through without the SSL protocol.
To do this, use either Xcode to add exceptions as shown in the following image or add the XML snippets below to your info.plist file:
Whitelist the calls in Xcode:
Whitelist the calls by copying the following XML to the info.plist file: