connectrpc / connect-swift

The Swift implementation of Connect: Protobuf RPC that works.
https://connectrpc.com/docs/swift/getting-started
Apache License 2.0
93 stars 17 forks source link

Cannot compile on Linux target - "no such module 'os.log'" #262

Open joemccall86 opened 4 months ago

joemccall86 commented 4 months ago

I have my generated Swift clients and the project builds in macOS. When I build on Linux I get the following issue:

[112/150] Compiling Connect ResponseCallbacks.swift
/root/project/clients/swift/proto-common/.build/checkouts/connect-swift/Libraries/Connect/Public/Implementation/Clients/ProtocolClient.swift:16:8: error: no such module 'os.log'
import os.log

I believe this is because os.log is only defined for macOS and not Linux. As far as I can tell the gRPC generators do not have this limitation.

perezd commented 4 months ago

@rebello95 any thoughts about this?

rebello95 commented 4 months ago

👋🏽 at the moment Connect is not set up to compile for Linux. I have not done a thorough exploration into this, but adding Linux support seems like it would be nontrivial given Alamofire still has some missing features on Linux due to incomplete Swift behavior there: https://github.com/Alamofire/Alamofire?tab=readme-ov-file#known-issues-on-linux-and-windows

I also opened a test PR with some changes, but you can see from the CI failures that there are deeper issues, particularly around streaming: https://github.com/connectrpc/connect-swift/pull/263

rebello95 commented 4 months ago

Also, gRPC-Swift does not have this issue because it is backed fully by SwiftNIO. Connect is primarily backed by URLSession but has a separate module with SwiftNIO support. If we wanted to go down the Linux route, we could explore only making the NIO version support Linux