tencent cloud

Chat

Mac

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-12-01 16:06:47
This document describes how to quickly integrate the Chat SDK (Mac) into your projects. To configure and integrate the SDK, follow these steps.

Development Environment Requirements

Xcode 9.0+.
Mac device running OS X 10.10 or later.
The project has been configured with a valid developer signature.

Integrating Chat SDK

You can either automatically integrate the Chat SDK by using Swift Package Manager or CocoaPods, or manually download the SDK and import it to your current project.

Automatic Loading with Swift Package Manager

Step 1: Check the Development Environment

Use a version of Xcode that supports Swift 5.10 or later, such as Xcode 16.0. Mac apps integrated through Swift Package Manager require macOS 10.13 or later. These toolchain and operating system requirements apply only to integration through Swift Package Manager.

Step 2: Add the SDK Repository

Open your project in Xcode, choose File > Add Package Dependencies..., and enter the following repository URL in the search box:
https://github.com/Tencent-RTC/Chat_SDK_SwiftPM.git
For repository details, see Chat_SDK_SwiftPM.

Step 3: Select a Version and Associate a Target

Select Exact Version under Dependency Rule, enter 9.1.7824, and click Add Package.

On the product selection page, select TXIMSDK_Plus_Mac and add it to the macOS App Target that needs to use the IM SDK.

Note:
You can select a version dependency rule as needed:
Exact Version: Pin a version, such as 9.1.7824.
Up to Next Minor Version: Enter 9.1.0 to restrict versions to 9.1.x.
Up to Next Major Version: Enter 9.1.0 to allow versions ≥ 9.1.0 and < 10.0.0.
Range: Specify a custom range that includes the lower bound but excludes the upper bound.
Do not add the IM SDK to the same App Target through Swift Package Manager, CocoaPods, and manual integration at the same time, to avoid duplicate symbols or framework conflicts.

Step 4: Import the SDK and Verify Integration

Import ImSDKForMac_Plus in the Swift files that need to use the SDK. Note that the dependency product name is TXIMSDK_Plus_Mac, while the module name used in code is ImSDKForMac_Plus.
Before running the Mac app, configure App Sandbox and network permissions as described in Enabling App Sandbox below.
import ImSDKForMac_Plus

func verifyIMSDKIntegration() {
guard let manager = V2TIMManager.sharedInstance(),
let version = manager.getVersion(),
!version.isEmpty else {
assertionFailure("IM SDK integration verification failed")
return
}
print("IM SDK version: \\(version)")
assert(version == "9.1.7824")
}
Call verifyIMSDKIntegration() after the app starts, then build and run it using the Debug configuration. If the project compiles and links successfully, the console outputs IM SDK version: 9.1.7824, and no assertion is triggered, this version of the SDK has been integrated successfully. When integrating another version, update the expected version number in the example accordingly.

Automatically loading CocoaPods

Note:
As the official CocoaPods repository no longer accepts new versions, future IM SDK versions will be released exclusively through Swift Package Manager (SPM) and will no longer be updated through CocoaPods.

Step 1: Install CocoaPods

Run the following command in a terminal window (you need to install the Ruby environment on your Mac device in advance):
sudo gem install cocoapods

Step 2: Create a Podfile

Navigate to the path where the project is located and run the following command. Then, a Podfile will appear under the project path.
pod init

Step 3: Edit the Podfile

Edit the Podfile as follows:
platform :macos, '10.10'
source 'https://github.com/CocoaPods/Specs.git'

target 'mac_test' do
pod 'TXIMSDK_Mac'
end

Step 4: Update and install the SDK

Run the following command in a terminal window to update the local library file and install TXIMSDK_Mac:
pod install
Alternatively, run the following command to update the local library version:
pod update
After the pod command is executed, a project file integrated with the SDK and suffixed .xcworkspace will be generated. Double-click the file to open it.

Manual integration

Step 1: Obtain the SDK download URL from Github:

ImSDKForMac.framework is the core dynamic library file of the SDK.
Pack Name
Description
ipa Increment
ImSDKForMac.framework
Chat feature pack
1.4 MB

Step 2: Create a project

Create a project:



Enter a project name:




Step 3: Integrate Chat SDK

Add the dependent library:select the Target of Demo. On the General panel, add the dependent library under Embedded Binaries and Linked Frameworks and Libraries.



Add the dependent library:
ImSDKForMac.framework
Caution:
You need to add -ObjC in Build Setting > Other Linker Flags.

Enabling App Sandbox

Select the project's Target, find App Sandbox in the Signing & Capabilities panel, and select Network to allow network requests from the Mac app.
Note:
If App Sandbox is not enabled, messages, conversations, groups, and other data stored locally by the IM SDK will become invalid.
If you do not select Network to allow network requests, the Mac app will be unable to access the network, causing the IM SDK to fail to establish a connection.
Xcode adds and enables App Sandbox by default when creating a project. If App Sandbox is not shown in the current panel, click +Capability to add it manually.




Referencing Chat SDK

Use the SDK in project code in two ways:
Method 1: Navigate to Xcode > Build Setting > Header Search Paths, and set the ImSDKForMac.framework/Headers path. In files that require the SDK API, directly reference the header file "ImSDK.h".
#import "ImSDK.h"
Method 2: in the files that require the SDK API, import the header file <ImSDKForMac/ImSDK.h>.
#import <ImSDKForMac/ImSDK.h>

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック