Oracle by Example brandingQuick Start Tutorial Using an iOS Application

section 0Before You Begin

This 15-minute tutorial shows you how to build an Apple iOS application that simulates a virtual device and sends a message to Oracle Internet of Things (IoT) Cloud Service.

Background

Oracle IoT Cloud Service provides communication services between devices and enterprise applications. In this tutorial, you build a simulated device in an Apple iOS application, and then transmit a Hello World message to Oracle IoT Cloud Service.

What Do You Need?


section 1Install and Configure the Required Software

  1. Download the latest version of the iOS Client Software Library binaries file from the Oracle Technologies Network downloads page.
  2. Open a command-line interface and go to the directory where you downloaded your library.
  3. Extract the iotcs-csl-ios-bin-release.zip file, where release is the release and version number.
    unzip iotcs-csl-ios-bin-release.zip
  4. Verify that your library is extracted under the iotcs/csl/ios/lib directory.

section 2Create Your Virtual Device Project

  1. Open Xcode IDE.
  2. To create a new project, click File, then New, and then Project.
  3. In New Project wizard, select iOS, then Single View Application, and then click Next.
  4. Enter the following values, leave the rest of the fields with the default values, and then click Next:
    • Product Name: IOSHelloWorld
    • Organization Identifier: com.oracle.iot
    Messages table
    Description of the illustration project_details.png
  5. Select the following values and click Create:
    • Source Control: Selected
    • Git Repository: My Mac
  6. In the Embedded Binaries section, click Add, then in the Choose items to add dialog box, click Add Other.
  7. Browse to your iotcs/csl/ios/lib directory, select the following frameworks, and click Open.
    DeviceLib.framework
    Alamofire.framework
    CommonCrypto.framework
    SwiftyJson.framework
    SQLite3Swift.framework
  8. Select the following options and click Finish:
    • Destination: Selected
    • Added folders: Create folder references
    Messages table
    Description of the illustration file_options.png

section 3Configure Your Virtual Device Project

  1. Go to Project Navigator, select iOSHelloWorld, and then General. Verify the list of the following frameworks are listed:
    Embedded Binaries
    • DeviceLib.framework
    • CommonCrypto.framework
    • Alamofire.framework
    • SwiftyJson.framework
    • SQLite3Swift.framework

    Linked Frameworks and Libraries
    • DeviceLib.framework
    • CommonCrypto.framework
    • Alamofire.framework
    • SwiftyJson.framework
    • SQLite3Swift.framework
    • libsqlite3.tbd
  2. To apply a workaround for a known bug, go to the Capabilities tab and set Keychain Sharing to ON.
    Capabilities tab
    Description of the illustration capabilities.png
  3. To set build settings, click Build Settings and then enter FRAMEWORK_SEARCH_PATHS in the Search field.
  4. Double-click in the FRAMEWORK_SEARCH_PATHS field. To add a new value, click +, enter ~/iotcs/csl/ios/lib, and press Enter.
  5. Replace FRAMEWORK_SEARCH_PATHS with SWIFT_INCLUDE in the Search field and press Enter.
  6. Double-click in the SWIFT_INCLUDE field. To add a new value, click +, enter ~/iotcs/csl/ios/lib/IPTools, and press Enter.
  7. Replace SWIFT_INCLUDE with SWIFT_VERSION in the Search field and press Enter.
  8. To set the value to YES, click the No value.
  9. Go to Project Navigator and expand the iOSHelloWorld project. Right-click info.plist, select Open As, then Source Code, and add the content of the info.plist.part file.

    Note: Replace myinstance-myidentitydomain.iot.us.oraclecloud.com with the URL of your Oracle IoT Cloud Service instance.
  10. Go to Project Navigator and click the iOSHelloWorld project. Then from the menu items, select Add Files to "iOSHelloWorld" option, browse to your provisioning file, and click Add.
  11. Verify that your provisioning file is added to your project.
    iOSHelloWorld project
    Description of the illustration ios_project.png

section 4Send your First Message

  1. Go to Project Navigator and expand the iOSHelloWorld project, double-click the ViewController.swift file, and add the content of the ViewController.swift file that you downloaded in the What do you need? section.
    Note: Replace PROVFILE5 and PASSPHRASE6 with the configuration data values you obtained when you completed the Configuring an Application in Oracle Internet of Things Cloud Service tutorial.
  2. To execute your project, click Run, then in the Debugger Output window you see the "Virtual device created" message.
  3. To stop the display of verbose OS debug messages, on the debugger window of Xcode 8.1, go to the Environment Variables section of the scheme and set the OS_ACTIVITY_MODE as disable.

section 5Verify Your Message

  1. Sign in to your Oracle IoT Cloud Service instance.
  2. On the Oracle IoT Cloud Service home page, under Applications, click Oracle IoT Asset Monitoring.
  3. Select Data, and then in Filter By, select Device.
  4. Verify that the Messages table contains your message and review the value of Message Content.
    Messages table
    Description of the illustration messages_table.png

more informationWant to Learn More?