Q: Cannot pass immutable value of type 'UnsafeRawPointer?' as inout argument var keyCallbacks = kCFTypeDictionaryKeyCallBacks
var valueCallbacks = kCFTypeDictionaryValueCallBacks
  
var keys = [Unmanaged.passUnretained(kSecClass).toOpaque(), Unmanaged.passUnretained(kSecAttrApplicationTag).toOpaque(), Unmanaged.passUnretained(kSecAttrKeyType).toOpaque(), Unmanaged.passUnretained(kSecReturnRef).toOpaque()]
var values = [Unmanaged.passUnretained(kSecClassKey).toOpaque(), Unmanaged<AnyObject>.passUnretained(privateTag as AnyObject).toOpaque(), Unmanaged.passUnretained(kSecAttrKeyTypeRSA).toOpaque(), Unmanaged.passUnretained(kCFBooleanTrue).toOpaque()]

// let queryKey = CFDictionaryCreate(kCFAllocatorDefault, &keys, &values, 4, &keyCallbacks, &valueCallbacks)//Error-- for "keys" this error show cannot pass immutable value of type 'UnsafeRawPointer?' as inout argument. 
let queryKey = CFDictionaryCreate(kCFAllocatorDefault, &keys, &values, 4, &keyCallbacks, &valueCallbacks)
    
// Get the key.
var extractedItem: AnyObject?
let resultCode = SecItemCopyMatching(queryKey, &extractedItem)//cannot pass immutable value of type 'UnsafeRawPointer?' as inout argument
    
guard let keyItem = extractedItem, resultCode == noErr else {
        
return nil


A: Don't use CFDictionary in Swift. It is not impossible, but not
worth the hassle. CFDictionary is toll-free bridged to NSDictionary
which in turn can be instantiated from a Swift Dictionary:
let query: NSDictionary = [
    kSecClass: kSecClassKey,
    kSecAttrApplicationTag: privateTag,
    kSecAttrKeyType: kSecAttrKeyTypeRSA,
    kSecReturnRef: true
]
var extractedItem: AnyObject?
let resultCode = SecItemCopyMatching(query, &extractedItem)

