title: How do I codesign a Swift app via the commandline?
body: <p>I am attempting to run an enterprise signed build of my Swift app on a real phone running iOS 7.1.</p>
  
  <p>If I create the enterprise signed app via the Xcode interface, the app works perfectly.
  If I create the enterprise signed app via xcodebuild and codesign on the command line, then the app crashes on open with the following log:</p>
  
  <pre><code>Dyld Error Message:
  Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Foo
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Frameworks/libswiftCore.dylib: code signature invalid for '/private/var/mobile/Applications/96578E7F-7FE6-4603-82F2-8941561225D8/Foo.app/Frameworks/libswiftCore.dylib'
  Dyld Version: 324
  </code></pre>
  
  <p>When I create the IPA via the command line, the IPA always contains the same libswiftCore.dylib</p>
  
  <pre><code>$ md5 cli/Payload/Foo.app/Frameworks/libswiftCore.dylib
  MD5 (cli/SwiftSupport/libswiftCore.dylib) = 0fe0370b5585a88a89d230b7501aee31 &lt;- same every time; matches what is provided by Xcode
  
  $ md5 /Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
  MD5 (/Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib) = 0fe0370b5585a88a89d230b7501aee31 &lt;- Same!
  </code></pre>
  
  <p>When the Xcode UI produces the IPA, it is clear that it is somehow signing or modifying libswiftCore.dylib</p>
  
  <pre><code>$ md5 ui/Payload/Foo.app/Frameworks/libswiftCore.dylib
  MD5 (ui/Payload/Foo.app/Frameworks/libswiftCore.dylib) = df73f604b1370b19721dfa7de298340f &lt;- different every time
  </code></pre>
  
  <p>I have tried using the --deep option on codesign with no luck.</p>
  
  <p>How can I get libswiftCore.dylib to get signed correctly when building/codesigning via the command line?</p>