Search code examples
iosxcodexcode4buildcode-signing

How is code signing done in Xcode 4.5


I have a script for building my app that is broken since updating to Xcode 4.5. The problem is code signing. When I run the following:

/usr/bin/xcrun \
    -sdk iphoneos \
    PackageApplication \
    -v "${BUILD_DIR}/${APPLICATION_NAME}.app" \
    -o "${APP_ARCHIVE}" \
    --sign "${DEVELOPER_ID}"
    --embed "${PROVISIONING_PROFILE}"

I get the following error:

error: /usr/bin/codesign --force --preserve-metadata --sign iPhone Developer: Apple Developer --resource-rules=/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app/ResourceRules.plist /var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app failed with error 1. Output: /var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app: replacing existing signature

codesign_allocate: object: /private/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app/Blah malformed object (unknown load command 34)

/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app: object file format unrecognized, invalid, or unsuitable

Something is going wrong with the code signing where it was working fine with Xcode 4.3 before. Can code signing still be done with the same command? Is this "unknown load command" the culprit, and if so, what is it, and how would one go about finding and fixing it?


Solution

  • It turns out upgrading XCode from App Store does NOT automatically upgrade everything.

    Go to Preferences / Downloads and make sure the latest Command Line Tools are installed.