These step are for Unreal 4.27.2 source code version + Rider 2023.1 + MacbookPro 2023(M2 Max) + macOS Ventura 13.3.1(a).
Steps
- Copy the Engine/Build/BatchFiles/Mac/Build.sh file and rename it to
Build-Tmp.sh
. - Open
Build-Tmp.sh
, and modify line 31 (mono Engine/Binaries/DotNet/UnrealBuildTool.exe "$@"
) to:mono --debugger-agent=address=localhost:34567,server=n,transport=dt_socket --debug Engine/Binaries/DotNet/UnrealBuildTool.exe "$@"
- This step is to start mono in debug client mode.
localhost:34567
is the address and port of the debug server to connect to after starting.
- Open Rider, then open UnrealBuildTool.cs, and set a breakpoint, such as L560 (code
int Result = Mode.Execute(Arguments);
). Then click the drop-down menu of the run target location in the toolbar → Edit Configurations → Upper left corner + sign → .NET → Mono Remote → In the generated page, change Port to34567
which was written in the previous step → CheckListen for incoming connections
. The name of this Configuration can be any name you like, namedUBT
here.
- This step is to set a breakpoint in the UBT project. And make a Debug configuration so that Rider can run a debug server to receive the debug client configured in step 2.
- Switch Rider to the
UBT
configuration created in step 3. At this time, only theDebug
button is clickable. Click theDebug
button, and now it will enter debug server waiting status. - Open Terminal and cd to the location where
Build-Tmp.sh
is located, then run command./Build-Tmp.sh UE4Editor Mac Development -buildscw
. - At this point, the UBT process running on the command line will start a debug client and connect to the debug server already started by Rider, and then hit the breakpoint. The effect is shown below:
My Chinense Original Version: Mac 平台,Rider debug UnrealBuildTool - 知乎