Installing and Applying the SDK
iOS Requirements
To use the AppGuard SDK in an iOS environment, the following requirements must be met.
- ~v1.10.1.3
- v1.10.2.0~
- Xcode 15.X
- AppGuard for iOS SDK v1.10.1.3 or later
- Xcode 15.4 or later
- iOS 12.0 or later
- AppGuard for iOS SDK v1.10.2.0 or later
There is a minimum OS bug in Xcode versions below 15.4 as reported by Apple.
This issue has been resolved in Xcode 15.4 and 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.
- ~v1.10.1.3
- v1.10.2.0~
| Item | Description |
|---|---|
| AppGuard SDK | Provided as a static framework: AppGuardCore.framework |
| AppGuard Config Files | Configuration files required to run AppGuard (appguard, appguard.crt, appguard.mf, appguard106000) |
Please delete the existing AppGuardCore.xcframework from your project.
| Item | Description |
|---|---|
| AppGuard SDK | Provided as a static framework: AppGuardCore.xcframework |
| AppGuard Config Files | Configuration files required to run AppGuard (appguard, appguard.crt, appguard.mf, appguard106000) |
How to Apply the AppGuard SDK
- ~v1.10.1.3
- v1.10.2.0~
-
Copy the downloaded
AppGuardCore.frameworkfile into your project. -
In Xcode, go to Project > TARGETS:ProjectName > Build Phases > Link Binary With Libraries, and click the Add[+] button at the bottom.
-
In the [Choose frameworks and libraries to add:] window, click [Add Other], and then choose [Add Files...].
-
Select the
AppGuardCore.frameworkfile that you copied to your project, and click [Open]. -
Ensure that the
AppGuardCore.frameworkfile is added to the Link Binary With Libraries section. -
Set the Embed attribute of the AppGuardCore.framework to
Do Not Embed.
-
Copy the downloaded
AppGuardCore.xcframeworkfile into your project. -
In Xcode, go to Project > TARGETS:ProjectName > Build Phases > Link Binary With Libraries, and click the Add[+] button at the bottom.
-
In the [Choose frameworks and libraries to add:] window, click [Add Other], and then choose [Add Files...].
-
Select the
AppGuardCore.xcframeworkfile that you copied to your project, and click [Open]. -
Ensure that the
AppGuardCore.xcframeworkfile is added to the Link Binary With Libraries section. -
Set the Embed attribute of the AppGuardCore.xcframework to
Embed & Sign.
- In Xcode, go to Project > TARGETS:ProjectName > Build Settings > Other Linker Flags, and add the options
-lstdc++,-lz.
Applying the AppGuard Config Files
-
Copy the four latest configuration files you downloaded (
appguard,appguard.crt,appguard.mf,appguard106000) into your 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 configuration files you copied to your project, and click [Open].
-
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);
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.
/**
* 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.
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.
| Filename | Description | Language |
|---|---|---|
AppGuard-Bridging-Header.h | Bridging Header to connect Swift and Objective-C modules | Objective-C |
AppGuardWarpper.h | AppGuard API interface declaration | Objective-C |
AppGuardWarpper.mm | AppGuard API interface implementation | Objective-C |
Applying the AppGuard Swift Interface Bridging
-
Copy the three files (
AppGuard-Bridging-Header.h,AppGuardWarpper.h,AppGuardWarpper.mm) from the /appguard_swift_interfaces folder you downloaded into your project folder. -
Add the copied files to your Xcode project by [Drag & Drop].
-
In the [Choose options for adding these files:] window, click the [Finish] button.
-
In the [Would you like to configure an Objective-C bridging header?] window, click the [Don't Create] button.
-
Go to Project > TARGETS:ProjectName > Build Settings > Swift Compiler - General > Objective-C Bridging Header, and add the path
$(SRCROOT)/MyProject/AppGuard-Bridging-Header.h.
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
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
*/
}
}
}
Please implement the logic for handling termination messages within the APPGUARDGAMECALLBACK() function.
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
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
}
After completing the above steps, you will be fully ready to use AppGuard in your Swift project.
For more detailed information about the APIs provided by the AppGuard SDK, refer to the AppGuard SDK API Reference.
Applying AppGuard SDK Privacy Manifests
- ~v1.10.1.3
- v1.10.2.0~
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.xcprivacyfile:- Compare it with the
PrivacyInfo.xcprivacyfile from AppGuardCore.framework to check for any missing parts. - If there are any missing parts, add them to the existing
PrivacyInfo.xcprivacyfile and merge them.
- Compare it with the
-
If your Xcode project does not have a
PrivacyInfo.xcprivacyfile:- Follow the same steps as for adding AppGuard Config Files:
-
Copy the
PrivacyInfo.xcprivacyfile 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.xcprivacyfile, and click [Open]. -
Ensure that the
PrivacyInfo.xcprivacyfile is added to the Copy Bundle Resources section.
-
- Follow the same steps as for adding AppGuard Config Files:
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.
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.
Starting with AppGuard SDK v1.10.2.0, Privacy Manifests have been applied according to Apple's requirements, so no additional merging is necessary.
[Apple & Creating a static framework]
Per Apple's requirements, AppGuard for iOS SDK v1.10.2.0 and later is distributed as a static framework under the name AppGuardCore.xcframework.
For more information, refer to Apple's documentation on creating a static framework: Apple & Creating a static framework
For AppGuard for iOS SDK v1.10.2.0 and later, Apple has specified in its Privacy Manifest that only the NSPrivacyAccessedAPICategoryUserDefaults API is used. No other APIs are accessed.