vault backup: 2023-07-09 19:29:50
This commit is contained in:
@@ -34,6 +34,11 @@ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
## git
|
||||
之后就可以输入命令安装git
|
||||
```bash
|
||||
brew install git
|
||||
```
|
||||
|
||||
## macOS开发环境
|
||||
https://ue5wiki.com/wiki/2329190d/
|
||||
@@ -56,39 +61,46 @@ https://github.com/trulyspinach/SMCAMDProcessor/releases/tag/0.7.1
|
||||
找到 `machdep.cpu.core_count` 字段,其中的数值就是 Mac 的核心数。然后可以给 xcode 开启多线程,数量数为核心数 *2,如我的是 8 核,就可以开启 16 线程:
|
||||
> defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 16
|
||||
|
||||
# 证书
|
||||
需要以下文件
|
||||
- .cer
|
||||
- .p12
|
||||
- .mobileprovision
|
||||
|
||||
并将其放入
|
||||
`/Users/你的用户名/Library/Mobiledevice/provisioning Profiles`,最后双击导入。p12建议设置一个密码,mac里不支持无密码的p12证书。
|
||||
|
||||
运行GenerateProjectFiles.command生成解决方案,***此时可以检查证书是否有效***。
|
||||
|
||||
# 编译流程
|
||||
- 先编译ShaderCompileWork
|
||||
- 后编译UE5
|
||||
|
||||
***一定要注意虚拟机的CPU以及内存的关系,CPU线程数 * 2 < 内存GB 数。所以给的CPU数目一定不能多。*** 即使是黑苹果下,如果内存不够多,开了比较占用内存的APP会比较容易死机。比如我使用的是7950x 16核心 32线程 与 64GB内存,基本就处于一个平衡状态。如果开了XCode的情况打包引擎会出现死机情况。
|
||||
|
||||
# 疑难问题解
|
||||
## UE5.1 Setup.bat 提示unsupported compression method问题
|
||||
问题为:
|
||||
>Checking dependencies...
|
||||
>Updating dependencies: 0% (0/97340)...
|
||||
> Failed to download 'https://cdn.unrealengine.com/dependencies/UnrealEngine-11447123-52802068b7db445d94de6cd13d574a02/00ba053f58ab8d00cf41519fd27d8059d397a4fb': InvalidDataException: The archive entry was compressed using an unsupported compression method.
|
||||
|
||||
此文问题普遍发生在5.0~5.1以及UE4版本,解决方法:
|
||||
去 https://github.com/EpicGames/UnrealEngine/releases 的各个版本标签下,下载**Commit.gitdeps.xml**文件,并替换`\Engine\Build`下同名文件即可。
|
||||
|
||||
## ExternalBuildToolExecution failed with a nonzero exit code
|
||||
问题表现为编译到一半提示 `ExternalBuildToolExecution failed with a nonzero exit code`。这主要是因为XCode代码检索会占用非常多的内存,使得CPU线程数 * 2 > 内存GB,从而导致编译失败。
|
||||
|
||||
解决方法:
|
||||
>在CMD中输入 `defaults write com.apple.dt.XCode IDEIndexDisable 1`,禁用XCode代码检索即可。
|
||||
|
||||
## ATOMIC_VAR_INIT错误
|
||||
https://forums.unrealengine.com/t/cannot-build-ue-5-1-1-from-source-on-macos-ventura-13-3-1-xcode-14-3/885545
|
||||
macOS 13.4 Xcode 14.3编译UE5.1会报错,其原因是:
|
||||
>So it seems the error is related to the deprecation of `ATOMIC_VAR_INIT` [since C++20 2](https://en.cppreference.com/w/cpp/atomic/ATOMIC_VAR_INIT). I gather [from this table 3](https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2) that Xcode 14.3 includes a clang patch version bump from 14.0.0 to 14.0.3, and a llvm major version bump from 14.0.0 to 15.0.0. With my limited understanding of clang and llvm, I would guess that llvm 15 compiles at C++20, and therefore throws the build error, whereas the build is successful with Xcode 14.2.
|
||||
|
||||
解决方法是:
|
||||
- ShaderCompileWorker.target.cs添加下面的代码。
|
||||
- UnrealEditor.Target.cs添加下面的代码(去掉bOverrideBuildEnvironment那一行)。
|
||||
|
||||
```c++
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class YourGameTarget : TargetRules
|
||||
{
|
||||
public YourGameTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
if(Target.Platform == UnrealTargetPlatform.Mac)
|
||||
{
|
||||
bOverrideBuildEnvironment = true;
|
||||
AdditionalCompilerArguments = "-Wno-deprecated-pragma"; // you can add more separated with spaces here
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
我对文件做了一些修改`Engine/Source/Programs/UnrealBuildTool/Platform/Mac/MacToolChain.cs`,错误消失了。
|
||||
在`Engine/Source/Programs/UnrealBuildTool/Platform/Mac/MacToolChain.cs`中添加判断语句,对高版本XCode添加`-Wno-deprecated-pragma`编译变量。
|
||||
```c++
|
||||
if (CompilerVersionGreaterOrEqual(14, 0, 0))
|
||||
{
|
||||
@@ -96,7 +108,7 @@ if (CompilerVersionGreaterOrEqual(14, 0, 0))
|
||||
}
|
||||
```
|
||||
|
||||
功能齐全:
|
||||
最后修改结果:
|
||||
```csharp
|
||||
protected override void GetCompileArguments_Global(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
|
||||
{
|
||||
@@ -124,11 +136,23 @@ protected override void GetCompileArguments_Global(CppCompileEnvironment Compile
|
||||
FrameworksSearchPaths.Add(FrameworkPath.Directory.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//添加的代码在这里
|
||||
if (CompilerVersionGreaterOrEqual(14, 0, 0))
|
||||
{
|
||||
Arguments.Add("-Wno-deprecated-pragma");
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## std::ref问题
|
||||
添加头文件即可。
|
||||
```c++
|
||||
#include <functional>
|
||||
```
|
||||
|
||||
## 清理引擎构建历史&缓存
|
||||
XCode的构建历史:
|
||||
>~/Library/Developer/Xcode/DerivedData
|
||||
|
||||
本人采用删除Engine、LocalBuild文件夹中所有文件与UE5 XCode解决方案文件,再使用git恢复。最后再运行Setup.command、GenerateProjectFiles.command。
|
Reference in New Issue
Block a user