iosswiftxcodeios14commoncrypto

CCCrypt - Type of expression is ambiguous without more context after iOS 14 update


So this morning I updated my OS and XCode to iOS 14, as prompted by the system.

However, when I opened XCode after the update, I encountered the error Type of expression is ambiguous without more context. I have not changed the code, and it was working before the update.

Here is the code in question:

let ccStatus = CCCrypt(
            CCOperation(kCCEncrypt), // operation
            CCAlgorithm(kAlgorithm), // Algorithm
            CCOptions(kCCOptionPKCS7Padding), // options
            realKey?.withUnsafeBytes{$0.baseAddress?.assumingMemoryBound(to: UInt32.self)}, // key //realKey.length, // keylength
            kCCKeySizeAES256,
            realIV?.withUnsafeBytes{$0.baseAddress?.assumingMemoryBound(to: UInt32.self)}, // iv
            data?.withUnsafeBytes{$0.baseAddress?.assumingMemoryBound(to: UInt32.self)}, // dataIn
            (data?.count ?? 0), // dataInLength,
            cipherData.withUnsafeMutableBytes{$0.baseAddress?.assumingMemoryBound(to: UInt32.self)}, // dataOut
            (cipherData.count), // dataOutAvailable
            &outLength) // dataOutMoved

I've tried everything I can think of, such as looking for unnecessary spaces, etc... I can't seem to figure this out. Any help would be greatly appreciated.


Solution

  • Ok so, if anyone finds this later, what did it for me was creating the values before calling the CCCrypt. For example instead of:

    let ccStatus = CCCrypt(CCOperation(kCCEncrypt),...)
    

    I now do:

    let operation = CCOperation(kCCEncrypt)
    //other values needed
    
    let ccStatus = CCCrypt(operation,...)