Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode building application from command line

I'm using this script for building application from command line:

#!/bin/bash

TARGET="signtest"
CONFIGURATION="Debug"
SDK="iphoneos"    
IDENTITY="iPhone Developer: Marcin Zyga (CLJR93MXJ6)"
KEYCHAIN="/Users/admin/Library/Keychains/login.keychain"
PASSWORD="admin"


security unlock-keychain -p ${PASSWORD} ${KEYCHAIN}
xcodebuild -target "${TARGET}" -configuration ${CONFIGURATION} -sdk iphoneos CODE_SIGN_IDENTITY="${IDENTITY}" PROVISIONING_PROFILE="94D99766-0268-4E0E-B8D1-053063BB2DA1" OTHER_CODE_SIGN_FLAGS="--keychain ${KEYCHAIN}"

I'm trying to compile application and sign it with my provisioning profile. I'm getting:

Build settings from command line:
    CODE_SIGN_IDENTITY = iPhone Developer: Marcin Zyga (CLJR93MXJ6)
    OTHER_CODE_SIGN_FLAGS = --keychain /Users/admin/Library/Keychains/login.keychain
    PROVISIONING_PROFILE = 94D99766-0268-4E0E-B8D1-053063BB2DA1
    SDKROOT = iphoneos5.0

=== BUILD NATIVE TARGET signtest OF PROJECT signtest WITH CONFIGURATION Debug ===
Check dependencies
[BEROR]Code Sign error: The identity 'iPhone Developer: Marcin Zyga (CLJR93MXJ6)' doesn't match any valid certificate/private key pair in the default keychain


** BUILD FAILED **

This is when I'm invoking as sudo su - probably I'm missing a valid configuration in my keychain.

When I'm invoking this build script as admin user I've got this:

Build settings from command line:
    CODE_SIGN_IDENTITY = iPhone Developer: Marcin Zyga (CLJR93MXJ6)
    OTHER_CODE_SIGN_FLAGS = --keychain /Users/admin/Library/Keychains/login.keychain
    PROVISIONING_PROFILE = 94D99766-0268-4E0E-B8D1-053063BB2DA1
    SDKROOT = iphoneos5.0

=== BUILD NATIVE TARGET signtest OF PROJECT signtest WITH CONFIGURATION Debug ===
Check dependencies
[BEROR]Code Sign error: Provisioning profile '94D99766-0268-4E0E-B8D1-053063BB2DA1' can't be found


** BUILD FAILED **

My provisioning profile definitly exists.

like image 551
Ertai Avatar asked Nov 04 '22 09:11

Ertai


1 Answers

You've got two problems. The first is there's something in Xcode 4 and later that is changing what I believe is the search path or access rights of the command line build settings, because I, ALSO, am failing with the same codesign [BEROR] when building from command line but not Xcode directly.

I wish I knew the answer to the first problem. I've tried explicitly setting the developer identity, using the generic "iPhone Developer", updating the project settings to have the [sdk-iphoneos*]="", etc., and I have to yet discover the solution.

Did this used to work for you and then you did a Mac OS/Xcode update and now it doesn't? That's my dilemma.

ANYWAY, your second problem is easily fixable: Pass the entire path and filename for the PROVISIONING PROFILE, a-la "/Users/zyga/Library/MobileDevice/ProvisioningProfiles/94D99766-0268-4E0E-B8D1-053063BB2DA1.mobileprovision"

...A

like image 55
Andrew Coven Avatar answered Nov 10 '22 21:11

Andrew Coven