Skip to main content
Version: 1.10.x

Installing and Applying the SDK

iOS Requirements


To use the AppGuard SDK in an iOS environment, the following requirements must be met.

  • Xcode 15.X
  • AppGuard for iOS SDK v1.10.1.3 or later

AppGuard SDK Installation and Application


Download the AppGuard SDK

You need to download the necessary files to apply the AppGuard SDK. Download the SDK and configuration files from the AppGuard Manager.

ItemDescription
AppGuard SDKProvided as a static framework: AppGuardCore.framework
AppGuard Config FilesConfiguration files required to run AppGuard (appguard, appguard.crt, appguard.mf, appguard106000)
tip

Please delete the existing AppGuardCore.xcframework from your project.

How to Apply the AppGuard SDK

  1. Copy the downloaded AppGuardCore.framework file into your project.

  2. In Xcode, go to Project > TARGETS:ProjectName > Build Phases > Link Binary With Libraries, and click the Add[+] button at the bottom.

  3. In the [Choose frameworks and libraries to add:] window, click [Add Other], and then choose [Add Files...].

  4. Select the AppGuardCore.framework file that you copied to your project, and click [Open].

  5. Ensure that the AppGuardCore.framework file is added to the Link Binary With Libraries section.

  6. Set the Embed attribute of the AppGuardCore.framework to Do Not Embed.

  • In Xcode, go to Project > TARGETS:ProjectName > Build Settings > Other Linker Flags, and add the options -lstdc++, -lz.

Applying the AppGuard Config Files

  1. Copy the four latest configuration files you downloaded (appguard, appguard.crt, appguard.mf, appguard106000) into your project.

  2. In Xcode, go to Project > TARGETS:ProjectName > Build Phases > Copy Bundle Resources, and click the Add[+] button at the bottom.

  3. In the [Choose items to add:] window, click [Add Other].

  4. Select the configuration files you copied to your project, and click [Open].

  5. Ensure that the configuration files are added to the Copy Bundle Resources section.

Using AppGuard SDK in Objective-C


Applying the Required API

To use the AppGuard SDK, the following required API must be implemented.

Callback Function Overview

AppGuard SDK provides a callback function to relay information about the operational state and detection events of AppGuard to the app. This callback function must be registered with the AppGuard SDK through the APPGUARD_INIT API.

typedef void (*PAPPGUARDAPPCALLBACK)(int type, int code, const char *pData);
static void APPGUARD_INIT(PAPPGUARDAPPCALLBACK);
caution

The callback function must be implemented in your project and passed as a parameter when calling APPGUARD_INIT.

Implementing and Registering the Callback Function

The callback function should be registered at the entry point of the app. It is generally recommended to implement and register the function in the AppDelegate source file.

AppDelegate.m
/**
* Declare the callback function for communicating with the AppGuard SDK.
* It is generally a good practice to implement this at the top of the AppDelegate source file.
*/

#import <AppGuardCore/AppGuard.h>
#import <AppGuardCore/AppGuardDefine.h>

static void AppGuardAppCallback(int type, int code, const char* desc)
{
if(type == APPGUARD_TYPE_KILL)
{
/**
* If the detected content is set to the kill option by policy, it requests a forced termination.
* When this message is detected, the app must be forcibly terminated.
* It is recommended to notify the user through a message and then terminate the app.
*/
}
else if(type == APPGUARD_TYPE_S2AUTH_CALLBACK)
{
if(code == APPGUARD_TYPE_CSAUTH_SUCCESS)
{
/**
* Server authentication was successful.
* Use the server authentication ID passed in the desc parameter to re-verify the user on the game server.
*
* desc : Server authentication ID
*/

}
else if(code == APPGUARD_TYPE_CSAUTH_FALSE)
{
/**
* Server authentication failed.
* Use the server authentication ID passed in the desc parameter to re-verify the user on the game server.
*
* The failure may be due to a network issue on the client side, so it is essential to perform the re-verification process through the game server.
*
* desc : Server authentication ID
*/
}
}
}

...

/**
* Register the callback function for communicating with the AppGuard SDK.
*
* Use the APPGUARD_INIT API to register the callback function with AppGuard SDK.
*
* It is recommended to implement this within the didFinishLaunchingWithOptions function of the AppDelegate.
*/
- (Bool)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *) launchOptions {
// Use the APPGUARD_INIT API to register the callback function with AppGuard SDK
APPGUARD_INIT(AppGuardAppCallback);
}

Once the above steps are completed, you are ready to use the AppGuard SDK. Build and run your project to ensure that the AppGuard SDK is functioning correctly.

tip

For more detailed information about the APIs provided by the AppGuard SDK, refer to the AppGuard SDK API Reference.

Using AppGuard SDK in Swift


AppGuard Swift Interface Explanation

To use the Objective-C-based AppGuard API in a Swift project, the Bridging Header method must be employed. To facilitate the use of the AppGuard API in Swift projects, the following three files are provided.

FilenameDescriptionLanguage
AppGuard-Bridging-Header.hBridging Header to connect Swift and Objective-C modulesObjective-C
AppGuardWarpper.hAppGuard API interface declarationObjective-C
AppGuardWarpper.mmAppGuard API interface implementationObjective-C

Applying the AppGuard Swift Interface Bridging

  1. Copy the three files (AppGuard-Bridging-Header.h, AppGuardWarpper.h, AppGuardWarpper.mm) from the /appguard_swift_interfaces folder you downloaded into your project folder.

  2. Add the copied files to your Xcode project by [Drag & Drop].

  3. In the [Choose options for adding these files:] window, click the [Finish] button.

  4. In the [Would you like to configure an Objective-C bridging header?] window, click the [Don't Create] button.

  5. Go to Project > TARGETS:ProjectName > Build Settings > Swift Compiler - General > Objective-C Bridging Header, and add the path $(SRCROOT)/MyProject/AppGuard-Bridging-Header.h.

info

After completing these steps, your Swift project will be ready to use the AppGuard API.

Required AppGuard Swift API Implementation

Callback Function Overview

For Swift projects, the APPGUARDGAMECALLBACK function is defined at the top of the AppGuardWarpper.mm file. This function detects and reports abnormal behavior by malicious users. If the detected behavior requires forced termination as per the security policies set in the admin page, the app is notified.

You can handle detected and reported content as shown in the sample code below.

AppGuardWarpper.mm
// AppGuardWarpper.mm

static void APPGUARDGAMECALLBACK(int type, int code, const char* desc)
{
if(type == APPGUARD_TYPE_KILL)
{
/**
* If the detected content is set to the kill option by policy, it requests a forced termination.
* When this message is detected, the app must be forcibly terminated.
* It is recommended to notify the user through a message and then terminate the app.
*/
}
else if(type == APPGUARD_TYPE_S2AUTH_CALLBACK)
{
if(code == APPGUARD_TYPE_CSAUTH_SUCCESS)
{
/**
* Server authentication was successful.
* Use the server authentication ID passed in the desc parameter to re-verify the user on the game server.
*
* desc : Server authentication ID
*/

}
else if(code == APPGUARD_TYPE_CSAUTH_FALSE)
{
/**
* Server authentication failed.
* Use the server authentication ID passed in the desc parameter to re-verify the user on the game server.
*
* The failure may be due to a network issue on the client side, so it is essential to perform the re-verification process through the game server.
*
* desc : Server authentication ID
*/
}
}
}
tip

Please implement the logic for handling termination messages within the APPGUARDGAMECALLBACK() function.

caution

Before releasing the service, make sure to remove any log output functions within the APPGUARDGAMECALLBACK() function.

Registering the Callback Function

This is a required API function for initializing AppGuard and communicating with the SDK. You must call the APPGUARD_INIT API within the application function in AppDelegate.swift to register the callback function in a Swift project.

AppDelegate.swift
// AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//* Use the APPGUARD_INIT API to register the callback function with AppGuard SDK
let obj = AppGuardWarpper()
obj.initAppGuard()

return true
}
info

After completing the above steps, you will be fully ready to use AppGuard in your Swift project.

tip

For more detailed information about the APIs provided by the AppGuard SDK, refer to the AppGuard SDK API Reference.

Applying AppGuard SDK Privacy Manifests


To apply Privacy Manifests with AppGuard SDK v1.10.1.3 or higher, follow these steps.

The module in AppGuardCore.framework is merged and distributed within the TARGETS linked to AppGuardCore.framework.

PrivacyInfo.xcprivacy, related to Apple's Privacy Manifests, must include the content of PrivacyInfo.xcprivacy from AppGuardCore.framework within the PrivacyInfo.xcprivacy file linked to the TARGETS of the AppGuard SDK.

To merge the PrivacyInfo.xcprivacy content of AppGuardCore.framework into the PrivacyInfo.xcprivacy of your project, follow the guide below.

  • If your Xcode project already has a PrivacyInfo.xcprivacy file:

    • Compare it with the PrivacyInfo.xcprivacy file from AppGuardCore.framework to check for any missing parts.
    • If there are any missing parts, add them to the existing PrivacyInfo.xcprivacy file and merge them.
  • If your Xcode project does not have a PrivacyInfo.xcprivacy file:

    • Follow the same steps as for adding AppGuard Config Files:
      • Copy the PrivacyInfo.xcprivacy file from AppGuardCore.framework into your Xcode project.

      • In Xcode, go to Project > TARGETS:ProjectName > Build Phases > Copy Bundle Resources, and click the Add[+] button at the bottom.

      • In the [Choose items to add:] window, click [Add Other].

      • Select the copied PrivacyInfo.xcprivacy file, and click [Open].

      • Ensure that the PrivacyInfo.xcprivacy file is added to the Copy Bundle Resources section.

info

Starting with AppGuard for iOS SDK v1.10.1.3, the SDK is distributed under the name AppGuardCore.framework, and it is distributed as a static framework.

tip

For AppGuard for iOS SDK v1.10.1.3 and later, Apple has specified in its Privacy Manifest that only the NSPrivacyAccessedAPICategoryUserDefaults API is used. No other APIs are accessed. For third-party SDKs linked as static frameworks, a merge operation with the customer's PrivacyInfo.xcprivacy may also be necessary, similar to the AppGuard SDK.