Search code examples
ioskeychain

Is there a way to list keychain access groups in an iOS app at runtime?


Is there a way to get a list of keychain access groups in an iOS app at runtime?

I want a piece of code to use an access group when available, but not use it otherwise. This is a library, so I'd rather not force the user of the library to redundantly specify this if I can avoid it.


Solution

  • I. I'm sure there's a better method than this one. Why not try to use the access group unconditionally, then check for errors and fall back gracefully if the attempt to store/retrieve data was not successful?

    II. If not, then have a look at Keychain-Dumper. You will surely find some inspiring ideas inside. I especially recommend studying the printKey() function for having an idea about getting all the access groups by iteraring through each keychain entry.