This document describes how to quickly integrate the TRTC iOS SDK into your project.
You can use CocoaPods to automatically load the SDK or download and import it manually into your project.
Enter the following command in a terminal window (you need to install Ruby on your Mac first):
sudo gem install cocoapods
Go to the directory of your project and enter the following command to create a Podfile in the directory.
Edit the Podfile and select an SDK edition based on your needs:
TRTC Lite: This edition has the smallest installation package, but integrates only TRTC and CDN playback (TXLivePlayer) features.
platform :ios, '8.0' target 'App' do pod 'TXLiteAVSDK_TRTC', :podspec => 'https://liteav.sdk.qcloud.com/pod/liteavsdkspec/TXLiteAVSDK_TRTC.podspec' end
TRTC Professional:This edition integrates RTMP push (TXLivePusher), CDN playback (TXLivePlayer), VOD playback (TXVodPlayer), short video (UGSV), and other features.
platform :ios, '8.0' target 'App' do pod 'TXLiteAVSDK_Professional', :podspec => 'https://liteav.sdk.qcloud.com/pod/liteavsdkspec/TXLiteAVSDK_Professional.podspec' end
You can use the official CocoaPods source, but the download may be slow:
platform :ios, '8.0' source 'https://github.com/CocoaPods/Specs.git' target 'App' do pod 'TXLiteAVSDK_TRTC' end
Enter the following command in a terminal window to update the local repository and install the SDK:
Or, run this command to update the local repository:
An XCWORKSPACE project file integrated with the TRTC SDK will be generated. Double-click to open it.
You need to manually add the dependent library Accelerate.framework.
TXLiteAVSDK_TRTC.framework: TXFFmpeg.xcframework and TXSoundTouch.xcframework. Click Embed & Sign.
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. Their content is what users see in the mic and camera access pop-up windows.
You can import the TRTC SDK in two ways.
There are two ways to use the SDK in Objective-C or Swift:
Import the module: Import the SDK module in the files that will use the SDK APIs.
Import the header file: Import the header file in the files that will use the SDK APIs.
Import the header file: If you want to use C++ APIs to develop your iOS application, import the header file in the
Use the namespace: The cross-platform C++ methods and types are all defined in the TRTC namespace, which you can use directly. This method can simplify your code and is recommended.
using namespace trtc;
For more information on how to use C++ APIs, see Overview.
Yes. If you want the SDK to run in the background, select your project, under the Capabilities tab, toggle on Background Modes, and select Audio, AirPlay, and Picture in Picture.