## 安装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 source ~/.zshrc ``` ## macOS开发环境 https://ue5wiki.com/wiki/2329190d/ 运行生成解决方案.sh时会提示: >ERROR: Invalid SDK MacOSX.sdk, not found in /Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs 确认安装Xcode之后执行 ```bash sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms /Library/Developer/CommandLineTools/Platforms ``` ## 为 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 线程: > defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 16 # 编译流程 - 先编译ShaderCompileWork - 后编译UE5 macOS 13.4 Xcode 14.3编译UE5.1会报错, ```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 } ... } } ```