My app crashes in iPad Air,os 12.2.0.. the crashlytics in Fabric shows the crash at line 315
NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
in KeychainItemWrapper.m file. This method is called to store UUID in app :
func getUUIDString() -> String {
if !uuid.trimmed().isEmpty {
print("uuid ==> \(uuid)")
return uuid // return cached value
}
/// Generate A Dynamic UDID
var toRet = ""
/// Wrapper Object
let keychainWrapperObj = KeychainItemWrapper(identifier: "ManDown", accessGroup: nil)
/// Check is Any UDID Stored
if let udidSavedVal = keychainWrapperObj?.object(forKey: kSecAttrService) {
print("Old UDID is being Used now as ==> \(udidSavedVal as? String ?? "")")
toRet = udidSavedVal as? String ?? ""
}
if toRet.trimmed().isEmpty {
/// We have no UDID Saved Need to get New
if UserDefaultManager.getUUIDSaved() != nil {
toRet = UserDefaultManager.getUUIDSaved()!
//The line causing crash keychainwraper.setobject()
keychainWrapperObj?.setObject(toRet, forKey: kSecAttrService)
} else {
/// Need to Get new UUID
var newUUIDStr: String?
newUUIDStr = UIDevice.current.identifierForVendor!.uuidString
print(newUUIDStr!)
UserDefaultManager.saveUUIDInDefaultAs(UUIDString: newUUIDStr!)
toRet = newUUIDStr!
keychainWrapperObj?.setObject(toRet, forKey: kSecAttrService)
}
}
print("uuid ==> \(toRet)")
uuid = toRet
Crashlytics.sharedInstance().setUserName(uuid)
return uuid
}
Well my question is how can I solve this crash and how can I at least replicate this error for further debugging. Xcode 10.2 swift 4 The capability is not on for keychainSharing, but the app is still working fine.
Error logs:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x191b53518 __exceptionPreprocess
1 libobjc.A.dylib 0x190d2e9f8 objc_exception_throw
2 CoreFoundation 0x191a6d148 +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x1925301c8 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]