title: Xcode 4.6 automatic entitlement not working - "no valid aps-environment"
body: <p>I'm getting the famous error:<br>
  <em>Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x413be0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}</em></p>
  
  <p><strong>I am able to fix it</strong> by editing the following file:</p>
  
  <pre><code>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/Entitlements.plist
  </code></pre>
  
  <p>And manually adding the aps-environment key like so:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;application-identifier&lt;/key&gt;
      &lt;string&gt;$(AppIdentifierPrefix)$(CFBundleIdentifier)&lt;/string&gt;
      &lt;key&gt;aps-environment&lt;/key&gt;
      &lt;string&gt;development&lt;/string&gt;
      &lt;key&gt;keychain-access-groups&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;$(AppIdentifierPrefix)$(CFBundleIdentifier)&lt;/string&gt;
      &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>Then, Xcode is generating correct Xcent file, which contains the aps-environment key at:  </p>
  
  <pre><code>/Users/mySelf/Library/Developer/Xcode/DerivedData/myApp-buauvgusocvjyjcwdtpewdzycfmc/Build/Intermediates/myApp.build/Debug-iphoneos/myApp.build/myApp.xcent
  </code></pre>
  
  <p>And running the App on iPhone is able to produce device token for push.<br>
  This is the only way I found to fix the issue.<br>
  ( you may use this info for your own troubleshooting in case you encounter this error )  </p>
  
  <p>Now, I have the same project running on another laptop (synced with git),<br>
  with the same Xcode version 4.6.<br>
  This problem does <strong>not occur</strong> on that laptop.<br>
  Project settings/provisioning profile,etc are all 100% the same on both machines.<br>
  ( Please trust me on this one )</p>
  
  <p>Did anyone encounter such issue with Xcode 4.6 ?<br>
  I should probably open a ticket at Apple's support as well.</p>
  
  <p>Just wondering if another more elegant solution is available.</p>
  
  <h2>Update:</h2>
  
  <p>The above fix could be sufficient only for devel stage but not for release.</p>