title: xcodebuild how to sign app with command line?
body: <p>I am trying to export an ipa using the command line, I can't do that within Xcode because the app is made for a client and I am not a member of his team (I really hope Apple changes that and makes it work like in Xcode 5 :/ ) </p>
  
  <p>Anyway, I did more research and tried this command: </p>
  
  <pre><code>xcodebuild -exportArchive -archivePath pcdev.xcarchive -exportPath ~/Desktop/playcadeAdHoc.ipa -exportFormat ipa -PROVISIONING_PROFILE= xxxxxxx-8a61-4264-8fe9-0513bd7935e6 -CODE_SIGN_IDENTITY=iPhone Developer:xxxxx
  </code></pre>
  
  <p>It did export the .ipa but I wasn't able to run it on my phone; I was stuck in the installing state. I went through the logs of the command and I think this one is causing the problem: </p>
  
  <blockquote>
    <h3>Checking original app</h3>
    
    <ul>
    <li>/usr/bin/codesign --verify -vvvv /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app
    Program /usr/bin/codesign returned 1 : [/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app: 
    a sealed resource is missing or invalid
    file missing: /private/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-entitlements.xcent
    ]</li>
    </ul>
    
    <p>Codesign check fails :
    /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app:
    a sealed resource is missing or invalid file missing:
    /private/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-entitlements.xcent</p>
  </blockquote>
  
  <p>I am sure that am using the correct provisioning and code signing name, also in Xcode I changed the scheme archive setting to debug instead of release in order to work with adhoc and development identity. </p>
  
  <p>My experience with Apple tools is very limited so please try to explain the solution as much as possible. </p>
  
  <p><strong>EDIT:</strong>
  I also tried this method it doesn't gave me any error but still the app is stacked in "installing...": </p>
  
  <pre><code>xcrun -sdk iphoneos PackageApplication ~/Desktop/finalX.xcarchive/Products/Applications/games.app -o ~/Desktop/playcadetest.ipa --sign "iPhone Developer: Name Name (xxxxxxxx)" --embed ~/Desktop/p/adhoc.mobileprovision
  </code></pre>
  
  <p>Thank you</p>