tencent cloud

Tencent Effect SDK

Release Notes and Announcements
Release Notes
Tencent Effect SDK V3.5 Version Released
Tencent Effects SDK V3.0 Version Related API and Material Changes
Product Introduction
Overview
Features
Basic Concepts
Strengths
Use Cases
Purchase Guide
Pricing Overview
Purchase Guide
Payment Overdue and Refund
Tutorial
Demos
Free Trial License
Licenses
Adding and Renewing a License (Mobile)
Adding and Renewing a License (Desktop)
Adding and Renewing a License (Web)
FAQs
SDK Download
Features
SDK Download
Version History
SDK Integration Guide(No UI)
General Integration of Tencent Effect
Integrating Capabilities
SDK Integration Guide(Including UI)
General Integration of Tencent Effect
Integrating Tencent Effect into MLVB SDK
Integrating Tencent Effect into TRTC SDK
Integrating Tencent Effect into UGSV SDK
Virtual Avatars
API Documentation
iOS
Android
Flutter
Web
Feature Guide
Reducing SDK Size
SDK Integration Issue Troubleshooting
Performance Fine-Tuning
Effect Fine-Tuning
Material Usage
Effect Parameters
Recommended Parameters in Beautification Scenarios
UGSV Enterprise Edition Migration Guide
Integrating Tencent Effect for Third-Party Publishers (Flutter)
Integrating Beauty AR Web into Mini Programs
Tencent Effect Studio Usage
Beauty AR Web
Overview
Quick Start
SDK Integration
Parameters and APIs
Console Guide
Demos
Preset Effect List
Practical Tutorial
FAQs
FAQs
General
Technical
License
Legacy Documentation
Recommended Parameters in Beautification Scenarios
Beauty Parameters Table
One-Minute Integration of TRTC
One-Minute Integration of Live Streaming
TE SDK Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us

iOS

PDF
Focus Mode
Font Size
Last updated: 2025-09-29 16:43:10

Prerequisites

1. Download and decompress the demo package, and copy the xmagickit folder in the demo/XiaoShiPin/ directory to the directory of the Podfile in your project.
2. Add the following dependencies to your Podfile and run pod install.
pod 'xmagickit', :path => 'xmagickit/xmagickit.podspec'
3. Set Bundle ID to the bundle ID bound to your license.

Environment requirements

Xcode 11 or later (download from App Store or here)
Recommended runtime environment:
Device requirements: iPhone 5 or later. iPhone 6 and older models support up to 720p for the front camera.
System requirements: iOS 12.0 or later.

SDK API Integration

Step 1. Authenticate

Add the following code to didFinishLaunchingWithOptions of AppDelegate (LicenseURL and LicenseKey are the authorization information you obtain from Tencent Cloud). If your SDK version is earlier than 2.5.1, you can find TELicenseCheck.h in XMagic.framework; if your SDK version is 2.5.1 or later, TELicenseCheck.h is in YTCommonXMagic.framework.
[TXUGCBase setLicenceURL:LicenseURL key:LicenseKey];

[TELicenseCheck setTELicense:LicenseURL key:LicenseKey completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {
if (authresult == TELicenseCheckOk) {
NSLog(@"Authentication successful");
} else {
NSLog(@"Authentication failed");
}
}];
Authentication error codes:
Error Code
Description
0
Successful.
-1
The input parameter is invalid; for example, the URL or KEY is empty.
-3
Download failed. Check the network settings.
-4
Unable to obtain any Tencent Effect authentication information from the local system, which may be caused by an I/O failure.
-5
The VCUBE TEMP license file is empty, which may be caused by an I/O failure.
-6
The JSON field in the v_cube.license file is incorrect. Please contact Tencent Cloud team for help.
-7
Signature verification failed. Please contact Tencent Cloud team for help.
-8
Decryption failed. Please contact Tencent Cloud team for help.
-9
The JSON field in TELicense is incorrect. Please contact Tencent Cloud team for help.
-10
The Tencent Effect authentication information parsed online is empty. Please contact Tencent Cloud team for help.
-11
Failed to write Tencent Effect SDK authentication information to the local file, which may be caused by an I/O failure.
-12
Download failed, and failed to parse local assets.
-13
Authentication failed.
Others
Please contact Tencent Cloud team for help.

Step 2. Set the SDK material path

CGSize previewSize = [self getPreviewSizeByResolution:self.currentPreviewResolution];
NSString *beautyConfigPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
beautyConfigPath = [beautyConfigPath stringByAppendingPathComponent:@"beauty_config.json"];
NSFileManager *localFileManager=[[NSFileManager alloc] init];
BOOL isDir = YES;
NSDictionary * beautyConfigJson = @{};
if ([localFileManager fileExistsAtPath:beautyConfigPath isDirectory:&isDir] && !isDir) {
NSString *beautyConfigJsonStr = [NSString stringWithContentsOfFile:beautyConfigPath encoding:NSUTF8StringEncoding error:nil];
NSError *jsonError;
NSData *objectData = [beautyConfigJsonStr dataUsingEncoding:NSUTF8StringEncoding];
beautyConfigJson = [NSJSONSerialization JSONObjectWithData:objectData
options:NSJSONReadingMutableContainers
error:&jsonError];
}
NSDictionary *assetsDict = @{@"core_name":@"LightCore.bundle",
@"root_path":[[NSBundle mainBundle] bundlePath],
@"tnn_"
@"beauty_config":beautyConfigJson
};
// Init beauty kit
self.beautyKit = [[XMagic alloc] initWithRenderSize:previewSize assetsDict:assetsDict];

Step 3. Add log and event listeners

// Register log
[self.beautyKit registerSDKEventListener:self];
[self.beautyKit registerLoggerListener:self withDefaultLevel:YT_SDK_ERROR_LEVEL];

Step 4. Configure effects

- (int)configPropertyWithType:(NSString *_Nonnull)propertyType withName:(NSString *_Nonnull)propertyName withData:(NSString*_Nonnull)propertyValue withExtraInfo:(id _Nullable)extraInfo;

Step 5. Render the video

In the preprocessing frame callback, construct YTProcessInput and pass textureId to the SDK for rendering.
[self.xMagicKit process:inputCPU withOrigin:YtLightImageOriginTopLeft withOrientation:YtLightCameraRotation0]

Step 6. Pause/Resume the SDK

[self.beautyKit onPause];
[self.beautyKit onResume];

Step 7. Add an effect panel to the layout

UIEdgeInsets gSafeInset;
#if __IPHONE_11_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
if(gSafeInset.bottom > 0){
}
if (@available(iOS 11.0, *)) {
gSafeInset = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
} else
#endif
{
gSafeInset = UIEdgeInsetsZero;
}

dispatch_async(dispatch_get_main_queue(), ^{
// Effect option UI
_vBeauty = [[BeautyView alloc] init];
[self.view addSubview:_vBeauty];
[_vBeauty mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.view);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(254);
if(gSafeInset.bottom > 0.0){ // Adapt to full-view screen
make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);
} else {
make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(-10);
}
}];
_vBeauty.hidden = YES;
});


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback