Before even talking about the derivative of a function, you need to check wether the function makes sense.
Let $f(t)=\frac{\cos(tx)}{t}$
Then $f$ is defined for every $t $ except $t=0$. If we want to start talking about
$\int\limits_0^x {f(t)}dt = \int\limits_0^x {\frac{{\cos (tx)}}{t}}dt $
we thus have to take extra care about what happens near $0$. Clearly, we want to consider an improper integral. The function $f(t)$ is continuous on any $[\epsilon,x]$ for $x,\epsilon>0$, thus integrable on $[\epsilon,x]$, so we want to look at $\epsilon \to 0^+$.
$\int\limits_\epsilon ^x {f(t)}\,dt = \int\limits_\epsilon ^x {\frac{{\cos (tx)}}{t}} \, dt$
But
$\frac{{\cos (tx)}}{t} = \frac{1}{t} - x^2\frac{{t{}}}{{2}} + o\left( {{t}} \right)$
so,
$\int\limits_\epsilon ^x {\frac{{\cos (tx)}}{t}} = \log x \color{red}{- \log \epsilon } - {x^2}\frac{{{x^2}}}{4} + {x^2}\frac{{{\epsilon ^2}}}{4} + o(t^2)$
Do you see now what's the problem when $\epsilon\to 0^+$?