CODE_SIGN_IDENTITY parameter for xcodebuild (Xcode 4) CODE_SIGN_IDENTITY parameter for xcodebuild (Xcode 4) shell shell

CODE_SIGN_IDENTITY parameter for xcodebuild (Xcode 4)


A newer xcodebuild now allows settings to be specified.Taken from developer.apple.com:

xcodebuild [-project projectname] [-target targetname ...]           [-configuration configurationname] [-sdk [sdkfullpath | sdkname]]           [buildaction ...] [setting=value ...] [-userdefault=value ...]

I also found this resource for explaining the available settings

CODE_SIGN_IDENTITY (Code Signing Identity)    Description: Identifier. Specifies the name of a code signing identity.    Example value: iPhone Developer

However, PROVISIONING_PROFILE is missing from the index of available commands.

The command I finally used specified "CODE_SIGN_IDENTITY" & "PROVISIONING_PROFILE" settings.

xcodebuild -sdk <iphoneos> -target <target_name> -configuration <Debug> CODE_SIGN_IDENTITY="iPhone Developer: Mister Smith" PROVISIONING_PROFILE="XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"


I had following problem:

Our developers used the 'iPhone Development' signing identity, but I needed to use the 'iPhone Distribution' signing identity for our automated integration system.

So I added the line:

codesign -f --sign "iPhone Distribution: XXXXXXX" ${PATH_TO_APP}

between the xcodebuild and the xcrun commands to swap the code signing identities (see the -f flag).


As far as I know in Xcode 4 signing is done with xcrun tool:

/usr/bin/xcrun -sdk "iphoneos" PackageApplication -v "myapp.app" -o "myapp.ipa" --sign "iPhone Developer: XXXXX" --embed "XXXXX.mobileprovisioning"

It is a bit uncomfortable to use because you must specify both your identity and mobileprovisioning file. Especially uncomfortable if you use last one from ~/Library/MobileDevice/Provisioning Profiles/ directory because its name is changed every time provisioning profiles are updated automatically from Provisioning Portal.