title: Codesigning ios app from the command line
body: <p>I'm working on creating a command line workflow for my ios development and I'm stuck at the last stage: codesigning.</p>
  
  <p>I built an app for armv7 and armv7s, link it and create the app bundle:</p>
  
  <pre><code>$ codesign -d -v path/to/myapp.app
  Executable=/path/to/myapp.app/myapp
  Identifier=com.mycompany.myapp
  Format=bundle with Mach-O universal (armv7 armv7s)
  CodeDirectory v=20200 size=2292 flags=0x0(none) hashes=105+5 location=embedded
  Signature size=4332
  Signed Time=Sep 7, 2014, 2:47:55 AM
  Info.plist entries=26
  TeamIdentifier=XXXXXX
  Sealed Resources version=2 rules=5 files=3
  Internal requirements count=1 size=192
  </code></pre>
  
  <p>I get a codesigning hash XXXXX from:</p>
  
  <pre><code>$ security find-identity -pcodesigning -v
    1) XXXXX "iPhone Developer: My Name (YYYY)"
       1 valid identities found
  </code></pre>
  
  <p>However, after I codesign using the following:</p>
  
  <pre><code>codesign --force -vvvv --sign XXXXX --resource-rules=path/to/myapp.app/ResourceRules.plist --entitlements path/to/myapp.xcent path/to/myapp.app
  path/to/myapp.app: replacing existing signature
  path/to/myapp.app: signed bundle with Mach-O universal (armv7 armv7s) [com.mycompany.myapp]
  </code></pre>
  
  <p>It still seems to be unhappy:</p>
  
  <pre><code>$ codesign --verify -vvvv path/to/myapp.app
  path/to/myapp.app: invalid Info.plist (plist or signature have been modified)
  In architecture: armv7s
  </code></pre>
  
  <p>As a reference I built a (similar) app using xcode (I actually used the codesign line from the logs to sign this app), and it works just fine:</p>
  
  <pre><code>$ codesign --verify -vvvv path/to/otherapp.app
  path/to/otherapp.app: valid on disk
  path/to/otherapp.app: satisfies its Designated Requirement
  </code></pre>
  
  <p>I'm definitely sure that I have correct codesigning hash, since I have signed and deployed apps via xcode. I'm just trying to reproduce the same steps on the command line and failing miserably. Obviously if I changed info.plist or something, I would expect to see this error, but I don't expect to see it right after I do the codesign step. Some black magic is at work here. Could anyone shed some light or help with some pointers please?</p>
  
  <p><em>EDIT</em>:</p>
  
  <p>I removed armv7s and just built armv7 and now it seems happy at the codesign verification stage, however I still can't deploy the app with the following error from the logs:</p>
  
  <p>installd[26777] : 0x10050c000 verify_signer_identity: MISValidateSignatureAndCopyInfo failed for /var/tmp/install_staging.Mvi7tR/myapp.app/myapp: 0xe8008019</p>
  
  <p>I have no idea what's going on :\</p>
  
  <p><em>ANOTHER EDIT</em>:</p>
  
  <p>I got the codesign verification to fail again, heh. So, if I verify myapp.app, then it says everything is OK. However, if I try to verify myapp.app/myapp binary directly, then it says that verification failed (with the above error except for architecture armv7)</p>