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.

  1. 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.
  2. To install Carthage by using Homebrew (only on Xcode 7.x), run the commands brew update and 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 make install.

Install the Watson SDK:

  1. Open a Bash shell in the root directory of your project.
  2. Enter cat > cartfile
  3. Enter github "watson-developer-cloud/ios-sdk”
  4. Enter a new line. Then, press control + C to exit Edit mode.
  5. 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:

    1. Under the project name, create a new group in your Xcode project called

Framework

    .

  1. 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 Framework group 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:
  2. In the Build Phases tab, add a new Copy Files phase and set its destination to Frameworks.
  3. For the frameworks that were added by Carthage, copy each framework individually. These are the files that you copy:
  4. 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:

    <key>NSAppTransportSecurity</key>
    <dict>
    <key>NSExceptionDomains/key>
    <dict>
    <key>watsonplatform.net/key>
    <dict>
    <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
    <false/>
    <key>NSIncludesSubdomains</key>
    <true/>
    <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
    <true/>
    </dict>
    </dict>
    </dict>