I have spent my last five hours looking for this weird situation a reasonable explanation.
Here is the warning:
ld: warning: directory not found for opt
For me, the bad path was under Framework Search Paths.
The easiest way to find where the bad path is, is to type a part of it in the search box on the top right. That will filter the list to only that one bad path. Deleting it, as the other answer suggests, fixes the problem.
See this answer for more info.