Skip to content

Swift codegen needs to import FoundationNetworking to work with Swift 5.x #353

@webholik

Description

@webholik

Starting with Swift 5.1, networking related functionality has been moved to FoundationNetworking. It needs to be imported for the codegen to work.

To Reproduce
Compile the code generated for any request with Swift 5.x and the following error is produced:

error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
let task = URLSession.shared.dataTask(with: request) { data, response, error in 

Expected code snippet and corresponding request
The following code should be present in the generated code to work with Swift 5.x:

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions