What Does the "Text Encoding" Option in Xcode Mean?
Default Xcode UTF encoding is UTF-8.
Xcode exposes a “Text Encoding” option in the File Inspector, but its purpose today is mostly historical — and in practice, misleading. In the latest Xcode versions, including Xcode 26.1, this option creates the impression that you can choose how a file is encoded, but the feature does not actually work.
Let’s break down what this option claims to do versus what actually happens.
1. The “Text Encoding” option in Xcode 26.1 does not function
When you change the encoding in the File Inspector:
Xcode prompts for confirmation
Xcode pretends it will convert the file
But the final result is: nothing changes
Xcode does not detect the file’s actual encoding, does not convert it, and does not re-encode it to the selected option. The feature appears to be a leftover UI component that no longer matches how the Swift toolchain works.
If you expect Xcode to convert a file to UTF-16, UTF-32, ISO-Latin-1, or anything else, it won’t.
2. Xcode source files must be UTF-8
Regardless of what the UI suggests, Xcode’s only accept UTF-8 encoded source files.
If a .swift file is saved as UTF-16 or any non-UTF-8 format, Xcode displays:
The compiler does not auto-convert the file, and Xcode does not fix the encoding.
You must manually resave the file as UTF-8 with for example Visual Studio Code
3. Swift itself rejects non-UTF-8 source files
Swift source code must be valid UTF-8.1 If a .swift file is saved using UTF-16 or UTF-32, the Swift compiler immediately stops with an error and will not attempt any recovery or transcoding.
4. Conclusion
The “Text Encoding” control in Xcode looks like a real feature, but in modern toolchains it is effectively non-functional. Swift requires UTF-8, Xcode enforces UTF-8. Everything else will produce errors — and Xcode’s encoding selector won’t help you. If you’re assuming that Xcode can convert or detect encoding for you, it won’t.
Want to learn more about encodings?
This is part of a larger story: Unicode, UTF-8 as Swift’s native storage format, and the differences between encodings like UTF-8, UTF-16, and UTF-32. I cover all of that in this post:
https://forums.swift.org/t/may-swift-source-code-be-in-utf-16-in-xcode/34494/2



