Install Carthage and add the Watson SDK to your project
As in the previous two labs, you must again install the Carthage dependency manager, the SDK, and then add that SDK to your Xcode project.
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 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
Install the Watson SDK:
- 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 frameworks, 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 (TextToSpeechV1.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.
This is the list of the framework libraries:
- 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: