So, this code works with XeLaTeX
\documentclass[12pt]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{fontspec}
%\newfontfamily{\AR}[Script=Arabic]{Scheherazade}
\AtBeginDocument{
\renewcommand\textipa[2][r]{{\fontfamily{cm#1}\tipaencoding #2}}
}
\renewenvironment{IPA}[1][r]
{\fontfamily{cm#1}\tipaencoding}
{}
\begin{document}
%\textipa{\slshape pUK.t\~A}
\textipa{\slshape f@"nEtIks}
\textipa[tt]{f@"nEtIks}
\begin{IPA}f@"nEtIks\end{IPA}
\begin{IPA}[tt]f@"nEtIks\end{IPA}
\begin{IPA}\slshape f@"nEtIks\end{IPA}
\end{document}
But when I uncomment the line
%\textipa{\slshape pUK.t\~A}
just after the \begin{document}, it no longer compiles. How should I correct it?

\~Abe replaced byÃ? It certainly compiles but whether it compiles to the correct thing, I know not! – cfr Sep 19 '15 at 16:13puʁ.tɑ̃, as in https://fr.wiktionary.org/wiki/pourtant (the pronunciation ofpourtant). – usr203050 Sep 19 '15 at 16:47latex(often inside math environment). – usr203050 Sep 19 '15 at 16:50fontspecmakes the code compile as is. – egreg Feb 02 '17 at 09:31