0

In an iOS Project with folders containing *.m files, similar to packages, one will have to run genstrings -o en.lproj *.m for each folder and match the relative en.lproj path. Is there a command that will do the drill down from the root folder?

4 Answers 4

2

You can concatenate all of the *.m files into one file and then call the genstrings on that.

I.E:

find . -name "*.m" -exec cat {} >> all.txt \;
Sign up to request clarification or add additional context in comments.

1 Comment

i have created file with your instructions but unable to use genstrings command on that. can you please elaborate the line to deal with txt file ?
2

In Greenwich we use find piped to xargs. You can see how that's done here, but it's basically:

find "path/to/directory" -name "*.m" -print0 |
  xargs -0 genstrings -s NSLocalizedString -o "path/to/output.strings"

I'd also recommend taking a look at Greenwich as it makes the whole process of localization much easier.

Comments

1

if you have a simple folder struct you probably get away with a simple

genstrings -ao <destination> <root>/*/*.m

using one * for each level of subfolder.

Alternatively and if the folders have different nesting levels you are better off using:

  find <root>/* -iname "*.m"  -type f -print0 | xargs -0 genstrings -ao <destination>

Comments

1

For me, this line just solved all problems. You even don't need to copy all m-Files to one document, before running the line in the shell. Just step into your project folder and run it, and all even the subfolders will be checked:

find . -name \*.m | xargs genstrings -o "directory/"

just create the directory before running it, otherwise you get an exception.

1 Comment

Works with Xcode11, iOS13, swift: find . -name *.swift | xargs genstrings -o "directory/"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.