I'm trying to make an asynchronous network call using the async / await in Swift 5.5 but for some reason, it does not work as expected in my Swift Package.
let (data, response) = await URLSession.shared.data(for: request)
The above line of code works in a swift playground (request here being a URLRequest) but it fails to work inside my Swift Package (using swift tools version 5.5)
The error at first is: Type of expression is ambiguous without more context
but I realized it had to do with the tuple assignment so I changed the statement to just:
let data = await URLSession.shared.data(for: request)
And it gives me the error: Value of type 'URLSession' has no member 'data'
Futhermore, Xcode's code completion does not list .data(for:) while working in the Swift Package as opposed to the playground. Check the screenshots below for a better understanding.