Launchd not able to access Mac OS keychains

I ran into this today too.

It seems to be not well documented, but if you add the following to your plist your application will be able to see the user keychains when running as a LaunchAgent:

<key>SessionCreate</key>
<true/>

Credit to:

  • Missing certificates and keys in the keychain while using Jenkins/Hudson as Continuous Integration for iOS and Mac development
  • https://serverfault.com/questions/328785/how-do-i-launch-a-process-as-a-specific-user-at-startup-on-os-x/