Xcode build error: "UTF-16 (LE) byte order mark detected"

I solved this problem in a similar way but using vscode for Mac; saving as encoding: UTF-8 without BOM, and only for the file that caused the error rather than all generated files.