Use xcodebuild to build workspace vs project
We have spent quite some time tuning our automated build scripts.
You can build a specific scheme that is part of a Xcode workspace (.xcworkspace) by using the command:
xcodebuild -workspace *yourWorkspaceFile* -scheme *schemeName* -sdk "*targetSDK*" -configuration *buildConfig* CODE_SIGN_IDENTITY="*NameOfCertificateIdentity*" PROVISIONING_PROFILE="*ProvisioningProfileName" OTHER_CODE_SIGN_FLAGS="--keychain *keyChainName*"
To build a Xcode project (.xcodeproj), use this:
xcodebuild -project "*path/fileName*.xcodeproj" -target "*targetName*" -sdk "*targetSDK*" -configuration *buildConfig* CODE_SIGN_IDENTITY="*NameOfCertificateIdentity*" PROVISIONING_PROFILE="*ProvisioningProfileName" OTHER_CODE_SIGN_FLAGS="--keychain *keyChainName*"
Where:
yourWorkspaceFile : path and filename of workspace file, e.g. path/CoolGame.xcworkspace * (points to ./path/CoolGame.xcworkspace)*
schemeName : name of scheme defined in project, e.g. CoolGame
targetName : name of build target in project
targetSDK : e.g. iphoneos
buildConfig : Debug, Release or Distribution
NameOfCertificateIdentity : e.g. iPhone Developer: My Name (738d039880d)
ProvisioningProfileName: e.g. Cool Game Development Profile
keyChainName: points to your keychain that can open development certificate, e.g. /Users/johnsmith/Library/Keychains/login.keychain