2023-06-29 11:55:02 +08:00
|
|
|
|
## 安装homebrew
|
|
|
|
|
参考:
|
|
|
|
|
- https://www.jianshu.com/p/e0471aa6672d
|
|
|
|
|
|
|
|
|
|
国内镜像安装命令:
|
|
|
|
|
```c++
|
|
|
|
|
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
安装完之后需要替换源:
|
|
|
|
|
### 1.必备设置
|
|
|
|
|
- 替换 brew.git:
|
|
|
|
|
```bash
|
|
|
|
|
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
|
|
|
|
|
```
|
|
|
|
|
- 替换 homebrew-core.git:
|
|
|
|
|
```bash
|
|
|
|
|
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
|
|
|
|
|
```
|
|
|
|
|
### 2.按需设置
|
|
|
|
|
- 替换 homebrew-cask.git:
|
|
|
|
|
```bash
|
|
|
|
|
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
|
|
|
|
|
```
|
|
|
|
|
- 替换homebrew-bottles:
|
|
|
|
|
首先要先区分你的mac用哪种终端工具,如果是 bash,则执行:
|
|
|
|
|
```bash
|
|
|
|
|
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
|
|
|
|
|
source ~/.bash_profile
|
|
|
|
|
```
|
|
|
|
|
若是 zsh,则执行:
|
|
|
|
|
```bash
|
|
|
|
|
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
|
2023-07-04 11:27:31 +08:00
|
|
|
|
source ~/.zshrc
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## macOS开发环境
|
|
|
|
|
https://ue5wiki.com/wiki/2329190d/
|
|
|
|
|
|
2023-07-04 12:10:46 +08:00
|
|
|
|
运行生成解决方案.sh时会提示:
|
|
|
|
|
>ERROR: Invalid SDK MacOSX.sdk, not found in /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs
|
|
|
|
|
|
2023-07-04 11:27:31 +08:00
|
|
|
|
确认安装Xcode之后执行
|
|
|
|
|
```bash
|
|
|
|
|
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms /Library/Developer/CommandLineTools/Platforms
|
2023-07-04 12:10:46 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 为 xcode 开启多线程编译
|
|
|
|
|
AMD CPU信息查看APP:
|
|
|
|
|
https://github.com/trulyspinach/SMCAMDProcessor/releases/tag/0.7.1
|
|
|
|
|
|
|
|
|
|
首先看一下 Mac 的硬件配置:
|
|
|
|
|
>sysctl machdep.cpu
|
|
|
|
|
|
|
|
|
|
找到 `machdep.cpu.core_count` 字段,其中的数值就是 Mac 的核心数。然后可以给 xcode 开启多线程,数量数为核心数 *2,如我的是 8 核,就可以开启 16 线程:
|
2023-07-04 13:04:13 +08:00
|
|
|
|
> defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 16
|
|
|
|
|
|
|
|
|
|
# 编译流程
|
|
|
|
|
- 先编译ShaderCompileWork
|
|
|
|
|
- 后编译UE5
|
|
|
|
|
|
2023-07-04 13:56:55 +08:00
|
|
|
|
## 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会报错,解决方法是:
|
|
|
|
|
- ShaderCompileWorker.target.cs添加下面的代码。
|
|
|
|
|
- UnrealEditor.Target.cs添加下面的代码(去掉bOverrideBuildEnvironment那一行)。
|
|
|
|
|
|
2023-07-04 13:04:13 +08:00
|
|
|
|
```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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-04 13:56:55 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
2023-07-04 13:04:13 +08:00
|
|
|
|
```
|