title: How to use System KeyChain along with AccessGroup?
body: <p>I want to have my keys stored in System Keychain and a couple of apps(keySharing and AppGroup enabled)   to access them</p>
  <p>My current approach
  I am using</p>
  <pre><code> let path:String = &quot;/Library/Keychains/System.keychain&quot;
   var keychain: SecKeychain?
   SecKeychainOpen(path, &amp;keychain)
  
  </code></pre>
  <p>For options in SecItemAdd() ,I added</p>
  <p><code>[kSecUseKeychain as String: keychain! ]</code></p>
  <p>with this approach, I am able to write to System keyChain  but only the current app is able to access  this KeyChainItem,
  <code>kSecAttrAccessGroup</code>
  is completely ignored for this keychain item.</p>
  <p>After some digging I found
  <code>kSecUseDataProtectionKeychain = true</code>
  is mandatory to use AccessGroup</p>
  <p>When I included this in the options of SecAddItem(), Yes I am able to utilize access groups after this, but it is ignoring <code>kSecUseKeychain</code> now. Though  my app is running in root and kSecUseKeychain is set, SecAddtem() is writing to login KeyChain (and apps inside my access are able to access them) instead of System Keychain</p>
  <p>Is there a way to write to System KeyChain and allow a set of apps to modify them?</p>
  <p>In short
  <code>[kSecUseKeychain as String: keychain! ]</code>
  is ignored  when</p>
  <p><code>kSecUseDataProtectionKeychain = true</code></p>
  <p>Thanks
  Any alternatives related to having keys in System Context  is much appreciated</p>
  <p>Xcode -12.2
  macOS :10.15</p>