Unreal iOS
在使用 Hive SDK Unreal iOS 完成应用开发后,构建应用时需要配置以下项目。
- 在虚幻编辑器菜单中,点击编辑 > 项目设置。项目设置窗口将出现在屏幕上。
- 在项目设置窗口中,在左侧面板的平台标题下选择iOS菜单。iOS设置屏幕将出现。根据每个组的指导设置项目。
按组设置¶
以下是按组设置的说明。
-
捆绑信息组:在捆绑标识符字段中输入您游戏的 AppID。
-
操作系统信息组:从 Unreal Engine 4.25 开始,支持的操作系统版本已更改为 11.0 或更高。将 Minimum OSVersion 字段值设置为 11.0。
-
构建组:在附加非运输链接器标志字段和附加运输链接器标志字段中输入 -ObjC。
额外的 Plist 数据组设置¶
根据下面列出的设置项在附加 PList 数据字段中输入代码行。所有代码必须在一行中输入。
访问权限请求设置¶
要设置访问权限请求,请将以下代码添加到附加 PList 数据字段中。
<key>NSCameraUsageDescription</key>
<string>Approval required to take pictures.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Approval required to upload image files.</string>
<key>NSUserTrackingUsageDescription</key>
<string>We need your permission to use the Advertising Identifiers (IDFA) for promotion targeting and tracking analysis.</string>
认证:Facebook、QQ VK、微信、Line 设置¶
如果您使用 Facebook、QQ、VK、微信或 Line 认证,请将以下代码添加到附加 PList 数据字段中以设置服务器白名单。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>vk-share</string>
<string>vkauthorize</string>
<string>vk</string>
<string>weixinULAPI</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>lineauth2</string>
<string>mqqopensdkapiV3</string>
<string>wtloginmqq2</string>
<string>mqq</string>
<string>mqqapi</string>
</array>
在使用 Facebook 时,请使用以下代码添加 Facebook AppID 和 ClientToken。确保为您的游戏输入 Facebook AppID 和 ClientToken 值。
<key>FacebookAppID</key><string>926000000000000</string>
<key>FacebookClientToken</key><string>d123783h7sdfyh8031h23unf81h3</string>
为每个身份提供者设置 URL 方案。
<key>CFBundleURLTypes</key>
<array>
<!--For Facebook usage. Please insert your app's Facebook App ID value-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>fb926000000000000</string></array></dict>
<!--For using deep links on the Hive platform. Please insert your AppID value-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>com.com2us.misample.normal.freefull.apple.global.ios.universal</string></array></dict>
<!--For Google Sign-in. Please insert the Google Sign-in key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>com.googleusercontent.apps.270000000000-0m7r8tb2co1q00000000000000000000</string></array></dict>
<!--For QQ Sign-in. Please insert the QQ key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>tencent</string>
<key>CFBundleURLSchemes</key><array><string>tencent1106227203</string></array></dict>
<!--For Wechat Sign-in. Please insert the Wechat key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>weixin</string><key>CFBundleURLSchemes</key><array><string>wx78176cf0c698c0f9</string></array></dict>
<!--For VK Sign-in. Please insert the VK key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>vk6270065</string><key>CFBundleURLSchemes</key><array><string>vk6270065</string></array></dict>
<!--For Line Sign-in-->
<dict><key>CFBundleTypeRole</key><string>Editor</string>
<key>CFBundleURLSchemes</key><array><string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string></array></dict>
</array>
以下是将上述值插入到附加 PList 数据字段中的示例。
<key>NSCameraUsageDescription</key>
<string>Approval required to take pictures.</string>
<key>NSContactsUsageDescription</key>
<string>You must agree to add friends from your Contacts.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Approval required to upload image files.</string>
<key>NSUserTrackingUsageDescription</key>
<string>We need your permission to use the Advertising Identifiers (IDFA) for promotion targeting and tracking analysis.</string>
<key>FacebookAppID</key>
<string>1809615065921877</string>
<key>FacebookClientToken</key>
<string>c41e47ba5512ea3fb5bfb29d5cfeb244</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb926000000000000</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.com2us.hivesdk.normal.freefull.apple.global.ios.universal</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.331526026701-s41n272jsv6c0f72kt5o7of0jns350gl</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>tencent</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tencent1106227203</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>weixin</string>
<key>CFBundleURLSchemes</key>
<array>
<string>wx78176cf0c698c0f9</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>vk6270065</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vk6270065</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>vk-share</string>
<string>vkauthorize</string>
<string>vk</string>
<string>weixinULAPI</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>lineauth2</string>
<string>mqqopensdkapiV3</string>
<string>wtloginmqq2</string>
<string>mqq</string>
<string>mqqapi</string>
</array>
苹果登录设置¶
要支持 Apple SignIn,请将以下代码添加到项目文件夹 > 配置 > DefaultEngine.ini 文件中。
多语言设置¶
要在多种语言中服务您的应用程序,您需要添加多语言设置文件。下载multilingual setting file,解压缩,然后将localize文件夹的内容复制到/Plugins/HIVESDK/Source/HIVESDK/ThirdParty/iOS/resource。
应用 HIVEAppDelegate¶
对于 iOS 构建,您需要修改 AppDelegate 方法。在 Unreal Engine 的情况下,使用 Swizzling 来访问 AppDelegate。在应用程序启动时的初始化阶段添加以下代码。
// Add IOSAppDelegate.h
#if PLATFORM_IOS
#include "Runtime/ApplicationCore/Public/iOS/IOSAppDelegate.h"
#endif
// Add AppDelegate
#if PLATFORM_IOS
UIApplication * dummyApplication = [UIApplication sharedApplication];
Class clzHIVEAppDelegate = NSClassFromString(@"HIVEAppDelegate");
SEL selApplicationDidFinishLaunchingWithOptions = NSSelectorFromString(@"application:didFinishLaunchingWithOptions:");
if( clzHIVEAppDelegate != nil && [clzHIVEAppDelegate respondsToSelector:selApplicationDidFinishLaunchingWithOptions] ) {
NSMethodSignature *method = [clzHIVEAppDelegate methodSignatureForSelector:selApplicationDidFinishLaunchingWithOptions];
if (method != nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:method];
[invocation setSelector:selApplicationDidFinishLaunchingWithOptions];
[invocation setTarget:clzHIVEAppDelegate];
[invocation setArgument:(void*)&dummyApplication atIndex:2];
NSDictionary *localLaunchOptions = [IOSAppDelegate GetDelegate].launchOptions;
if( localLaunchOptions != nil ) {
[invocation setArgument:(void*)&localLaunchOptions atIndex:3];
}
[invocation invoke];
}
}
#endif
iOS FMallocAnsi 设置¶
为了使Unreal Engine iOS环境与C++标准模板库兼容,FMallocAnsi设置如下所需。将以下代码添加到您的应用项目中的{YourProject}.Target.cs
文件中。