Reputation: 8214
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 Jenkins plugin to set the bundle identifier:
The problem is that this will change the bundle identifier in the Info.plist file and in MyTarget > General > Bundle Identifier. But it won't change the bundle identifier in Build Settings > Packaging > Product Bundle Identifier.
The same thing happens if I do it manually. I create a new project in Xcode 7. By default, the three values are:
When I change the value in the Info.plist
file like this:
The other two value will be:
So how you can see the value in Build Settings is not changing. If I'm in Xcode I change that value manually, but if I'm building the project in Jenkins this is a bis issue.
Anyone encountered the same problem? How do you tackle it?
Thanks!
Upvotes: 52
Views: 56544
Reputation: 253
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 you're project is missing if in case you're using pods in the 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.
Upvotes: 3
Reputation: 16124
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}
Upvotes: 2
Reputation: 796
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.
Upvotes: 37
Reputation: 113
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.
Upvotes: 0
Reputation: 675
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
Upvotes: 15
Reputation: 509
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.
Upvotes: 30