The principle is to use the official command line key parameters -projectPath -buildTarget
https://docs.unity3d.com/Manual/CommandLineArguments.html
Mac system command reference, other systems can refer to the above URL
/Applications/Unity/Unity.app/Contents/MacOS/Unity -projectPath 项目路径 -buildTarget standalone
Among them, standalone is the target platform. For details, please refer to -buildTarget in the above URL.
PS: Unity crashed many times after using this command. The solution is to try a few more times. If it still doesn’t work, try another platform for a few seconds and then switch back immediately.