I set xelatex as the default compiler in TeXstudio. When I run "Compile" or "Build & View", the output window shows the following message:
Process started: /usr/texbin/xelatex -interaction=nonstopmode "xxxx".tex
sh: xdvipdfmx: command not found
Error: Command crashed: /usr/texbin/xelatex -interaction=nonstopmode "xxxx".tex
Process exited normally
xdvipdfmx is internally called by xelatex, which is located in path "/usr/texbin". It
seems that the shell used in texstudio does not properly inherit environment variables from OS.
Solution 1. Add /usr/texbin to the additional search paths on the "Preferences| Build | Build Options | Additional Search Paths" page (in fact that option should automatically be set there on mac), as shown in the following figure.
Solution 2. Explicitly specify the output driver in TexStudio's "Preferences | Commands" pane, the XeLaTex field should read
/usr/texbin/xelatex -synctex=1 -interaction=nonstopmode -output-driver="/usr/texbin/xdvipdfmx -q -E" %.tex