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

I’ve been working on a C++ based project for quite some time on Windows, but I wanted to see how the project runs on my Macbook.

After checking out the code, I couldn’t compile through the editor so I generated Xcode project files. However, when compiling through Xcode, I am hit with the following error affecting most of the source files including the “.generated” files: “UTF-16 (LE) byte order mark detected in … FILENAME HERE”.

I attempted to change text format but this error just won’t go away. Has anyone else encountered this? I get these errors even when creating a new C++ based project in the Epic Launcher. If it helps, it’s the “#include” lines the errors are located.

Still having problems with this.

Three months later, still having problems with this.

I’ve the same issue. Changing encoding in xcode 9 doesn’t help. However, I got it working by converting all the generated class and header files (using sublime 3, should be the same with other text editors ) from UTF16 to UTF-8 and it works.

I just encountered this issue in UE 4.21.0. I didn’t look deep into it, but I believe the issue was caused by a non UTF-8 symbol added in my source files. In my case, the symbol which caused issues was “©” in my copyright notice and all of my source files. Most of my files contained a replacement character (�), however the ones that had errors did not for some reason. I resolved this by removing the © and � characters from all of my source files and removing the special character from my copyright template in the project settings.

3 Likes

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.