Kitura/Kitura-Sample

Can't compile with SPM - Swift 4.2.0

Closed this issue · 5 comments

Can't compile with SPM - Swift 4.2.0
platform: macOS 10.14.2
Xcode: 10.1
There are some issues with RSAKey+JWK.swift

@diuming
Can you try clearing the package.resolved and .build files:

rm Package.resolved
rm -rf .build

And checking if this is still an issue?
Does SPM give you any error message?

@Andrew-Lees11
Thanks for replying

build on Swift 4.2.1

swift build -Xcc -I/path/to/openssl/include

Errors in build stage

warning: PackageDescription API v3 is deprecated and will be removed in the future; used by package(s): SimpleLogger
'OpenSSL' /Kitura-Sample/.build/checkouts/OpenSSL-OSX.git--485871550309880529: warning: Ignoring declared target(s) 'OpenSSL' in the system package
Compile agentcore ibmras/monitoring/agent/BucketList.cpp
Compile agentcore ibmras/monitoring/agent/Agent.cpp
Compile agentcore ibmras/monitoring/agent/Bucket.cpp
Linking ./.build/x86_64-apple-macosx10.10/debug/libenvplugin.dylib
Compile Swift Module 'SwiftJWKtoPEM' (5 sources)
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:19:43: error: use of undeclared type 'EVP_PKEY'
    private var key: UnsafeMutablePointer<EVP_PKEY>? = nil
                                          ^~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:193:83: error: use of undeclared type 'BIGNUM'
    private func base64URLToBignum (_ str: String) throws -> UnsafeMutablePointer<BIGNUM> {
                                                                                  ^~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:48:15: error: value of type 'OpaquePointer' has no member 'pointee'
        rsakey?.pointee.n = try base64URLToBignum(n)
        ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:49:15: error: value of type 'OpaquePointer' has no member 'pointee'
        rsakey?.pointee.e = try base64URLToBignum(e)
        ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:52:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.d = try base64URLToBignum(d)
            ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:59:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.p = try base64URLToBignum(p)
            ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:62:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.q = try base64URLToBignum(q)
            ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:65:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.dmq1 = try base64URLToBignum(dq)
            ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:68:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.dmp1 = try base64URLToBignum(dp)
            ~~~~~~^ ~~~~~~~
/Kitura-Sample/.build/checkouts/Swift-JWK-to-PEM-8539606117191108344/Sources/SwiftJWKtoPEM/RSAKey+JWK.swift:71:19: error: value of type 'OpaquePointer' has no member 'pointee'
            rsakey?.pointee.iqmp = try base64URLToBignum(qi)
            ~~~~~~^ ~~~~~~~
error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Kitura-Sample/.build/debug.yaml main output:

It looks like this issue is due to AppID requiring openSSL which is not installed by default on MacOS.
You should be able to fix it on your machine by installing openssl:

brew install openssl

I have raised a pull request to remove the AppID sample from mac so that users do not require OpenSSL installed to run the sample.

Would you be able to try switching to that branch and running the sample:

git pull
git checkout noOpenSSL
rm Package.resolved
rm -rf .build
Swift run

We have merged this branch into master. Could you confirm whether or not you are now able to build the Sample?

@Andrew-Lees11 thanks for help
It works very well.