English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Fast Integration

Last Updated on : 2022-01-07 07:03:31

This topic describes how to quickly integrate Tuya Industry App SDK for iOS into your development environment, such as Xcode. It also sheds light on the initialization method and how to enable the debugging mode with a few simple steps. This allows you to run the demo app and get started with your app development by using the Industry App SDK.

Prerequisites

  1. Before you start, make sure that you have registered an account and downloaded the SDK. For more information, see Preparation.
  2. The following software is installed:
    • Xcode 12.0 or later
    • CocoaPods 1.10.0 or later
  3. Your project must be targeted to iOS 10.0 or later.

Integrate the SDK

Step 1: Create an iOS project

Create a project in Xcode.

Step 2: Import the SDK

  1. (Optional) If you have not created the Podfile, create one.

    $ cd your-project-directory
    
    $ pod init
    
  2. In the Podfile, add the Industry App SDK and source.

    source 'https://cdn.cocoapods.org/'
    source 'https://github.com/TuyaInc/TuyaPublicSpecs.git'
    
    target 'your-project' do
    pod 'TuyaIoTAppSDK'
    end
    
  3. Install a pod, open the .xcworkspace file, and then view the project in Xcode.

    $ pod install
    
    $ open your-project.xcworkspace
    
  4. Import the SDK.

    Swift:

    import TuyaIoTAppSDK
    

    Objective-C:

    #import <TuyaIoTAppSDK/TuyaIoTAppSDK-Swift.h>
    

The Industry App SDK is a closed-source Swift library. To use this library in a pure Objective-C project, you must add an empty Swift file in your project. Xcode will ask you whether to create a bridging header file. Choose to create it.

Step 3: Initialize the SDK

In AppDelegate.swift, add the following code block to didFinishLaunchingWithOptions:

TYSDK.initialize(clientID: "YourClientID",
					clientSecret: "YourClientSecret",
					hostRegion: .US)

In this code block, the values of clientID and clientSecret can be obtained from the Authorization Key field that is used when you create the application.