Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign location specific BundleDisplayNames for different Targets

I have 2 Apps : Free & Full I have 2 Languages : English & German

This results in 4 different App-Names

How can I achieve this.

Actually all my targets have the name "Free" in it, even it the the Full Version.

I know: I have 1 InfoPlist.strings File, which is multiplied by Localization and I can assign them to targets. So for 1 App I can localize the BundleDisplayName.

But how can I assign the specific names for the second app ?

like image 606
mcfly soft Avatar asked Nov 02 '15 14:11

mcfly soft


People also ask

How do I change my bundle name?

Change the Bundle IDChoose your project from the left side, then your app target under TARGETS, select the General tab and rename the Bundle Identifier.

What is bundle display name Xcode?

The user-visible name for the bundle, used by Siri and visible on the iOS Home screen.

How do I change my app Display Name?

Go to the app > manifests > AndroidManifest. xml file and change the android:label field in your application node in AndroidManifest.

How do I change the display name in Xcode project?

Build Settings> Change "Product Name" TARGETS> Select app> Change "Display Name" Project Navigator> Select project name> Double-click> Change "project name"> Rename> Mange Scheme> Change "Scheme name" info.


2 Answers

PlistBuddy is your friend here. What you need to do is update your plist in a build time.

  1. You have to create custom scheme for every target you have (I assume you are already has that)
  2. In your xcode go to scheme and add post action like that to custom scheme target:

enter image description here

Here is the code:

infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
/usr/libexec/PlistBuddy -c "Set CFBundleName some_new_name_here" "$infoplist"

Important thing with this approach is that you're not change nothing in your plist file but with post-actions you already changing the packet prepared for device, so you keep your code repository nice and clean.

like image 92
Jakub Avatar answered Oct 19 '22 22:10

Jakub


Associate InfoPlist.strings to targets

From the Apple Developer Technical Notes:

If your app supports localization, be sure to localize CFBundleDisplayName by adding it to all your language-specific InfoPlist.strings files. Furthermore, be sure to use a name that complies with the App Review Guidelines for your app.

Prerequisites

  • I am assuming you already have multiple targets.

  • I am also assuming you already have an InfoPlist.strings file. If your do not, code > File > File... > Resource > Strings File > Next > Save As: InfoPlist > Base.lproj > Target: the english target > Create

  • Ensure you have enabled this in your Info.plist:

    <key>LSHasLocalizedDisplayName</key>
    <true/>
    

Step by step

  1. In Project Navigator, select InfoPlist.strings.
  2. In File Inspector > Localization, select all the languages. This will create and/or copy said InfoPlist.strings into their respective locations. Localize InfoPlist.strings
  3. Would you want to add languages, you achieve this in Project Navigator > project > Project & Target List > Project > Info > Localizations > +. Again, keep Use Base Internationalization.
  4. Unfortunately, when you execute step 2., Xcode does all the magic for you. It is worth noting that in versions of Xcode where that magic did not happen, you had to do the associations by hand. Step 5. is about reverting the magic.
  5. Remove InfoPlist.strings from the Project Navigator. Of course, only Remove References when prompted.
  6. In the Finder, locate en.lproj, drag it onto your Project Navigator, pick Create Groups, add to target your English, or Base target, Finish
  7. Repeat step 6 with de.lproj, fr.lproj, each time dragging the entire .lproj from the Finder, and associating with the appropriate target.
  8. Some .lproj may contain other localized files for which you want to enjoy the magic of step 3. Simply remove their references.
  9. You are done.

The final setup, for say the German language, will look like this in the File Inspector:

One InfoPlist.strings per target


References:

Share localization across targets:

This is the general method to achieving localization. See https://stackoverflow.com/a/33749062/218152.

Specific localization to specific targets:

This is only useful if you want to explicitly control which languages go into which target. See https://stackoverflow.com/a/33791181/218152.

like image 38
SwiftArchitect Avatar answered Oct 19 '22 23:10

SwiftArchitect