Different application name depending on configuration when application name is localized in InfoPlist.strings

We use a setting with different sizes for each configuration. Like this: Target-Info-Dev.plist, Target-Info-Beta.plist ...

Thus, our configurations can have their own name CFBundleDisplayName, and we can differentiate assemblies by the name of the application on the device. For example: "DEV Appname", "BETA Appname" ...

However, now we need to localize the application name. We did this by creating localized InfoPlist.strings for each purpose:

"CFBundleDisplayName" = "<localized-appname>"; "CFBundleName" = "<localized-appname>"; 

But since the CFBundleDisplayName name is no longer derived from Target-Info- [Configuration] .plist, we cannot distinguish the application name for different configurations.

It should be noted that we have several goals for different brands of the same application, but we already got this job by getting a separate InfoPlist.strings for each goal.

Does anyone have an idea how to execute the local and configuration name of the application?

+7
ios localization configuration
source share
1 answer

The best solution

  • Modify Info.plist , set CFBundleDisplayName to a variable named $(MY_DISPLAY_NAME)

enter image description here

  1. Open the project’s or target's <Settings> tab , add a key named MY_DISPLAY_NAME in the Custom section (you need to scroll down to find this section), and then simply expand the newly added key and specify any name for each configuration, as you wish.

enter image description here

When creating a project, each variable in Info.plist will be replaced with its value.

The solution is much simpler than the original.

Original solution

I had the same requirement in my project, and then I found your question, and finally I solved it. Edit the project diagram , add a preliminary action and aftereffect script to make the changes. Like this,

Step 1. Change the application name in the Pre-actions assembly

 str="" if [ "${CONFIGURATION}" == "Debug" ];then str="dev" elif [ "${CONFIGURATION}" == "AdhocDevelopment" ];then str="dev" elif [ "${CONFIGURATION}" == "AdhocDistribution" ];then str="adhoc" elif [ "${CONFIGURATION}" == "DailyBuild" ];then str="rdm" fi perl -pi -e "s/appName[^<]*/appName${str}/g" ${PROJECT_DIR}/smd/Info.plist 

enter image description here

Step 2. Restore the application name in Building Deliveries

 perl -pi -e "s/appName[^<]*/appName/g" ${PROJECT_DIR}/smd/Info.plist echo ${PROJECT_DIR}/${INFOPLIST_FILE} > ~/tmp.txt; rm -f ~/tmp.txt 

Something to explain: Debug / AdhocDevelopment / AdhocDistribution / DailyBuild - these are the configuration names of your projects; $ {CONFIGURATION} is predefined by Xcode; perl is preferred over awk and sed, which are all pre-installed on every Mac OS X.

By the way, what I did was change appName in Info.plist, you can change your infoplist.strings. Thus, you only need one Info.plist file.

+6
source share

All Articles