0

我的应用程序在 iPad Air,os 12.2.0 中崩溃。Fabric 中的 crashlytics 显示第 315 行的崩溃

NSAssert( result == noErr, @"Couldn't add the Keychain Item." );

在 KeychainItemWrapper.m 文件中。调用此方法将 UUID 存储在 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()!

//导致崩溃的行 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
    }

好吧,我的问题是如何解决此崩溃以及如何至少复制此错误以进行进一步调试。Xcode 10.2 swift 4 keychainSharing 的功能不可用,但应用程序仍然可以正常工作。

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:]
4

0 回答 0