'Generate xcode .stringdict file from script

I am trying to create a script (the language is not relevant, but it is a mix of node/js and bash) to generate plural localization files for xcode known as .stringdict format.

The Apple documentation as usual doesn't help (to be kind) and could only find help about the format in this archive.

The problem is that even just copying an existing valid file and re-creating it from shell, it apparently gets invalidated for not being in the correct format. Trying to open it from Xcode results in the following error:

Tried to create a document (class: IDEPlistDocument) and got a document with a different, non-conforming fileType back instead.

Reading around it appears that xcode "conveniently" converts the file to binary adding some metadata. I don't see the sense in this, but i tried anyway to open and re-save the file with PlistBuddy (which in the while dear Apple has removed from standard path and for which there appear to be ZERO documentation around, despite being a long used official tool), something like:

/usr/libexec/PlistBuddy -x -c "Print" .<project-root>/Resources/de.lproj/Localizable.stringsdict

with no success.

I have tried as well with plutil and again, no luck:

plutil -convert xml1 ./<project-root>/Resources/de.lproj/Localizable.stringsdict 

TLDR: How can i create a stringdict file that is readable by xcode from a script (in any language, using any library or tool)?



Solution 1:[1]

I had the same issue and

plutil -convert binary1 Localizable.stringsdict

helped me, it's not user readable but Xcode can open it.

But after a while i've realized that restarting Xcode also works after running plutil -convert xml1 Localizable.stringsdict

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ismailgulek