UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Genstring command not working in terminal !!

Forums > SwiftUI

I am trying to generate Localizable strings using genstrings -SwiftUI *.swift command, but terminal is not able to find it. I tried checking solution online where it's suggested to use find ./ -name "*.swift" -print0 | xargs -0 genstrings -a -SwiftUI -o en.lproj, but i am not sure what i should replace en.lproj with, or is it even mandatory?

If i execute above command withou -o, it's generating the Localizable strings in project, but they are greyed out. So, i tried checking error by executing pl < Localizable.strings in terminal, in my project directory. Below is the output-:

*** Exception parsing ASCII property list: NSParseErrorException Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 1" UserInfo={NSDebugDescription=Unexpected character / at line 1, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character '0x0' at line 9" UserInfo={NSDebugDescription=Unexpected character '0x0' at line 9}}

Xcode error -:

no --inputencoding specified and could not detect encoding from input file

I have checked line 1 there is no such / unexpected character.Can anyone suggest what's going wrong?

Thank you in advance.

3      

I'm stuck as well. genstrings successfully made a Localizable.strigns file for me but I get the error "could not decode input file using specified encoding: Unicode (UTF-8), and the file contents appear to be encoded in Unicode (UTF-16)" on the first line and I don't know where the error is.

Also, it strangely made this line:

"%@:\n%@" = "%1$@:\n%2$@";

3      

Update (hopefully this helps somebody else):

In my Localizable.strings file I changed my Text encoding to UTF-16. (It's default was at UTF-8.) This text encoding parameter can be found at File Inspector > Text Settings > Text Encoding. When you switch to UTF-16, Xcode will ask your if you want to Convert it or Reinterpret it. I honestly don't know. I just tried Reinterpret since it seemed less scary. It compiled now and I think it's working fine so far. We'll see.

I believe this issue might have happened because Swift 5 switched from UTF-16 to UTF-8 and I guess Localizable.strings is expecting UTF-16. Idk.

4      

I had the same problem, and realized my problem was:

All my views swift files were under another folder called Views.

3      

It was resolved for me with this command

genstrings -SwiftUI

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.