btnguyen2k / swiftutils

Utility library in Swift
MIT License
72 stars 22 forks source link

XCode9 RsaUtils.swift compile error #6

Closed dorucazan closed 7 years ago

dorucazan commented 7 years ago

Hi, I try to compile RsaUtils.swift included in a project and get "Expression too complex to be solved in reasonable time"Error. I replace

        let queryFilter = [
            String(kSecClass)              : kSecClassKey,
            String(kSecAttrKeyType)        : kSecAttrKeyTypeRSA,
            String(kSecAttrApplicationTag) : tagName,
            //String(kSecAttrAccessible)     : kSecAttrAccessibleWhenUnlocked,
            String(kSecValueData)          : privkeyData!,
            String(kSecAttrKeyClass)       : kSecAttrKeyClassPrivate,
            String(kSecReturnPersistentRef): true
            ] as [String : Any]

with

        let k = String(kSecAttrKeyType)
        let v = kSecAttrKeyTypeRSA
        let queryFilter = [
            String(kSecClass)              : kSecClassKey,
                   k : v,
            String(kSecAttrApplicationTag) : tagName,
            //String(kSecAttrAccessible)     : kSecAttrAccessibleWhenUnlocked,
            String(kSecValueData)          : privkeyData!,
            String(kSecAttrKeyClass)       : kSecAttrKeyClassPrivate,
            String(kSecReturnPersistentRef): true
            ] as [String : Any]

and

        let queryFilter = [
            String(kSecClass)              : kSecClassKey,
            String(kSecAttrKeyType)        : kSecAttrKeyTypeRSA,
            String(kSecAttrApplicationTag) : tagName,
            String(kSecValueData)          : pubkeyData!,
            String(kSecAttrKeyClass)       : kSecAttrKeyClassPublic,
            String(kSecReturnPersistentRef): true
            ] as [String : Any]

with

        let k = String(kSecAttrKeyType)
        let v = kSecAttrKeyTypeRSA
        let queryFilter = [
            String(kSecClass)              : kSecClassKey,
                   k : v,
            String(kSecAttrApplicationTag) : tagName,
            String(kSecValueData)          : pubkeyData!,
            String(kSecAttrKeyClass)       : kSecAttrKeyClassPublic,
            String(kSecReturnPersistentRef): true
            ] as [String : Any]

and no more issues; except cpu overloading!

btnguyen2k commented 7 years ago

Hi @dorucazan,

The code you posted seems old. Can you try the latest code and see if the problem still persists? The latest commit a19d780a0d55cdea9ecd94b801d6434eb8f207ab was 12 days ago: https://github.com/btnguyen2k/swiftutils/commit/a19d780a0d55cdea9ecd94b801d6434eb8f207ab

Regards, Thanh Nguyen

dorucazan commented 7 years ago

Tested now and there were no "Expression too complex to be solved in reasonable time" Errors nor cpu overloading anymore. Functionality testing will follow but it seems fine. Thanks a lot !!!