Xcode 7: changing product bundle identifier

佐手、 提交于 2019-11-28 16:50:20
udit gupta

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.

Aoke Li

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.

Sarthak Singhal

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!