18

Is there a way to set the 'iOS Application Target Bundle Identifier' per 'Build Configuration' in Xamarin?

In XCode you can do that, which means that the same base code can be compiled for different enterprise customers (our case).

Xamarin Studio allows creating 'Build Configurations', and different provisioning profiles can be used in each one, however, it doesn't seem to have a way to set the Bundle Id.

Please advise. Thanks.

rufo
  • 5,158
  • 2
  • 36
  • 47
  • 2
    For whoever would like this feature to be added, I created an entry in Xamarin's uservoice: https://xamarin.uservoice.com/forums/144858-xamarin-suggestions/suggestions/4352734-allow-setting-the-bundle-identifier-per-build-conf. Votes are welcome. – rufo Aug 28 '13 at 22:43
  • There is a bugzilla comment about this here: https://bugzilla.xamarin.com/show_bug.cgi?id=1118 The response I had there was the following: "The MSBuild targets for iOS are nearing completion - they should ship as part of Xamarin.iOS for iOS 8" The feature you are after relies on the MSBuild targets being implemented. – Justyn Jul 17 '14 at 20:38
  • 1
    Update: above Bug status says now resolved. So, this "should" now be available? I cannot see it as of XS 8.9 / VS Plugin, can anyone else confirm this is now available? – WickedW May 05 '15 at 10:08

3 Answers3

12

Not directly. However you can create pre (or post) build steps scripts (see Custom Commands in your project's options), which knows among other things the configuration being built, i.e. ${ProjectConfig}.

From the script you can use a tool, like PlistBuddy, to modify the Info.plist file values.

poupou
  • 43,413
  • 6
  • 77
  • 174
  • Ok. I guess that's sufficient - it would be nice if it was a feature in the IDE tough. Thanks. – rufo Aug 27 '13 at 20:55
  • 3
    Please make your voice heard @ https://xamarin.uservoice.com/forums/144858-xamarin-suggestions – poupou Aug 27 '13 at 21:44
  • I agree with Rufo - this needs to be part of the IDE. Added 3 votes to the uservoice report. It also does not work if you use the Visual Studio Xamarin plug-in. No PlistBuddy on windows. – briangraf Sep 09 '13 at 00:28
  • 1
    Does anyone have a working example of this? In Xcode this is as easy as can be, but code signing is messing it up for me in Xamarin even when doing it in an After Build command. – Stefan Fisk Dec 11 '13 at 18:30
1

You can create and enviroment variable containing the bundle id and add it to the plist file as a pre-build step, this is what I did in my project

if [ -n "$MY_BUNDLE_ID" ]; then
    /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $MY_BUNDLE_ID" ${PROJECT_DIR}/shell/shell-Info.plist
fi
Pablo Retyk
  • 5,690
  • 6
  • 44
  • 59
0

For now, there is still no direct way to do it. Create the bundle identifier in XCode and utilize that in your Xamarin project.

KaeM
  • 225
  • 3
  • 6