Kitura / Kitura-WebSocket-NIO

A SwiftNIO based implementation of WebSocket for Kitura
Apache License 2.0
18 stars 14 forks source link

'CZlib' libz.pc: warning: couldn't find pc file #41

Open helenmasters opened 5 years ago

helenmasters commented 5 years ago

Having run kitura init to generate a basic Swift application when I recompile it to use Kitura-NIO by setting export KITURA_NIO=1 I then get a warning from CZlib as follows: .... Resolving https://github.com/apple/swift-nio-ssl.git at 2.1.1 'CZlib' libz.pc: warning: couldn't find pc file [456/456] Linking ./.build/x86_64-apple-macosx/debug/MyKituraApp

The application runs ok but I don't like the warning as I now wonder what didn't work.

I'm running on: macOS Mojave v10.14.5

weissi commented 5 years ago

If you want to fix the warning (which you don't have to), you can do brew install pkg-config. The warning is just fine though, zlib is part of the macOS SDK and Swift will be able to find it.

ianpartridge commented 5 years ago

Seems odd that SPM generates warnings that can only be fixed by using Homebrew?

weissi commented 5 years ago

Seems odd that SPM generates warnings that can only be fixed by using Homebrew?

Well, the Kitura-WebSocket-NIO Package.swift file says that it needs zlib and that zlib is contained in the libz pkg-config file. By default however, macOS doesn't ship any .pc files or pkg-config and therefore SwiftPM complains that it can't consider the libz.pc file for additional include/lib directories etc. For zlib that's not an issue because it's on the usual system include/lib paths so it works without a .pc file.

I guess the message is there that in case it requires some more esoteric package it would give you a hint on what you could do to fix the errors if you get any compilation/linker errors further down the line. SwiftPM will just attempt to build without the .pc file because the required headers/libs might just be installed on the system's defaults paths.

If you really want to remove this warning, I think you can also just drop the libz package config requirement, pretty much every UNIX under the sun will have that installed in the default dirs anyway, right? SwiftPM however can't assume that it's definitely there so it warns you that it couldn't confirm where zlib is installed...

ianpartridge commented 5 years ago

Perhaps SPM shouldn't print this warning on macOS, unless it's also willing to advise people to install Homebrew (which I guess wouldn't be deemed OK).

weissi commented 5 years ago

I'm not actually sure if SwiftPM actually shells out to pkg-config, I thought it parses the .pc files itself (might be wrong). So you can technically also just put the .pc files in place...