title: Code sign validation failing during xcodebuild and Failed to read entitlements for xcrun
body: <p>I have tried every available solution over here and on the internet.</p>
  
  <p>I am trying to automate the iOS build process, and the clean, build and archive process succeed with these 5 warnings (errors) failing code sign validation.</p>
  
  <pre><code>warning: The CodeResources file is missing and it must be a symbolic link to      _CodeSignature/CodeResources.  Make certain that the bundle is on a locally-mounted volume (not a remote SMB volume), and be certain to use the Mac OS X Finder to compress it (-19062)
  Unable to validate your application. - (null)
  
  warning: iPhone/iPod Touch: application executable is missing a required architecture.      At least one of the following architecture(s) must be present: armv6 (-19033)
  Unable to validate your application. - (null)
  
  warning: Icon specified in the Info.plist not found under the top level app wrapper:  (-19007)
  Unable to validate your application. - (null)
  
  warning: iPhone/iPod Touch: Info.plist: Unable to verify icon dimensions, no icon found.  Your MinimumOSVersion is below 3.2, so you must define CFBundleIconFile or provide a default Icon.png that is 57x57. (-19013)
  Unable to validate your application. - (null)
  
  warning: Application failed codesign verification.  The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)
  </code></pre>
  
  <p>If i try to ignore the warning or use the debug config to skip validating the codesign,  xcrun to package the .app to .ipa fails with following error</p>
  
  <pre><code>env SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk 
  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication -v 
  /Users/XXXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_11_31_23.app -o 
  /Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_11_31_23.ipa 
  --sign iPhone\ Distribution 
  --embed/Users/XXXXXXX/source/digital_hub/cms/cms_local_repo/6072/76/XXXXXXXX_AppStore_11_07_1373971044.mobileprovision
  
  error: Failed to read entitlements from '/var/folders/n6/8tsx1pss5v3fq3sfpz8379r0ms3b7m/T/Rm5MudWNER/Payload/Test_22_07_13_11_31_23.app'
  </code></pre>
  
  <p>My xcodebuild command is following as I am working with workspaces</p>
  
  <pre><code>/usr/bin/xcodebuild -verbose 
  -workspace /Users/XXXXX/source/digital_hub/cms/git_local_repo/11330/80/PDFReader.git/XXXXXX.xcworkspace 
  -scheme _DEFAULT -sdk iphoneos -configuration Release CODE_SIGN_IDENTITY="iPhone Distribution:" 
  PROVISIONING_PROFILE=73DE6F20-FAB9-46A2-9825-35D7DE82CD4D 
  CONFIGURATION_BUILD_DIR=/Users/ahsandar/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.app
  OTHER_CODE_SIGN_FLAGS="--keychain /tmp/xcoder1374496105" clean
  </code></pre>
  
  <p>My xcrun command looks like this</p>
  
  <pre><code>/usr/bin/xcrun -log -sdk iphoneos PackageApplication -v 
  "/Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.app" -o 
  "/Users/XXXXX/source/digital_hub/cms/final/cms_repo/H1/45/ZD/0v/U9/Rr/gT/builds/Test_22_07_13_13_26_29.ipa" --sign "iPhone Distribution:" 
  --embed "/Users/XXXXX/source/digital_hub/cms/cms_local_repo/11330/80/XXXXXX_AppStore_11_07_1373
  </code></pre>
  
  <p>I am using xcoder gem to create temporary keychain to add my p12 in it. all verification on the archive are successful using the command line tools for codesign.</p>