Again, the problem is that calling -[ACAccountStore requestAccessToAccountsWithType:options:completion:] on OS X 10.11 for a new app will ask the user for permission then always give the error "Setting TCC failed." (Reported as Radar #23114308 for any Apple people reading this.)

While this bug remains, I came across a solution in Apple's developer forums. It's a hack, and probably won't work in sandboxed apps, but does work for non-sandboxed apps.

Basically, if that error is received, we can edit the "~/Library/Accounts/Accounts3.sqlite" database directly via the sqlite3 command line tool.

I've put together an open-source demo app to show this technique, called AccountsDemo.

The AccountsDemo sample project includes a button to load the Twitter accounts, a checkbox to use the above hack, and a button to remove the app from the accounts database (so you can re-try it). Try clicking the load button with the checkbox unchecked, to confirm that you get the error, then check the box and try loading again, and it should work.