If you are using TexStudio and build a document and receive the following error:
Fatal fontspec error: “cannot-use-pdftex” The fontspec package requires either XeTeX or LuaTeX. You must change your typesetting engine to, e.g., “xelatex” or “lualatex”instead of plain “latex” or “pdflatex”. For immediate help type H .
You simply need to change the build type from pdflatex to xelatex in the options (tool -> options -> build) section.