Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - genstrings: couldn't connect to output directory en.lproj

I searched for this error online and here. Online it shows me results in a different language then english nice Google. Here it has one post and a guy that never really answered the guys question.

I have my xcode project folder on my desktop. Inside the project folder I have an en.lproj folder that has both iPad and iPhone storyboards inside along with a localization.plist file. However when I launch the project in Xcode this en.lproj folder is nowhere to be found. So this might be the problem?

With the project folder on my desktop I launch terminal type in: cd

then drag my project folder into Terminal and it gives me the path. I then paste this line of code into the Terminal

find . -name *.m | xargs genstrings -o en.lproj

I get this error message in the Terminal:

genstrings: couldn't connect to output directory en.lproj

it prints this line multiple times and then says my project is a path to a directory?

No .strings file is made. Any thoughts on what I am doing wrong? I got UILabels that I dragged and dropped from inside Storyboards, but I also I strings that are coded with

NSLocalizedString(@"First Level Passed", @"This is a message displayed on screen to allow the user to know they have passed the first level!");

So the above Terminal code snippet should be finding those NSLocalizedStrings right? I think it isn't even getting to find the en.lproj folder in the first place but I don't know?

Any help would be great.

like image 550
I00I Avatar asked Sep 12 '12 11:09

I00I


2 Answers

I got the same error, while execute the following command as per the tutorials.

genstrings -o en.lproj *.swift

Above command gives me following error:

genstrings: couldn't connect to output directory en.lproj

My issue:

  • I try to implement above command on my own directory(i.e. subdirectory of root project directory) where all the ".lproj" directory is there. - that gives me above error.
  • Then i have removed old “Localizable.strings” on sub-folder "Localization". and created new “Localizable.strings” in root directory. - here i got no errors but nothing is happen as per "genstrings" command.

Solution:

On command line move to the Root directory of project where you can get the all the ".lproj" directories.

Add the path of file, where you listed all the "NSLocalizedString("TEXT", comment: "COMMENT")" - in my case i have listed everything on "Constants.swift" file.

So, i have execute the following command and its work like charm.

 genstrings -o en.lproj/ #ProjectPath#/Constants/Constants.swift

Note: File path will be easily get via just drag file from the Xcode and drop to the terminal.

like image 133
g212gs Avatar answered Nov 15 '22 18:11

g212gs


Better late then never,

you are creating a file (localizable.strings) in the folder projectroot/en.lproj. If this folder doesn't exist you get this error message. Simply create the folder en.lproj in the root and the command should work.

like image 32
Saren Inden Avatar answered Nov 15 '22 18:11

Saren Inden