Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

iOS: can I define PRODUCT_NAME (as used in Info.plist) in qmake .pro file



  • When deploying to an IOS device, the Info.plist contains an entry like

    <key>CFBundleDisplayName</key>
    <string>${PRODUCT_NAME}</string>
    

    Can I define PRODUCT_NAME somehow in the qmake .pro file (eg using PRODUCT_NAME=MyApp) or do I have to modify the Info.plist file directly?


  • Lifetime Qt Champion

    Hi,

    Is it a custom Info.plist file you are using ?


  • Qt Champions 2020

    We did this in this way:

    1. Create file 'Info.plist.in' with this content:
    ...
    	<key>CFBundleDisplayName</key>
    	<string>$$MY_COOL_PRODUCT_NAME</string>
    ...
    
    1. Create *.pro file with this content:
    ...
    ...
    
    MY_COOL_PRODUCT_NAME = MyCoolProduct
    ...
    
    } else:ios {
        # This is a workaround for the bug QTBUG-70072 for Qt 5.11.1.
        load(default_post.prf)
    ...
        info_plist.input = ios/Info.plist.in
        info_plist.output = $$OUT_PWD/Info.plist
        QMAKE_SUBSTITUTES += info_plist
        QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
    ...
    } else {
    

    But it was for Qt 5.11.1, as I remember... I don't know how it will be for a newest Qt... Maybe it was fixed in a simple way.


  • Moderators

    @marc_van_daele
    usually the replace string to the key <key>CFBundleDisplayName</key> is

    <string>${PRODUCT_NAME}</string>

    And that one is constructed via

    TARGET and QMAKE_TARGET_BUNDLE_PREFIX

    so:
    TARGET = myApp
    QMAKE_TARGET_BUNDLE_PREFIX = xx.myCompany

    results in the bundle display name: xx.myCompany.myApp



  • @SGaist I indeed have a custom Info.plist

    @kuzulis This approach works indeed. Only drawback is that I have to escape all '"' in the Info.plist since otherwise, QMAKE_SUBSTITUTES removes them

    @J-Hilk Using TARGET indeed works and seems, to me, right now, the easiest solution.


Log in to reply