Using Flavors with Flutter on iOS: ${PRODUCT_NAME} not working as intended

1.6k Views Asked by At

So I am trying to setup flavors in the iOS app of my Flutter project. My aim is to be able to have multiple flavors of the app simultaneously installed on my iPhone.

In order to achieve this, I stumbled upon this official guide: https://docs.flutter.dev/deployment/flavors.

But I have encountered issues where the app ended up being named "Runner" and I could not even have multiple apps installed on my iPhone.


Let's start at the beginning.

I have 3 flavors (schemes):

  • dev,
  • mr, and
  • prod.

screenshot of the schemes

Manage Schemes modale screenshot

Each are defined for Debug, Profile and Release and I have removed the original ones.

Next step, the guide shows how to define unique bundle identifier for each scheme which in my case are as follow:

Screenshot of all unique bundle identifiers

Then we move on to the Product Name and I did exactly like the guide: Scheme's product name screenshot

Last step is to edit some fields in the Info.plist.

This is where the guide is very confusing, because it says to set ${PRODUCT_NAME} to Bundle Display Name however, in the following screenshot it clearly says CF Bundle Display Name. I tried to find the latter in Xcode but there is no such choice when browsing available keys ("+" button next to "Information Property List").

Then I opened Info.plist in Android studio to write the following keys:

<key>CFBundleDisplayName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleName</key>
<string>My Flutter App</string>

Back to Xcode, this is how it looks like now: Screenshot of Info.plist in Xcode

Unless I am wrong, to my understanding:

  • CFBundleDisplayName corresponds to Bundle Display Name from the written text in the guide,
  • while Bundle Display Name from the guide's screenshot corresponds to Bundle Name in my Info.plist (or CFBundleName in the raw version).

Then I try to build the app with the dev flavor: Screenshot of build configurations in Android Studio

But on my iPhone running iOS 12, the app is titled "Runner". Then, if I use the main.dart (mr) build config (which uses the mr flavor), the new build replaces the existing one, and it is still named "Runner".

So I believe that:

  • the naming does not work
  • the flavor system does not work as well.

Also what further confuses me, is why the guide asked to write Product Names such as "Debug Free" (or Debug Dev in my example) ??? Is that supposed to be the app name ? I am not actually looking for different names at the moment, but I want to be able to have the three flavored apps installed on my iPhone.

What am I doing wrong?


Note: the flavors system worked perfectly fine on Android

1

There are 1 best solutions below

0
Farhan Syah On

I have experienced this too. The tutorial only said to change in Project level. However, when I check at Target level, the product name is set to "Runner". Hence, all the product name will be named as Runner.

So I changed the target product name to $(PRODUCT_NAME). Then, it will properly use the PRODUCT_NAME value from the Project level.

Changet target.productName