Disable automatic InfoPlist.xcstrings generation

Hi all,

I am trying to localise the purpose strings in my Info.plist file, for that I am using the InfoPlist.xcstrings file. In my app I have multiple targets, each with a different display name, the problem that I am facing is that when the InfoPlist.xcstrings file is automatically updated in each build the CFBundleDisplayName is always added to the file which forces me to have just one name for every target. So, I would like to know how others approach this problem and how can I resolve my situation. The ideal solution was that there was a way for me to disable this automatic generation (or at least trigger it by hand) once I have added all the purpose strings that I want to localise in multiple languages. If not, having one InfoPlist.xcstrings per target will also so it, although it will be a little harder to maintain. AFAIK, there's no documentation on the InfoPlist.xcstrings generation, so any help will be very much appreciated.

Thank you all in advance

Answered by Developer Tools Engineer in 797378022

The recommended approach here is to have separate InfoPlist.xcstrings files per target. Otherwise you would not be able to effectively translate the app name without every target having the same name.

There is no setting for disabling extraction of CFBundleDisplayName from the Info.plist. Even if it wasn't in the String Catalog, Xcode would generate it again when exporting localizations to allow translators to translate it.

The naming convention of InfoPlist.xcstrings is as follows:

  1. The Info.plist file (if you have one) should not be added to any targets but referenced by the "Info.plist File" build setting in the relevant target. The corresponding .xcstrings file should be added to the target.
  2. "InfoPlist.xcstrings" always works to refer to the strings for the Info plist (regardless of the name of the Info plist file and even if it is fully generated at build time).
  3. If a target's Info plist file is named "CustomName.plist", then the xcstrings file may be named "CustomName-InfoPlist.xcstrings".
  4. If a target's Info plist file is named "CustomNameInfo.plist", then the xcstrings file may be named "CustomNameInfoPlist.xcstrings".
  5. If no explicit Info.plist file is in the project but you are using auto-generation via the "Generate Info.plist File" build setting, then you can name your xcstrings file "TargetName-InfoPlist.xcstrings".

The recommended approach here is to have separate InfoPlist.xcstrings files per target. Otherwise you would not be able to effectively translate the app name without every target having the same name.

There is no setting for disabling extraction of CFBundleDisplayName from the Info.plist. Even if it wasn't in the String Catalog, Xcode would generate it again when exporting localizations to allow translators to translate it.

The naming convention of InfoPlist.xcstrings is as follows:

  1. The Info.plist file (if you have one) should not be added to any targets but referenced by the "Info.plist File" build setting in the relevant target. The corresponding .xcstrings file should be added to the target.
  2. "InfoPlist.xcstrings" always works to refer to the strings for the Info plist (regardless of the name of the Info plist file and even if it is fully generated at build time).
  3. If a target's Info plist file is named "CustomName.plist", then the xcstrings file may be named "CustomName-InfoPlist.xcstrings".
  4. If a target's Info plist file is named "CustomNameInfo.plist", then the xcstrings file may be named "CustomNameInfoPlist.xcstrings".
  5. If no explicit Info.plist file is in the project but you are using auto-generation via the "Generate Info.plist File" build setting, then you can name your xcstrings file "TargetName-InfoPlist.xcstrings".

Hi,

Thank you for you response!

I've followed your instructions and I've created a xcstrings file per each Info.plist file that I use. Now, for example, I've created Info-dev-InfoPlist.xcstrings, which works as intended and picks up the content of my Info-dev.plist file and let's me localise every purpose string as well as the name of the app.

The problem now is that the app is not showing the correct language when showing the purpose string. If I change the language of the device to Spanish (as well as the language for the app) I still see the purpose strings in English, which was the language I wrote them initially in the plist file. Am I missing something? Is there any configuration that I should modify so that the language is correctly picked up by the device when showing the purpose strings?

Thank you in advance.

Disable automatic InfoPlist.xcstrings generation
 
 
Q