Last updated: 2021-09-13 15:45:11

    This document describes how to quickly integrate LiteAVSDK for iOS into your project. The directions below use the full-featured MLVB Professional Edition as an example.

    Environment Requirements

    • Xcode 9.0 or above
    • iPhone or iPad with iOS 9.0 or above
    • A valid developer signature for your project

    Integrating the SDK

    You can use CocoaPods to automatically load the SDK or manually download the SDK and import it into your project.

    CocoaPods

    1. Install CocoaPods

    Enter the following command in a terminal window (you need to install Ruby on your macOS first):

    sudo gem install cocoapods
    

    2. Create a Podfile

    Go to the directory of your project and enter the following command to create a Podfile in the directory.

    pod init
    

    3. Edit the Podfile

    There are two ways to edit the Podfile:

    • Method 1: use the path of the PODSPEC file of LiteAVSDK
      platform :ios, '9.0'

      target 'App' do
      pod 'TXLiteAVSDK_Professional', :podspec => 'https://liteav.sdk.qcloud.com/pod/liteavsdkspec/TXLiteAVSDK_Professional.podspec'
      end
    • Method 2: use CocoaPod’s official source, which allows version selection

    4. Update the local repository and install the SDK

    Enter the following command in a terminal window to update the local repository file and install LiteAVSDK:

    pod install
    

    Or, run the following command to update the local repository:

    pod update
    

    An XCWORKSPACE project file integrated with LiteAVSDK will be generated. Double-click to open the file.

    Manual integration

    1. Download LiveAVSDK and decompress the file.
    2. Open your Xcode project, select the target you want to run, and select Build Phases.
    3. Expand Link Binary with Libraries and click + at the bottom to add the libraries to depend on.
    4. Add the downloaded TXLiteAVSDK_Professional.framework and the libraries it depends on.
      libz.tbd
      libc++.tbd
      libresolv.tbd
      libsqlite3.tbd
      Accelerate.framework
      OpenAL.framework
      
    5. Click Build Settings, search for Other Linker Flags, and add -ObjC.

    Granting Camera and Mic Permissions

    To use the audio/video features of the SDK, you need to grant it mic and camera permissions. Add the two items below to Info.plist of your application to display pop-up messages asking for mic and camera permissions.

    • Privacy - Microphone Usage Description, plus a statement specifying why mic access is needed
    • Privacy - Camera Usage Description, plus a statement specifying why camera access is needed

    Importing the SDK

    There are two ways to import the SDK in your project code.

    • Method 1: import the SDK module in the files that need to use the SDK’s APIs in your project
      @import TXLiteAVSDK_Professional;
      
    • Method 2: import a specific header file in the files that need to use the SDK’s APIs in your project
      #import "TXLiteAVSDK_Professional/TXLiteAVSDK.h"
      

    Configuring License

    Click Get License to obtain a trial license. You will get two strings: a license URL and a decryption key.

    Before you use LiteAVSDK features in your application, complete the following configurations (preferably in - [AppDelegate application:didFinishLaunchingWithOptions:]):

    @import TXLiteAVSDK_Professional;
    @implementation AppDelegate
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      NSString * const licenceURL = @"<The license URL obtained>";
      NSString * const licenceKey = @"<The key obtained>";
    
      //TXLiveBase can be found in the "TXLiveBase.h" header file
      [TXLiveBase setLicenceURL:licenceURL key:licenceKey]; 
      NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]);
    }
    @end
    

    FAQs

    Can I run LiteAVSDK in the background?

    Yes, you can. If you want the SDK to run in the background, select your project, under the Capabilities tab, set Background Modes to ON, and check Audio, AirPlay and Picture in Picture, as shown below: