title: Error Creating IPA File for Enterprise Distribution: "PackageApplication failed with exit code 1"
body: <p>I am running XCode 4.2 and when I Build, Archive, and then attempt to create the IPA file in Organizer, I get the following error message:</p>
  
  <pre><code>PackageApplication failed with exit code 1.
  Packaging application: '/Users/Brad/Library/Developer/Xcode/Archives/2011-08-06/*** 8-6-11 4.21 PM.xcarchive/Products/Applications/***.app'
  Arguments: embed=/Users/Brad/Library/MobileDevice/Provisioning Profiles/***.mobileprovision  verbose=1  output=/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/1376A091-5CA1-4393-AF29-34FFBFD49C74-1082-00000C64DB251DF1/app.ipa  sign=iPhone Distribution: ***.  
  Environment variables:
  HOME = /Users/Brad
  LOGNAME = Brad
  __CF_USER_TEXT_ENCODING = 0x1F5:0:0
  DISPLAY = /tmp/launch-r5c1Ou/org.x:0
  COMMAND_MODE = unix2003
  VERSIONER_PERL_PREFER_32_BIT = no
  PATH = /Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
  SHELL = /bin/bash
  SSH_AUTH_SOCK = /tmp/launch-SjRZET/Listeners
  Apple_PubSub_Socket_Render = /tmp/launch-4KUyaU/Render
  TMPDIR = /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/
  USER = Brad
  VERSIONER_PERL_VERSION = 5.10.0
  
  Output directory: '/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/1376A091-5CA1-4393-AF29-34FFBFD49C74-1082-00000C64DB251DF1/app.ipa'
  Temporary Directory: '/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U'  (will NOT be deleted on exit when verbose set)
  + /bin/cp -Rp /Users/Brad/Library/Developer/Xcode/Archives/2011-08-06/*** 8-6-11 4.21 PM.xcarchive/Products/Applications/***.app /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload
  Program /bin/cp returned 0 : []
  ### Checking original app
  + /usr/bin/codesign --verify -vvvv /Users/Brad/Library/Developer/Xcode/Archives/2011-08-06/*** 8-6-11 4.21 PM.xcarchive/Products/Applications/***.app
  Program /usr/bin/codesign returned 0 : [/Users/Brad/Library/Developer/Xcode/Archives/2011-08-06/*** 8-6-11 4.21 PM.xcarchive/Products/Applications/***.app: valid on disk
  /Users/Brad/Library/Developer/Xcode/Archives/2011-08-06/*** 8-6-11 4.21 PM.xcarchive/Products/Applications/***.app: satisfies its Designated Requirement
  ]
  Done checking the original app
  ### Embedding '/Users/Brad/Library/MobileDevice/Provisioning Profiles/***.mobileprovision'
  + /bin/rm -rf /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app/embedded.mobileprovision
  Program /bin/rm returned 0 : []
  + /bin/cp -rp /Users/Brad/Library/MobileDevice/Provisioning Profiles/***.mobileprovision /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app/embedded.mobileprovision
  Program /bin/cp returned 0 : []
  + /usr/bin/codesign -d --entitlements /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/entitlements_rawunFQiwaj /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app
  Program /usr/bin/codesign returned 0 : [Executable=/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app/***
  ]
  + /usr/libexec/PlistBuddy -c Set :get-task-allow NO /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/entitlements_plistNowUyBmz
  Program /usr/libexec/PlistBuddy returned 0 : []
  + /usr/bin/plutil -lint /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/entitlements_plistNowUyBmz
  Program /usr/bin/plutil returned 0 : [/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/entitlements_plistNowUyBmz: OK
  ]
  ### Codesigning '/Users/Brad/Library/MobileDevice/Provisioning Profiles/***.mobileprovision' with 'iPhone Distribution: ***.'
  + /usr/bin/codesign --force --preserve-metadata --sign iPhone Distribution: ***. --resource-rules=/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app/ResourceRules.plist --entitlements /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/entitlements_plistNowUyBmz /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app
  Program /usr/bin/codesign returned 1 : [/var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app: replacing existing signature
  codesign_allocate: object: /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app/*** malformed object (unknown load command 8)
  /var/folders/-K/-K95TJ0AGgaHq4MSn8EjL++++TI/-Tmp-/kNwZk2Uc3U/Payload/***.app: object file format invalid or unsuitable
  ]
  error: codesign failed with error 1
  </code></pre>
  
  <p>Note: I replaced any names with <em>*</em>.</p>