iOS
- SDK 1.26 及之后版本
- SDK 1.26 之前的版本
UE4.21 ~ UE4.27 & UE5 ~ UE5.5
UE4.21 ~ UE4.27 & UE5 ~ UE5.4
前提条件
游戏使用的每个 SDK 插件的版本(包括游戏启动器使用的版本)必须保持一致。如果游戏需要同时访问多个版本的 Player Network SDK,或者只有一个组件需要升级,请联系 Player Network 助手。
步骤1:安装 SDK
1. 将 Player Network SDK 添加到您的项目
-
解压 SDK 软件包。
-
将
INTLSDK
文件夹复制到项目的Plugins
文件夹中。
如果项目中没有Plugins
文件夹,请创建一个。 -
打开项目的
{项目名称}.Build.cs
文件,并按照示例将 Player Network SDK 添加到 Unreal Engine 中。public INTLSample(ReadOnlyTargetRules Target) : base(Target)
{
PrivateDependencyModuleNames.AddRange(new string[] {
"INTLCore",
"INTLFoundation",
"INTLConfig",
});
}
Player Network SDK package
├─INTLSDK
│ ├─INTLSDK.uplugin // Player Network SDK plugins description files
│ ├─Resources // Player Network SDK resources
│ └─Source // Player Network SDK plugin modules. Each module contains its own Build.cs file, libraries, and interfaces.
│ ├─INTLApple
│ ├─INTLConfig // Player Network SDK configurations
│ ├─INTLCore // Player Network SDK Core module
│ ├─INTLDiscord
│ ├─INTLEpic
│ ├─INTLFacebook
│ ├─INTLFoundation
│ ├─INTLGoogle
│ ├─INTLKakao
│ ├─INTLLine
│ ├─INTLSteam
│ ├─INTLTwitter
│ └─INTLVK
├─LevelInfinite // LI PASS APIs
└─Symbols // Player Network SDK symbol table *.so files
INTLSDK/Source/INTLCore
└─INTLSDK
├─INTLSDK.uplugin
├─Resources
└─Source
├─INTLConfig
├─INTLCore
| ├─INTLCore.Build.cs // INTLCore Build.cs file
| ├─Libs // INTLCore libraries for different platforms which contain dll, lib, and other binary files.
| | ├─Android
| | ├─include
| | ├─iOS
| | ├─MacOS
| | └ ─Win
| ├─Private // Player Network SDK private folder
| └─Public // Player Network SDK public interfaces
| // INTLSDKAPI.h: Player Network SDK APIs
| // INTLSDKPluginObserver.h: Player Network SDK observer classes
| // INTLSDKPluginDefine.h: Player Network SDK data types
| // INTLSDKOutputUtility.h: Player Network SDK utility to process callbacks
| // INTLSDKBaseUserWidget.h: Player Network SDK base class for UserWidget which includes registration and deregistration APIs
├─INTLCustomer
├─INTLDiscord
├─INTLEpic
INTLSDK/Source/INTLConfig
└─INTLSDK
├─INTLSDK.uplugin
├─Resources
└─Source
├─INTLConfig
| ├─Configs // Player Network SDK configurations for different platform
| | ├─Android
| | | └─INTLConfig_APL.xml // Player Network SDK Android gradle configuration file
| | ├─iOS
| | | └─INTLConfig_UPL.xml
| | ├─Resources
| | | ├─APASConfig.ini // APAS device level configuration file
| | | └─INTLConfig.ini // Player Network SDK main configuration file
| ├─Encrypt
| ├─INTLConfig.Build.cs
| ├─INTLConfig.uplugin
| ├─Private
| ├─Public
| └─Resources
├─INTLCore
2. 加载所需的权限和插件
打开 INTLSDK/Scripts/INTLConfig/Editor/Resources/INTLConfig.ini
文件,并添加 Player Network SDK 配置。将占位符替换为游戏配置的对应值。
[INTL environment]
# WARNING: You should change this URL to the production environment when you release your game.
INTL_URL = https://test.intlgame.com
GAME_ID = {INTL_GAME_ID}
SDK_KEY = {INTL_SDK_KEY}
[INTL Log]
LOG_LEVEL = 1
LOG_CONSOLE_OUTPUT_ENABLE = 1
LOG_FILE_OUTPUT_ENABLE = 1
LOG_ENCRYPT_ENABLE = 0
LOG_COMPRESS_ENABLE = 0
[Facebook channel configuration]
FACEBOOK_APP_ID = {INTL_FACEBOOK_APP_ID}
FACEBOOK_DISPLAYNAME = {INTL_APP_NAME}
iOS 使用说明
集成时,用户可根据自己的需要修改内容,并 与法律团队确认内容是否合规。如果没有修改,请用游戏名称替换 INTLSample。
根据 iOS 权限要求,在申请敏感权限时,当系统弹出提示用户填写信息时,填写 用途描述。
-
在
Plugins/INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLCore.plist
中,以下权限已升级:<key>NSPhotoLibraryUsageDescription</key>
<key>NSCameraUsageDescription</key>
<key>NSLocationWhenInUseUsageDescription</key>
<key>NSPhotoLibraryAddUsageDescription</key>
<key>NSMicrophoneUsageDescription</key> -
在
Plugins/INTLSDK/Source/INTLConfig/Configs/iOS/Plist/INTLADTracking.plist
中,以下权限已升级:<key>NSUserTrackingUsageDescription</key>
3. Swift SDK 兼容设置
Unreal Engine 5.2 及以上版本已内置 Swift 模块,下列步骤仅适用于 Unreal Engine 5.2 以下版本。
iOS Swift 模块不能直接添加到 Unreal Engine 中,必须先修改引擎配置。
-
修改本地 Unreal Engine 源代码。
在 /Your_UE_Installation_Path/Engine/Source/Programs/UnrealBuildTool/ProjectFiles/Xcode/XcodeProject.cs 的
private void AppendProjectBuildConfiguration(StringBuilder Content, string ConfigName, string ConfigGuid)
函数中添加以下代码。// Enable Swift
Content.Append("\t\t\t\tCLANG_ENABLE_MODULES = YES;" + ProjectFileGenerator.NewLine);
Content.Append("\t\t\t\tSWIFT_VERSION = 5.0;" + ProjectFileGenerator.NewLine);
Content.Append("\t\t\t\tLIBRARY_SEARCH_PATHS = \"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\";" + ProjectFileGenerator.NewLine);
if (ConfigName == "Debug")
{
Content.Append("\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";" + ProjectFileGenerator.NewLine);
}
Content.Append("\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;" + ProjectFileGenerator.NewLine);
Content.Append("\t\t\t\tEMBEDDED_CONTENT_CONTAINS_SWIFT = YES;" + ProjectFileGenerator.NewLine); -
在 /Your_UE_Installation_Path/Engine/Source/Programs/UnrealBuildTool/Platform/IOS/IOSToolChain.cs 的
string GetLinkArguments_Global(LinkEnvironment LinkEnvironment)
函数中添加以下代码。- Before XCode 12
- XCode 12 and later
// enable swift support
Result += " -rpath \"/usr/lib/swift\"";
Result += " -rpath \"@executable_path/Frameworks\"";
// /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/swift/
String swiftLibPath = String.Format(" -L {0}Platforms/{1}.platform/Developer/SDKs/{1}{2}.sdk/usr/lib/swift",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName : Settings.Value.SimulatorPlatformName,
Settings.Value.IOSSDKVersion);
Result += swiftLibPath;
Log.TraceInformation("Add swift lib path : {0}", swiftLibPath);
///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
swiftLibPath = String.Format(" -L {0}Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/{1}",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName.ToLower() : Settings.Value.SimulatorPlatformName.ToLower());
Result += swiftLibPath;
Log.TraceInformation("Add swift lib path : {0}", swiftLibPath);
///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos
swiftLibPath = String.Format(" -L {0}Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/{1}",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName.ToLower() : Settings.Value.SimulatorPlatformName.ToLower());
Result += swiftLibPath;// This line of code must be prepended (see the sample image below for the position of the prepended code)
// enable swift support, make sure '/usr/lib/swift' goes before '@executable_path/Frameworks'
Result += " -rpath \"/usr/lib/swift\"";// enable swift support
Result += " -rpath \"@executable_path/Frameworks\"";
// /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/swift/
String swiftLibPath = String.Format(" -L {0}Platforms/{1}.platform/Developer/SDKs/{1}{2}.sdk/usr/lib/swift",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName : Settings.Value.SimulatorPlatformName, Settings.Value.IOSSDKVersion);
Result += swiftLibPath;
Log.TraceInformation("Add swift lib path : {0}", swiftLibPath);
///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
swiftLibPath = String.Format(" -L {0}Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/{1}",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName.ToLower() : Settings.Value.SimulatorPlatformName.ToLower());
Result += swiftLibPath;
Log.TraceInformation("Add swift lib path : {0}", swiftLibPath);
///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos
swiftLibPath = String.Format(" -L {0}Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/{1}",
Settings.Value.XcodeDeveloperDir,
bIsDevice? Settings.Value.DevicePlatformName.ToLower() : Settings.Value.SimulatorPlatformName.ToLower());
Result += swiftLibPath;
// Xcode 12 adds the swiftCompatibility51 library, so you need to add the following code
if (Settings.Value.IOSSDKVersionFloat >= 14.0f)
{
Result += String.Format(" -lswiftCompatibility51");
}