grpc / grpc-swift

The Swift language implementation of gRPC.
Apache License 2.0
1.99k stars 408 forks source link

Duplication of library code #884

Closed ohayon closed 4 years ago

ohayon commented 4 years ago

Describe the bug

Using version 1.0.0-alpha.15, Xcode is not able to build for SwiftUI previews because of what is seemingly a duplicate symbols warning.

The diagnostics messages are:

Swift package target 'CNIODarwin' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

----------------------------------------

SchemeBuildError: Failed to build the scheme "Example"

Swift package target 'CNIODarwin' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIODarwin' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOAtomics' is linked as a static library by 'NIOTransportServices' and 3 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIOConcurrencyHelpers' is linked as a static library by 'NIOTransportServices' and 3 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOSHA1' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIO' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOLinux' is linked as a static library by 'NIOTransportServices' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIODarwin' is linked as a static library by 'NIOSSL' and 'NIOTLS'. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOAtomics' is linked as a static library by 'NIOSSL' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIOConcurrencyHelpers' is linked as a static library by 'NIOSSL' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOSHA1' is linked as a static library by 'NIOSSL' and 'NIOTLS'. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIO' is linked as a static library by 'NIOSSL' and 'NIOTLS'. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOLinux' is linked as a static library by 'NIOSSL' and 'NIOTLS'. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIODarwin' is linked as a static library by 'NIOHTTP2' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOAtomics' is linked as a static library by 'NIOHTTP2' and 3 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIOConcurrencyHelpers' is linked as a static library by 'NIOHTTP2' and 3 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOSHA1' is linked as a static library by 'NIOHTTP2' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'NIO' is linked as a static library by 'NIOHTTP2' and 2 other targets. This will result in duplication of library code.

Build system information:
error: Swift package target 'CNIOLinux' is linked as a static library by 'NIOHTTP2' and 2 other targets. This will result in duplication of library code.

To reproduce

Steps to reproduce the bug you've found:

  1. Create a new SwiftUI project for iOS
  2. Include a Swift package which has grpc-swift as a dependency via SPM
  3. Attempt to render SwiftUI preview
  4. Observe failure

Expected behaviour

SwiftUI previews work as intended by Xcode

Lukasa commented 4 years ago

This is a known issue currently being discussed on the Swift forums.

Lukasa commented 4 years ago

As this problem is fundamentally an Xcode issue, and not an issue with grpc-swift, you'll need to use FeedbackAssistant to file the report. Sorry!

ohayon commented 4 years ago

Ah got it, thanks for the quick reply!

whilesoftware commented 4 years ago

FWIW: I was able to work around this issue by moving my SwiftUI code into a swift package, which can be previewed in xcode12 without an associated app and its runtime dependencies.

That said, it only works when the package is opened independently. The package cannot be a child of the primary project or in a shared workspace with the primary project, or you're right back where you started :(