This topic describes how to use XCode to integrate a GameShield SDK.

Prerequisites

  • You can obtain an SDK and AccessKey pair for iOS from the GameShield console. For more information, see Obtain an SDK package and AccessKey pair.
  • You can obtain the following information from the GameShield console.
    • GroupName: indicates a node group ID. Log on to the GameShield console, open the game management page, and view the target node group ID on the Basic Settings tab.Basic settings and a node group ID
    • Protection Target ID. Log on to the GameShield console, open the Games page, and view a protection target ID on the Protection Target Settings tab.Protection target settings and a protection target ID

Procedure

  1. Open XCode.
  2. Create a project, select Single View Application, and use the default settings to complete the creation of the project. Name the project yxd_sdk_test.
    Note Before proceeding to subsequent operations, you must make sure that the new project is working as expected.
  3. Add dependencies. Copy YunCeng.framework from the iOS SDK to the directory where the yxd_sdk_test project resides.Copy the YunCeng.framework file
  4. Change project settings.
    • Change Build Phases to Link Binary With Libraries.
    • Add YunCeng.framework and its associated frameworks.Add YunCeng.framework
  5. Modify ViewController.m.
    Note For more information about the initEx and getProxyTcpByDomain methods, see Introduction to core methods.
    // Initialize the SDK. One successful initialization for the SDK is required.
    const char appkey[] = "appkeytest"; //Obtain the AccessKey pair from the console.
    int ret = [YunCeng initEx: appkey: "token"];
    if (0 ! = ret) {
        printf("init failed. \n");
        return;
    }
    const char groupname[] = "GroupName"; //Obtain the node group ID from the console. Each game has a unique node group ID.
    char ip[128] = {0};
    char port[32] = {0};
    
    //Call the core methods.
    ret = [YunCeng getProxyTcpByDomain: "Player ID": groupname: "Port for the protection target": "Port for the origin server": ip: 128 : port: 32];
    if (0 ! = ret) {
        printf("get next ip failed. \n");
        return;
    }
    printf("get next ip success. %s, port:%s \n", ip, port);
    Note
    • If a message showing "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from occurs when you compile the project, we recommend that you add the CoreTelephony.framework library by referring to Step 4.
    • If a message showing "_res_9_getservers", referenced from occurs when you compile the project, we recommend that you add the libresolv.tbd library by referring to Step 4.libresolv.tbd

What to do next

After configuring protection for a game by using an SDK, you can use the SDK to retrieve an IP address and port number that is generated by GameShield for the game. The method that is used by GameShield to generate an IP address and port number for an application changes based on the type of services. For the method, see the topic that is specific to your service type.