pvzig / SlackKit

Build Slack apps, in Swift
MIT License
1.02k stars 139 forks source link

Ubuntu 18.04: 'URLSession' is unavailable: FoundationNetworking module #185

Closed slacklab closed 4 years ago

slacklab commented 4 years ago

Hello.

I have some app with packages: (try run this in docker with vapor image with ubuntu 18.04)

cat Package.swift
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "project_name",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
         .package(url: "https://github.com/httpswift/swifter.git", .upToNextMajor(from: "1.4.7")),
         .package(url: "https://github.com/SlackKit/SlackKit.git", .upToNextMinor(from: "4.3.1")),
         .package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"),
         .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.1.0")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "project_name",
            dependencies: [
                .product(name: "ArgumentParser", package: "swift-argument-parser"),
                "SlackKit"
        ]),
    ]
)

How to reproduce error:

1. sudo apt-get update && apt-get install -y libssl-dev
2. swift build --verbose # it's ok result
3. swift run --verbose 

I got errors:

/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:35:27: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
    private let session = URLSession(configuration: .default)
                          ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:135:66: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
    internal static func handleResponse(_ data: Data?, response: URLResponse?, publicError: Error?) throws -> [String: Any] {
                                                                 ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:49:23: error: use of unresolved identifier 'URLRequest'
        let request = URLRequest(url: url)
                      ^~~~~~~~~~
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:65:23: error: use of unresolved identifier 'URLRequest'
        let request = URLRequest(url: url)
                      ^~~~~~~~~~
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:67:23: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        var response: URLResponse? = nil
                      ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:91:23: error: use of unresolved identifier 'URLRequest'
        var request = URLRequest(url:url)
                      ^~~~~~~~~~
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:119:23: error: use of unresolved identifier 'URLRequest'
        var request = URLRequest(url:url)
                      ^~~~~~~~~~
/usr/bin/swiftc -modulewrap /build/.build/x86_64-unknown-linux-gnu/debug/ArgumentParser.swiftmodule -o /build/.build/x86_64-unknown-linux-gnu/debug/ArgumentParser.build/ArgumentParser.swiftmodule.o
/build/.build/checkouts/SlackKit/SKWebAPI/Sources/NetworkInterface.swift:35:27: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
    private let session = URLSession(configuration: .default)
                          ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^

My environment:

uname -a
Linux 93d4fcae391a 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@93d4fcae391a:/build# swift --version
Swift version 5.2.2 (swift-5.2.2-RELEASE)
Target: x86_64-unknown-linux-gnu

I found this same issue: https://github.com/vapor/vapor/issues/2140 Want to try this conditional import block

Can you give some advice with my problem?

Desicion: When I upgrade SlackKit version to "4.5.1" at my Package.swift i has no error with FoundationNetworking. Has another issue:

/build/Sources/project_name/main.swift:3:8: error: no such module 'SystemConfiguration'
import SystemConfiguration