# ios


01/31/2022, 6:33 AM
did anyone try to use async/await as described here by John O’Reilly and get it to work in unit tests? I could get it to work as described by calling with
async { <viewModel function to run> }
from the view, but from the unit tests it doesn’t do anything using this
async {}
syntax since it doesn’t wait for it. It seems that it’s not normal to call it like that in unit tests and just call it with
try await
only. However if I do that I get the IncorrectDereferenceException. I’m not sure if it’s currently possible to do it or if I just wasn’t doing it right. I’m not using the new memory model but maybe that would work. It’s not a big deal as I have it working without async/await but I really like the async/await syntax and eventually want to move to it.


01/31/2022, 4:41 PM
Here's a quick heads up if you're supporting iOS 14 or earlier. Xcode 13.2 is supposed to allow async/await on older versions of iOS but it also has a compiler bug that produces bad code in release builds that use if @available(…). You won't see it in the simulator and won't see it when running on device from Xcode unless you switch your scheme to use a release build instead of debug. You will see it when you send a build to TestFlight or release the app to production. Your crash logs will say something about a name mangling error. The only fix right now is to use 13.1 but that also means no async/await for iOS <15.
👍 1

Nikolay Kasyanov

01/31/2022, 7:10 PM


01/31/2022, 9:27 PM
thanks guys I think I’ll leave as is for now.