ijoshsmith / abandoned-strings

Command line program that detects unused resource strings in an iOS or OS X application.
MIT License
378 stars 67 forks source link

No results when '.strings' files are not UTF8 encoded #1

Closed adambolcsfoldi closed 8 years ago

adambolcsfoldi commented 8 years ago

Don't know if you've had this problem, but I got no results running abandoned-strings on my source. Turned out it was thecontentsOfFile method failing due to the encoding of the .strings files not being UTF8 encoded. I changed the method thusly to fix it.

func contentsOfFile(filePath: String) -> String {
    do {
        let usedEncoding = UnsafeMutablePointer<NSStringEncoding>()
        return try String(contentsOfFile: filePath, usedEncoding: usedEncoding)
    }
    catch { return "" }
}
ijoshsmith commented 8 years ago

Thanks Adam! I applied your fix.