Xcode 7: changing product bundle identifier

后端 未结 6 827
执笔经年
执笔经年 2020-12-12 23:47

I\'m setting up Jenkins to automate the build process. In particular, for my needs, I\'d like to be able to set different bundle identifiers.

I\'m using the Xcode J

相关标签:
6条回答
  • 2020-12-13 00:27

    Refer to this for a simple solution to replace $PRODUCT_BUNDLE_IDENTIFIER using shell command like -

    sed -i '' 's/com.example.oldbundleid/com.example.newbundleid/g' project.pbxproj

    You can pass your variables accordingly using Jenkins/Shell.

    Alternative approach to do this is using mod-pbxproj.

    python -m mod_pbxproj -b -af PRODUCT_BUNDLE_IDENTIFIER=com.example.newbundleid -rf PRODUCT_BUNDLE_IDENTIFIER=com.example.oldbundleid project.pbxproj All

    //edit

    Old bundle id can be fetched by -

    awk -F '=' '/PRODUCT_BUNDLE_IDENTIFIER/ {print $2; exit}' project.pbxproj

    This can be stored in a string variable and used in place of com.example.oldbundleid

    0 讨论(0)
  • udit's answer is correct. The best practice is in plist set Bundle ID value as $PRODUCT_BUNDLE_IDENTIFIER. Then in Build Settings, use different configurations(Debug, Release .etc) to set up different bundle ID by required:

    You don't need xCode plugin to change bundle id anymore but need to specify configuration in there.

    0 讨论(0)
  • 2020-12-13 00:30

    If you use bundle id suffixes, don't set the Product Bundle Identifier on General tab of the Target Settings.

    Set it on the Build Settings tab.

    For example:

    com.company.app${BUNDLE_ID_SUFFIX}
    
    0 讨论(0)
  • 2020-12-13 00:33

    Faced the same problem.

    The PRODUCT_BUNDLE_IDENTIFIER is a variable in your project.pbxproj file. Change that to whatever you want and it will reflect both in your Info.plist as well as the project settings.

    0 讨论(0)
  • 2020-12-13 00:44

    For xcode 8.x

    Changing app name under Targets > your_app_name - Info > addition of a new property key does not make complete changes of app name everywhere throughout the project.

    When you do this, your project runs smoothly in your mac alone (i.e., in the system which you used to do these changes, as all your property keys & identities will be saved in your system). When you try to use your project in another system, yo'll get this weird error that your project is missing if in case your using pods in your project.

    So, to overcome this, all you gotta do some changes in Build settings, leaving General tab and Info tab untouched.

    Under Targets > Build settings, scroll to Packaging.

    Change your Product name to the desired name & Product bundle identifier to the new one. Once you do this, automatically your project display name & bundle id changes to the new one in General tab.

    0 讨论(0)
  • 2020-12-13 00:48

    You can also see the data in plain text by going to Targets and select "Levels" which will show a column including the Bundle Identifier.

    0 讨论(0)
提交回复
热议问题