Xcode 7: changing product bundle identifier
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.
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.
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
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.