Mac M3 Pro、XCode 16.0、Unreal 5.4
流程
分享下我本地操作的全流程和遇到的问题
- 安装 XCode
- GithubDesktop 克隆自己 Fork 的仓库
- 运行 Setup.command
- 运行 GenerateProjectFiles.command
- 出现警告:Platform Mac is not a valid platform to build. Check that the SDK is installed properly and that you have the necessary platorm support files
- 造成的问题为 XCode 打开后没有项目
- 原因:Engine/Config/Apple/Apple_SDK.json 内限制了 XCode 的版本为 15.9.0,但是本地的版本为 16.0.0
- 解决办法:修改 json 内的 MaxVersion 为 16.0.0 即可
json
{
// Xcode versions
"MainVersion": "14.1",
"MinVersion": "14.1.0",
"MaxVersion": "15.9.0",
// The versions on Windows are iTunes versions
"MinVersion_Win64": "1100.0.0.0",
"MaxVersion_Win64": "8999.0"
}
-
打开 UE5 (Mac).xcworkspace
-
XCode 上方栏内的目标项目改为 UnrealEditor
-
菜单栏 - Product - Build
-
左侧项目目录界面的右侧可以查看日志
-
然后就是漫长的编译了,编译慢的一批
-
编译后就可以Run了,跑编辑器,后续流程同Windows
-
原有项目的.uproject 右键 switch engine version
-
然后 generate xcode project,我这边没有用,改用命令行后才成功:
sh "/Users/XXX/Documents/Projects/UnrealEngine/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh" -project="/Users/XXX/Documents/Projects/XXX/XXX.uproject" -game
-
XCode 上方栏内的目标项目改为 XXXEditor,编译运行即可
编译问题
cpp
declaration shadows a field of 'XXX' [-Werror,-Wshadow]
implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
encoding prefix 'u' on an unevaluated string literal has no effect and is incompatible with c++2c [-Werror,-Winvalid-unevaluated-string]
第一个问题:
cpp
// Engine/Source/Programs/UnrealBuildTool/ToolChain/ClangWarnings.cs
if (CompileEnvironment.ShadowVariableWarningLevel != WarningLevel.Off)
{
// Arguments.Add("-Wshadow" + ((CompileEnvironment.ShadowVariableWarningLevel == WarningLevel.Error) ? "" : " -Wno-error=shadow"));
}
第二个问题:
https://www.emmtrix.com/wiki/Clang:Diag/warn_deprecated_this_capture
C++20 不在允许隐式捕获this,加一下就好了:
cpp
[=, this]
第三个问题:
https://github.com/llvm/llvm-project/issues/64711
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2741r3.pdf
把static_assert内的TEXT宏去掉即可