tencent cloud

Tencent Real-Time Communication

iOS

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-11-17 20:43:11
TUIRoomKit is a comprehensive multi-party audio and video conferencing solution built on TRTC. It provides a complete set of UI components along with all the core functionality you need to get up and running quickly.
This documentation walks you through integrating TUIRoomKit into your project to enable reliable multi-party audio/video conferencing. You'll also find step-by-step guides for customizing image assets, localizing UI text, and configuring other options—everything you need to build audio/video experiences that align with your brand.
Room Preparation Page
Room Main Page
Member Management










Prerequisites

Activate the Service

To activate TUIRoomKit and obtain your trial version, follow the instructions at Activate the Service. You will need your SDKAppID and SDKSecretKey:
SDKAppID: Required application identifier. Tencent Cloud uses SDKAppID for billing and analytics.
SDKSecretKey: Application secret key for initializing configuration file secret information.

Environment Setup

SwiftPM integration requires Xcode 16+ / iOS 14.0+.
CocoaPods integration requires Xcode 15+ / iOS 14.0+.
For CocoaPods, make sure CocoaPods is installed.

Quick Integration

Step 1: Import SDK

Swift Package Manager Integration
CocoaPods Integration
1. In Xcode, navigate to File > Add Package Dependencies.... Paste the following URL into the search box, wait for results, then click Add Package.
https://github.com/Tencent-RTC/RoomKit_SwiftPM.git
2. In Choose Package Options ,select the desired released version. See Apple Official Documentation for version selection rules.
3. Add TUIRoomKit to your App Target. If you use the sample code in this guide, also add the resolved dependencies AtomicXCore and SnapKit to your Target's Frameworks, Libraries, and Embedded Content. No need to add the repository again.
Note:
SwiftPM integration requires Xcode 16 or higher. See above for environment requirements.
1. Run the following command in your terminal to install CocoaPods. Skip this step if CocoaPods is already installed.
sudo gem install cocoapods
2. In your project root directory, run pod init to create a Podfile. Edit and save it as follows:
platform :ios, '14.0'

# Change 'App' to your project's name
target 'App' do
pod 'AtomicXCore', :podspec => 'https://sdk-liteav-1252463788.cos.ap-hongkong.myqcloud.com/app/tuikit/download/latest/AtomicXCore.podspec'
# Official default version address
pod 'TUIRoomKit', :podspec => 'https://sdk-liteav-1252463788.cos.ap-hongkong.myqcloud.com/app/tuikit/download/latest/TUIRoomKit.podspec'
end
3. Run the following command in your terminal to install the SDK.
pod install
Note:
Be sure to include the external podspec for AtomicXCore; other dependencies are resolved automatically by CocoaPods. After installation, open the .xcworkspace project. The two default version addresses updatndependently. For production, use the paired versioned addresses as described in the FAQs.
Choose only one integration method to avoid duplicate SDK imports. Available SwiftPM versions are listed at RoomKit_SwiftPM Tags. API examples in this guide are based on your selected version.

Step 2: Configure the Project

To enable audio/video features, your app must request microphone and camera permissions. Add the following keys and usage descriptions to your Info.plist file. These descriptions will be displayed when the system prompts users for permission:
<key>NSCameraUsageDescription</key>
<string>TUIRoomKit requires access to your camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>TUIRoomKit requires access to your microphone</string>




Step 3: Log In

After integrating the code, complete the login process. This step is required to use TUIRoomKit. You must log in successfully before accessing any features. Verify that all parameters are correctly configured:
Note:
In the sample code, login is handled in the didFinishLaunchingWithOptions method. In real-world projects, call the AtomicXCore login service only after your own user authentication and login procedures have completed. This prevents business logic conflicts and ensures seamless integration with your user management and permission systems.
import AtomicXCore

// AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LoginStore.shared.login(sdkAppID: 1400000001, // Replace with your sdkAppID
userID: "test_001", // Replace with your userID
userSig: "xxxxxxxxxxx") { result in // Replace with your userSig
switch result {
case .success(let info):
debugPrint("login success")
case .failure(let error):
debugPrint("login failed code:\\(error.code), message:\\(error.message)")
}
}
return true
}
Login API Parameter Details:
Parameter
Type
Description
sdkAppID
Int32
userID
String
Unique user identifier. Use only English letters, numbers, hyphens, and underscores. Avoid using simple IDs like 1 or 123 to prevent multi-device login conflicts.
userSig
String
Authentication ticket for Tencent Cloud.
For development: Use GenerateTestUserSig.genTestSig or the UserSig Assistant Tool for a temporary UserSig.
For production: Always generate UserSig server-side to prevent secret key leaks. See Calculating UserSig on the Server.
For more details, see How to Calculate and Use UserSig.

Step 4: Set Avatar and Nickname

If a user logs in for the first time without avatar or nickname info, use the setSelfInfo API from LoginStore to set their profile:
import AtomicXCore

func setSelfInfo() {
let userProfile = UserProfile(userID: "test_001", // Your logged-in userID
nickname: "tom", // Set nickname
avatarURL: "http://xxx.png") // Set avatar URL
LoginStore.shared.setSelfInfo(userProfile: userProfile) { result in
switch result {
case .success():
debugPrint("setSelfInfo success")
case .failure(let error):
debugPrint("setSelfInfo failed code:\\(error.code), message:\\(error.message)")
}
}
}
setSelfInfo API Parameter Details:
Parameter
Type
Required
Description
userProfile
UserProfile
Yes
Main user info model:
userID: User ID to set.
nickname: Nickname.
avatarURL: Avatar URL.
completion
CompletionClosure
No
Callback for the result of setting user info. Returns error code and message if failed.

Step 5: Create a Room

MeetingView is the primary interface in TUIRoomKit for multi-party audio/video conferencing. The following example shows how to integrate MeetingView as a room owner.

Implementation

1.
Conform to the Routing Navigation Protocol: TUIRoomKit uses the RouterContext protocol to manage page navigation. The host view controller must implement this protocol to handle internal navigation actions such as ending a room or returning to a previous page.
2. Lazy Load the View: Instantiate MeetingView lazily in your controller and set its routerContext property so it can invoke navigation methods via the protocol.
3.
Configure Room Entry Settings: Specify whether to automatically enable audio/video devices on entering the room.
4. Initialize the Room Main Page: Initialize MeetingView as a room owner.
5. Add the View to Your Controller: In viewDidLoad, add MeetingView to your view hierarchy and use constraints to fill the controller's view.
Note:
TUIRoomKit's internal navigation is based on standard UINavigationController methods (push/pop). Ensure your view controller is either the root controller of a UINavigationController or part of its stack. If not, SDK navigation will fail due to the absence of a valid navigation context, resulting in page switching issues.

Sample Code

import UIKit
import TUIRoomKit
import SnapKit
import AtomicXCore

// YourMainViewController loads the room main page

// 1. YourMainViewController must conform to RouterContext in TUIRoomKit
class YourMainViewController: UIViewController, RouterContext {
// 2. Lazy load MeetingView from TUIRoomKit
private lazy var meetingView: MeetingView = {
// 3. Configure room entry settings
var config = RoomConnectConfig()
config.autoEnableCamera = true // Automatically enable camera
config.autoEnableMicrophone = true // Automatically enable microphone
config.autoEnableSpeaker = true // Automatically enable speaker
// 4. Initialize room main page as owner
var options = CreateRoomOptions()
options.roomName = "roomName" // Set room name
let view = MeetingView(roomID: "roomID", behavior: .createAndJoinRoom(options: options), config: config)
view.routerContext = self
return view
}()
public override func viewDidLoad() {
super.viewDidLoad()
// 5. Add MeetingView to the view controller
view.addSubview(meetingView)
meetingView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}

MeetingView Constructor Parameter Details:

Parameter
Type
Description
roomID
String
Unique room identifier.
Length: 0–48 bytes.
Use only numbers, letters (case-sensitive), underscores (_), and hyphens (-). Avoid spaces and Chinese characters.
behavior
RoomBehavior
Initialization source:
createAndJoinRoom: Room owner creates the room. Requires room creation options. See CreateRoomOptions Struct Details.
join: Participant joins the room.
config
RoomConnectConfig
Audio/video device control configuration after entering the room.

RoomConnectConfig Parameter Details:

Parameter
Type
Description
autoEnableMicrophone
Bool
Automatically enable microphone on room entry.
true: Enable automatically (default).
false: Do not enable automatically.
autoEnableCamera
Bool
Automatically enable camera on room entry.
true: Enable automatically (default).
false: Do not enable automatically.
autoEnableSpeaker
Bool
Automatically enable speaker on room entry.
true: Enable automatically (default).
false: Do not enable automatically.
CreateRoomOptions Struct
Parameter Name
Type
Required
Description
roomName
String
No
Room name (optional, defaults to empty string).
Limit: 0-60 bytes.
Supports English, Chinese, numbers, special characters.
password
String
No
Room password. Empty string "" means no password.
Limit: 0-32 bytes.
Recommend using 4-8 digits for easy mobile input. If set, other users must enter the password to join. Avoid storing plaintext sensitive information.
isAllMicrophoneDisabled
Bool
No
Disable microphones for all members. When enabled, only host/admin can unmute; regular participants are muted by default.
true: Disabled.
false: Not disabled (default).
isAllCameraDisabled
Bool
No
Disable cameras for all members. When enabled, only host/admin can enable cameras; regular participants are disabled by default.
true: Disabled.
false: Not disabled (default).
isAllScreenShareDisabled
Bool
No
Disable screen sharing for all members. When enabled, only host/admin can share screen.
true: Disabled.
false: Not disabled (default).
isAllMessageDisabled
Bool
No
Disable chat messages for all members (mute). When enabled, regular participants cannot send text messages in the room.
true: Disabled.
false: Not disabled (default).

Step 6: Join a Room

The following example shows how to embed MeetingView for joining as a participant.

Implementation

1.
Conform to the Routing Navigation Protocol: Implement the RouterContext protocol in your controller.
2. Lazy Load the View: Instantiate MeetingView and set its routerContext.
3.
Configure Room Entry Settings: Specify audio/video device preferences.
4.
Initialize the Room Main Page: Initialize as a participant.
5. Add the View to Your Controller: Add MeetingView and set constraints.

Sample Code

import UIKit
import TUIRoomKit
import SnapKit
import AtomicXCore
// YourMainViewController loads the room main page

// 1. YourMainViewController must conform to RouterContext in TUIRoomKit
class YourMainViewController: UIViewController, RouterContext {
// 2. Lazy load MeetingView from TUIRoomKit
private lazy var meetingView: MeetingView = {
// 3. Configure room entry settings
var config = RoomConnectConfig()
config.autoEnableCamera = true // Automatically enable camera
config.autoEnableMicrophone = true // Automatically enable microphone
config.autoEnableSpeaker = true // Automatically enable speaker
// 4. Initialize room main page as participant
let view = MeetingView(roomID: "roomID", behavior: .join, config: config)
view.routerContext = self
return view
}()
public override func viewDidLoad() {
super.viewDidLoad()
// 5. Add MeetingView to the view controller
view.addSubview(meetingView)
meetingView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}

Core Features

Once you've integrated MeetingView, your application will offer a full-featured multi-party audio/video conference interface, including member management, device controls, room information display, and more. This is the central functionality of TUIRoomKit.




Customize UI

Note:
Do not modify dependency caches directly, as changes may be overwritten when dependencies are re-downloaded. For SwiftPM customization, clone or fork RoomKit_SwiftPM and use a local package. For CocoaPods customization, use the component source directory containing TUIRoomKit.podspec and import via :path. The SwiftPM wrapper repository cannot be used directly as a CocoaPods local dependency.
The MeetingView main page is highly customizable. You can modify the UI to fit your product requirements and interaction scenarios. The following overview details the view components within MeetingView to help you make quick adjustments.



Component Overview for MeetingView
Component
Feature Description
Customization Suggestions
Main room container, coordinates layout and data among subcomponents.
Adjust background, safe area handling, component visibility logic.
Top navigation bar with room info, camera/audio controls, and exit button.
Replace icons, tweak background transparency, add custom buttons (e.g., recording, window mode).
RoomView
Video stream area, waterfall layout for multiple users.
Change layout (rows, columns, spacing), customize page indicator, design empty state views.
User video cell with screen and basic info.
Customize video rendering, user info (avatar, badge), add interactive controls (voice waveform).
Bottom toolbar for microphone, camera, and member management.
Rearrange buttons, modify styles (color, size), add business features (screen sharing, in-meeting call, beauty filter).

Customize Icons

After integrating TUIRoomKit, you can directly replace icon assets in the component to better match your UI and business needs.
TUIRoomKit manages UI image resources in TUIRoomKitIcons.xcassets. Use Xcode's graphical tools to quickly modify custom icons.



Common Icon Files
Icon
Filename
Description



roomkit_icon_camera_off.svg
Camera off icon.



roomkit_icon_camera.svg
Camera on icon.



roomkit_icon_microphone_off.svg
Microphone off icon.



roomkit_icon_microphone.svg
Microphone on icon.



roomkit_icon_screen_share.svg
Room owner badge icon.

Customize Texts

TUIRoomKit uses the Apple Strings Catalog tool to manage UI text. You can easily adjust text using Xcode's visual tools.
Note:
The Apple Strings Catalog (.xcstrings) format, introduced in Xcode 15, streamlines localization management. It supports structured formats for plurals, device-specific variants, and more, and is now the recommended localization approach for iOS and macOS apps.




FAQs

How to lock a version?

SwiftPM: In Xcode's Package Dependencies, select the released version and use Exact Version to lock the version.
External Pods: Replace the two default addresses with paired versioned podspec addresses. ROOM_VERSION and CORE_VERSION are component versions; ROOM_MAJOR_MINOR and CORE_MAJOR_MINOR are the first two segments of each version number. Replace accordingly; do not assume both components share the same version number.
pod 'AtomicXCore', :podspec => 'https://sdk-liteav-1252463788.cos.ap-hongkong.myqcloud.com/app/tuikit/download/release/CORE_MAJOR_MINOR/AtomicXCore_CORE_VERSION.podspec'
pod 'TUIRoomKit', :podspec => 'https://sdk-liteav-1252463788.cos.ap-hongkong.myqcloud.com/app/tuikit/download/release/ROOM_MAJOR_MINOR/TUIRoomKit_ROOM_VERSION.podspec'

How to upgrade External Pods?

Open the two default addresses to check each s.version for the default version. Before upgrading, confirm compatibility between the two components. When specifying a version, update to the paired podspec address, then run:
pod update TUIRoomKit AtomicXCore
pod install typically retains the version in Podfile.lock and does not upgrade proactively. Submit the updated Podfile.lock; do not delete the entire lock file to upgrade the SDK.

What if integration or compilation fails?

SwiftPM resolution failure: Check your network, run Resolve Package Versions in File > Packages. If it still fails, try Reset Package Caches.
requires Swift tools version 6.0: Use Xcode 16 or higher.
No such module: For SwiftPM, ensure your App Target includes TUIRoomKit, AtomicXCore, SnapKit. For CocoaPods, confirm both podspecs are added and open the project via .xcworkspace.
AtomicXCore missing API: Check if the selected version is compatible with TUIRoomKit. If needed, use the paired versioned address.

Do I need to call login every time I enter a room?

No. Typically, you only need to call LoginStore.shared.login once. It's best to tie login and logout to your own authentication logic.

How to update Package.swift for SwiftPM projects?

The following is a configuration snippet, not a complete manifest. Replace ROOM_VERSION with the released version, and add to your package's dependencies:
.package(url: "https://github.com/Tencent-RTC/RoomKit_SwiftPM.git", from: "ROOM_VERSION")
Add to the target's dependencies that uses the component:
.product(name: "TUIRoomKit", package: "RoomKit_SwiftPM")
package: uses the package identity RoomKit_SwiftPM, not the module name TUIRoomKit. If your business code directly imports AtomicXCore or SnapKit, declare their repository dependencies in your package manifest and add their product names to the target. Version requirements should match the Package.swift under your selected RoomKit_SwiftPM tag.

Contact Us

If you have any questions or suggestions during integration or use, contact info_rtc@tencent.com for support.

Ajuda e Suporte

Esta página foi útil?

comentários