Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Linux Build #1

Open
xanderdunn opened this issue Sep 14, 2020 · 3 comments
Open

Support Linux Build #1

xanderdunn opened this issue Sep 14, 2020 · 3 comments

Comments

@xanderdunn
Copy link

xanderdunn commented Sep 14, 2020

Currently, this project doesn't build on Linux. Using version 1.1.1:

$ which swift
/home/xander/swift-tensorflow-RELEASE-0.10-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
Target: x86_64-unknown-linux-gnu
$ swift build
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:32:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:40:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:216:18: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
    let session: URLSession
                 ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:132:34: error: cannot find type 'CFError' in scope
            var error: Unmanaged<CFError>?
                                 ^~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:31: error: cannot find 'kSecAttrKeyType' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                              ^~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:48: error: cannot find 'kSecAttrKeyTypeRSA' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                               ^~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:68: error: cannot find 'kSecAttrKeyClass' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                   ^~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:86: error: cannot find 'kSecAttrKeyClassPrivate' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:133:111: error: cannot find 'kSecAttrKeySizeInBits' in scope
            let attributes = [kSecAttrKeyType: kSecAttrKeyTypeRSA, kSecAttrKeyClass: kSecAttrKeyClassPrivate, kSecAttrKeySizeInBits: 256] as CFDictionary
                                                                                                              ^~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:134:36: error: cannot find 'SecKeyCreateWithData' in scope
            guard let privateKey = SecKeyCreateWithData(key as CFData, attributes, &error) else {
                                   ^~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:137:35: error: cannot find 'SecKeyCreateSignature' in scope
            guard let signature = SecKeyCreateSignature(privateKey, .rsaSignatureMessagePKCS1v15SHA256, data as CFData, &error) as Data? else {
                                  ^~~~~~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:229:19: error: 'URLSession' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        session = URLSession(configuration: .ephemeral, delegate: nil, delegateQueue: operationQueue)
                  ^~~~~~~~~~
Foundation.URLSession:2:18: note: 'URLSession' has been explicitly marked unavailable here
public typealias URLSession = AnyObject
                 ^
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:240:27: error: cannot find 'URLRequest' in scope
            var request = URLRequest(url: url)
                          ^~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:305:27: error: cannot find 'URLRequest' in scope
            var request = URLRequest(url: url)
                          ^~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:387:29: error: cannot find 'applyingTransform' in scope
        let logId = String((applyingTransform(.toLatin, reverse: false) ?? self)
                            ^~~~~~~~~~~~~~~~~
.build/checkouts/GoogleCloudLogging/Sources/GoogleCloudLogging/GoogleCloudLogging.swift:40:29: error: 'URLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
        case noDataReceived(URLResponse?)
                            ^~~~~~~~~~~
Foundation.URLResponse:2:18: note: 'URLResponse' has been explicitly marked unavailable here
public typealias URLResponse = AnyObject
                 ^

Some of these errors could be resolved simply by changing import Foundation to:

import Foundation
#if canImport(FoundationNetworking)
    import FoundationNetworking
#endif

It looks like the authentication portions of it would need to be replaced by either CryptoSwift or google-auth-library-swift, both of which support Linux. The latter is Google's official library for authenticating with Google Cloud and may readily replace this functionality.

@DnV1eX
Copy link
Owner

DnV1eX commented Sep 14, 2020

Thanks, @xanderdunn.
Initially, this library used Google's OAuth implementation, but I intentionally sacrificed Linux support to avoid third-party dependencies.
If anyone would like to share thoughts on the topic, welcome to comment!

@Mordil
Copy link

Mordil commented Oct 8, 2021

I think it's totally reasonable to use Apple and event SSWG incubating projects as dependencies, and we now have SwiftCrypto

@diegotl
Copy link

diegotl commented Jan 23, 2024

We're in 2024, this project seems abandoned but I still use it in my projects and wanted to use it in one of my Vapor apps, which runs in a linux server.

Turns out the JWT part that depends on Security framework (macOS-only) can be replaced using JWTKit, which is already a dependency of Vapor. I could make it work.

For a while I run my own fork with few other modifications, but if people are interested (including @DnV1eX) I can prepare and make a PR here adding the linux support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants