Closed mamcx closed 3 years ago
The build output shows that it's trying to compile NIO and Vapor 3's Core – which fails because you are using Swift 4.0 instead of the minimum required 4.1.
But the Package.swift you uploaded doesn't have any v3 stuff in it, which raises another question, have you run swift package update
after changing the dependencies?
Yeah, I don't do update. After that I get a dependance error, so I look at other vapor repos and try:
.package(url: "https://github.com/vapor/core.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/postgresql.git", from: "1.0.0-rc"),
Now update work, but building:
warning: error while trying to use pkgConfig flags for swift-nio-zlib-support: couldNotFindConfigFile Compile Swift Module 'Async' (15 sources) Compile Swift Module 'NIOOpenSSL' (11 sources) /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/core.git-9210800844849382486/Sources/Async/Future+Flatten.swift:50:51: error: missing argument label 'file:' in call let promise = worker.eventLoop.newPromise([Element.Expectation].self) ^ file: /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/core.git-9210800844849382486/Sources/Async/Future+Flatten.swift:53:48: error: ambiguous reference to member 'init' var results: [Element.Expectation?] = .init(repeating: nil, count: count) ^
~~~~~~/Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/core.git-9210800844849382486/Sources/Async/Future+Flatten.swift:53:48: note: overloads for 'init' exist with these partially matching parameter lists: (repeating: Element, count: Int), (repeating: Self.Element, count: Int) var results: [Element.Expectation?] = .init(repeating: nil, count: count) ^:1:9: note: in file included from :1: #import "/Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h" ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h:17:10: error: 'openssl/conf.h' file not found #include ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/NIOOpenSSL/OpenSSLHandler.swift:16:8: error: could not build Objective-C module 'CNIOOpenSSL' import CNIOOpenSSL ^ :1:9: note: in file included from :1: #import "/Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h" ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h:17:10: error: 'openssl/conf.h' file not found #include ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/NIOOpenSSL/OpenSSLHandler.swift:16:8: error: could not build Objective-C module 'CNIOOpenSSL' import CNIOOpenSSL ^ :1:9: note: in file included from :1: #import "/Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h" ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h:17:10: error: 'openssl/conf.h' file not found #include ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/NIOOpenSSL/OpenSSLHandler.swift:16:8: error: could not build Objective-C module 'CNIOOpenSSL' import CNIOOpenSSL ^ :1:9: note: in file included from :1: #import "/Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h" ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/CNIOOpenSSL/include/c_nio_openssl.h:17:10: error: 'openssl/conf.h' file not found #include ^ /Users/mamcx/Proyectos/Swift/DbLib/.build/checkouts/swift-nio-ssl.git-1370587408992578247/Sources/NIOOpenSSL/OpenSSLHandler.swift:16:8: error: could not build Objective-C module 'CNIOOpenSSL' import CNIOOpenSSL ^ error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/mamcx/Proyectos/Swift/DbLib/.build/debug.yaml main
So look like is a OpenSSL issue. But then how resolve that?
There are actually two errors in there. One is caused by Swift 4.0 (you need to have Swift 4.1 installed if you want to work with Vapor 3), the other is indeed OpenSSL. Run brew install libressl pkg-config
and run swift package update
again.
I can't use Swift 4.1 yet. Which is the compatible version for 4?
Vapor 2.4.4 along with version 2.1.2 of this repo.
@vzsg I updated the LibreSSL packages, but there is still a compile error showing the wrong version being linked for dylib for LibreSSL.
ld: warning: ld: warning: dylib (/usr/local/Cellar/libressl/3.2.3/lib/libcrypto.dylib) was built for newer macOS version (11.0) than being linked (10.10)dylib (/usr/local/Cellar/libressl/3.2.3/lib/libssl.dylib) was built for newer macOS version (11.0) than being linked (10.10)
@vzsg I tried this potential workaround for dylib, but no luck (https://stackoverflow.com/questions/58272830/python-crashing-on-macos-10-15-beta-19a582a-with-usr-lib-libcrypto-dylib)
@quantum-fusion that's just a linking warning, the actual compiler error is in App
and Run
@0xTim You can see that initially there are just warnings, for the dylib but then those turn to undefined symbols for dependencies during the linking step (Undefined symbols for architecture x86_64: "_OBJCCLASS$_CIContext", referenced from: objc-class-ref in Classifier.o "_OBJCCLASS$_CIImage", referenced from: objc-class-ref in routes.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) )
@0xTim I have tried and tried and tried, but can't get these Undefined symbols resolved, for dylib.
What versions on macOS, Xcode, Swift and LibreSSL are you using?
@0xTim We decided to downgrade the version of Swift and Xcode, to support Vapor4. I left a note to the developer of the Vapor project that was going to host a CoreML model with Vapor for a REST API, but he is non-responsive. I am not sure this is going anywhere. (https://github.com/rickwierenga/heartbeat-tutorials/issues/3). I asked if he could help upgrade to vapor4, but it doesn't look like he wants to.
swift --version Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28) Target: x86_64-apple-darwin20.4.0
Closing this as this is due to trying to import CIImage into a Swift Package which isn't possible and nothing to do with Vapor. You need to generate an Xcode project and use that (though that's deprecated essentially so I'm not sure what the workaround is after that)
I try to use this lib for first time with Swift 4: