This topic describes how to use Xcode to integrate GameShield SDK for iOS.
Procedure
- Open Xcode.
- Create a project, select Single View Application, and then use the default settings to complete the creation of the project. In this
example, the project is named yxd_sdk_test.
Note Before you perform the next steps, you must ensure that the new project is running
normally.
- Add dependencies. Copy the YunCeng.framework file from the iOS SDK package to the directory where the new project resides. In
this example, the project is yxd_sdk_test.
- Modify the project settings.
- Change Build Phases to Link Binary With Libraries.
- Add the YunCeng.framework file and its associated frameworks.
- Initialize the SDK.
Before you run the following code, you must replace the following variables:
- Replace
<yourAppKey>
with the AccessKey that you obtained in the GameShield console.
- Replace
<token>
with the unique ID of a player in your game. If the ID is unavailable, you can use
the default value. You cannot leave <token> unspecified.
- (int) SDKInit {
const char * appkey = "<yourAppKey>";
const char * token = "<token>";
int ret = YunCeng_InitEx(appkey, token);
if (ret == 0) {
NSLog(@"sdk init success");
} else {
NSLog(@"sdk init failed, ret %d", ret);
}
return ret;
}
Troubleshooting:
- If the "_OBJC_CLASS_$_CTTelephonyNetworkInfo", referenced from error message appears when you compile the code, we recommend that you add the CoreTelephony.framework library. For more information, see Step 4.
- If the "_res_9_getservers", referenced from error message appears when you compile the code, we recommend that you add the libresolv.tbd library. For more information, see Step 4.
What to do next
After you add your application, you can use the SDK to retrieve the IP address and
the port that are mapped by GameShield for your application. The method that GameShield
uses to map an IP address and a port for your application varies based on your service
type. For details about the methods, see the following topics: