Nothing ruins the vibe of a clean file like a yellow warning banner, especially for something that was working perfectly fine yesterday.
The "problem" isn't that your code is broken; it’s just that Apple is getting stricter about text encodings in the latest OS versions. They want you to explicitly state how the file should be read (e.g., UTF-8) rather than letting the system guess.
On line 30, you just need to add the encoding parameter. For 99% of text files, .utf8 is what you want.
Change this:
let contents = try String(contentsOf: fileURL)
To this:
let contents = try String(contentsOf: fileURL, encoding: .utf8)
Why is this happening?
The Deprecation: As of macOS 15 (and iOS 18), the version of String(contentsOf:) that doesn't require an encoding is officially deprecated.
The Logic: Without an explicit encoding, the system tries to "guess" if the file is UTF-8, Windows-1252, etc. If it guesses wrong, you get weird symbols or a crash. By forcing you to add , encoding: .utf8, Apple ensures your code is more predictable and stable.
Once you add that one extra argument, that warning should vanish instantly!