Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Swift build error #85

Open
upkarlidder opened this issue Jun 21, 2018 · 1 comment
Open

Swift build error #85

upkarlidder opened this issue Jun 21, 2018 · 1 comment

Comments

@upkarlidder
Copy link
Member

upkarlidder commented Jun 21, 2018

Hi,

I get the following error when I run "swift build".

/rainbow/Server/.build/checkouts/Kitura-Credentials.git-1137106172743287290/Sources/Credentials/TypeSafeCredentials.swift:48:38: error: use of undeclared type 'TypeSafeMiddleware'
public protocol TypeSafeCredentials: TypeSafeMiddleware, Codable {
                                     ^~~~~~~~~~~~~~~~~~
/rainbow/Server/.build/checkouts/Kitura-Credentials.git-1137106172743287290/Sources/Credentials/TypeSafeCredentials.swift:85:111: error: use of undeclared type 'RequestError'
    public static func handle(request: RouterRequest, response: RouterResponse, completion: @escaping (Self?, RequestError?) -> Void) {
                                                                                                              ^~~~~~~~~~~~
error: terminated(1): /usr/local/Cellar/swift/4.1/Swift-4.1.xctoolchain/usr/bin/swift-build-tool -f /Users/upkar/Documents/code-upkar/rainbow/Server/.build/debug.yaml main output:

Swift version

$ swift --version
Swift version 4.1 (swift-4.1-RELEASE)
Target: x86_64-apple-darwin17.4.0

I am new to swift to fix the code quickly. Thank you for your help !

@jpmmtrader
Copy link

jpmmtrader commented Jul 4, 2018

I received those two compile errors as well which can be resolved by building the Frameworks with your Swift libraries, this is a simple change to the Carthage syntax

TypeSafeMiddleware.swift: Use of undeclared type 'TypeSafeMiddleware', Use of undeclared type 'RequestError'

public static func handle(request: RouterRequest, response: RouterResponse, completion: @escaping (Self?, RequestError?) -> Void) {

I'm running the latest Xcode, Version 9.4 (9F1027a) and during the Carthage update I was required to use the no binaries option as my Swift is at 4.1.2, whereas the frameworks are at 4.1

This was resolved by building the IBM Frameworks using my Swift libraries rather than downloading the rebuilt binaries. This is done with the following command, In fact everything changes so fast I always use the --no-use-binaries on the first build and then run the carthage bootstrap --platform iOS --no-use-binaries command if I upgrade Xcode

carthage update --platform iOS --no-use-binaries

I added the following import code to TypeSafeCredentials.swift and resolved the undeclared error:

Use of undeclared type 'RequestError'

import KituraContracts

I then removed the unused variable TypeSafeMiddleware from the TypeSafeCredentials protocol and resolved the undeclared type error and the server code compiled successfully, HOWEVER, I'm not sure if this has any impact to the functioning of this protocol but it appears to be unused

public protocol TypeSafeCredentials: TypeSafeMiddleware, Codable {

gives error:

Use of undeclared type 'TypeSafeMiddleware',

The new line of code now looks like
public protocol TypeSafeCredentials: Codable {

This also resolved the conversion to Swift 4 errors and the conversion ran successfully

HOWEVER: I am still unable to connect to the server when the code successfully compiles and runs. The app will partially work but it cannot update or retrieve to from the Cloudant database

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

No branches or pull requests

2 participants