I tried manay ways and can not solve this problem.
But finally I found that Rider for Unreal can automatically generate xcode project when you modify any code, so I choose to use Rider instead of XCode.
sh “/Users/Shared/Epic Games/UE_5.0/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh” -project=“/Path/To/Project/TestProj/TestProj.uproject” -game
Just some small notes for people using this command. It works for me, but I’ve found that I need to remove the quotation marks. Maybe that’s obvious to most folks, but wasn’t to me at first.
Also, you can use a relative path for the .sh file (i.e ./path/from/current/directory/GenerateProjectFiles.sh) but I was only able to make the project path work if starting the path from /Users (i.e. /Users/myuser/TestProj/TestProj.uproject)