Trying to use SecCopyErrorMessageString to interpret errorCode. in swift :
var result: OSStatus result = SecItemAdd(query as CFDictionary, nil);
The above answer is a bit outdated, according to Apple, iOS 11.3, tvOS 11.3 and watchOS 4.3 started to support this since the beta version of SDK.
You'd need to compile against those supported SDKs to use that function. Otherwise, only macOS support that for now.