SwiftXcode / swift-lambda

Build and deploy Swift Package Manager projects on AWS Lambda
Apache License 2.0
24 stars 1 forks source link

NIO SSL Linking Issue (implementation only) #6

Closed helje5 closed 3 years ago

helje5 commented 3 years ago

I’ve recently pulled swift-nio-ssl as a dependency in my project (via async-http-client) - all’s good when running it in Xcode, but when I try to build for deploying on AWS (using @helge’s SPMDestinations/swift-lambda) it throws the following errors:

Reported via chat:

/<path>/.build/checkouts/swift-nio-ssl/Sources/NIOSSL/SSLCertificate.swift:301:16: error: cannot use type alias 'time_t' here; 'CNIOBoringSSL' has been imported as implementation-only
  public var notValidBefore: time_t {
        ^        ~~~~~~
CNIOBoringSSL.time_t:1:18: note: type declared here
public typealias time_t = __time_t
         ^
/<path>/.build/checkouts/swift-nio-ssl/Sources/NIOSSL/SSLCertificate.swift:310:16: error: cannot use type alias 'time_t' here; 'CNIOBoringSSL' has been imported as implementation-only
  public var notValidAfter: time_t {
        ^       ~~~~~~
CNIOBoringSSL.time_t:1:18: note: type declared here
public typealias time_t = __time_t
         ^
helje5 commented 3 years ago

OK, can repro that. Added this to MacroExamples:

  dependencies: [
...
    .package(url: "https://github.com/apple/swift-nio-ssl.git",
             from: "2.13.0")             
...
  targets: [
    .target(name: "httpd-helloworld", dependencies: [ "Macro", .product(name: "NIOSSL", package: "swift-nio-ssl") ]),
$ swift lambda build -d 5.3 -p httpd-helloworld
/Users/helge/tmp/MacroExamples/.build/checkouts/swift-nio-ssl/Sources/NIOSSL/SSLCertificate.swift:301:16: error: cannot use type alias 'time_t' here; 'CNIOBoringSSL' has been imported as implementation-only
    public var notValidBefore: time_t {
               ^               ~~~~~~
CNIOBoringSSL.time_t:1:18: note: type declared here
public typealias time_t = __time_t
                 ^
/Users/helge/tmp/MacroExamples/.build/checkouts/swift-nio-ssl/Sources/NIOSSL/SSLCertificate.swift:310:16: error: cannot use type alias 'time_t' here; 'CNIOBoringSSL' has been imported as implementation-only
    public var notValidAfter: time_t {
               ^              ~~~~~~
CNIOBoringSSL.time_t:1:18: note: type declared here
public typealias time_t = __time_t
helje5 commented 3 years ago

Adding an explicit import to SSLCertificate.swift fixes the issue for me:

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import struct Darwin.time_t
#elseif canImport(Glibc)
import struct Glibc.time_t
#endif
helje5 commented 3 years ago

Proposed the fix to swift-nio-ssl: https://github.com/apple/swift-nio-ssl/pull/294

helje5 commented 3 years ago

fixed in NIO