Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake generate xcode project with localizations

We've are developing our OSX project using cMake as a tool to create the Xcode project.

However, it turns out we now need some localization, for which we need both English and German .xib files (or .strings to generate them, that's not the important bit).

We have the files in the right place and correctly created, but when cMake generates the project, the files are inserted into the Xcode project as two completely separate and independent files, such as:

Foo.xib Foo.xib

Instead of two "sub-files" under the same name:

Foo.xib - Foo.xib (English) - Foo.xib (German)

If i drag and drop the xib's that are in en.lproj and sv.lproj directly to the resources folder in the project explorer: Xcode automatically detects that this is some different languages of the same UI, hence the languages are added in the project settings automatically. Also the xibs get a MainMenu.xib group in the project explorer three, consisting of both the languages.

I try to add the localized xib's to the project through cmake. They get added to the resources folder but not as identified localizations, I only get two xibs in the project explorer three no localization no connection between them.

How can I make the localization work through cmake generation?

set(CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS_MACOSX
  mac/en.lproj/MainMenu.xib
  )

  set(CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS_MACOSX
  mac/sv.lproj/MainMenu.xib
  )

set(CEFCLIENT_RESOURCES_SRCS
  ${CEFCLIENT_RESOURCES_MAC_SRCS}
  ${CEFCLIENT_RESOURCES_MAC_ENGLISH_LPROJ_SRCS}
  ${CEFCLIENT_RESOURCES_MAC_SWEDISH_LPROJ_SRCS}
  ${CEFCLIENT_RESOURCES_RES_SRCS}
  )

Is there a way to generate the Xcode projects through cmake with the .lproj bundles working?

like image 731
David Karlsson Avatar asked Apr 08 '15 14:04

David Karlsson


1 Answers

We just did this ourselves. Unfortunately the solution is not pretty. I ended up writing my own python script using mod_pbxproj to modify the xcode project after cmake generated it. If you can get away with using a regular xcode project instead of a cmake generated one, I think you are better off. What you have to do to make XCode recognize a set of files as localizations is pretty complex.

like image 85
Paul Franceus Avatar answered Oct 07 '22 11:10

Paul Franceus