Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol when building for production with v2.0 #2194

Open
DavidI7 opened this issue Feb 13, 2025 · 4 comments
Open

Undefined symbol when building for production with v2.0 #2194

DavidI7 opened this issue Feb 13, 2025 · 4 comments
Labels
status/triage Collecting information required to triage the issue.

Comments

@DavidI7
Copy link

DavidI7 commented Feb 13, 2025

Describe the bug

When I build the app for debugging, everything works fine. When I try to archive it, I get

Showing Recent Issues
Undefined symbol: protocol witness table for NIOHTTP2.NIOHTTP2AsyncSequence<A>.Continuation : NIOHTTP2.AnyContinuation in NIOHTTP2...

I downgraded grpc-swift to 1.24.2 and got something similar (I censored some classes&package names):

Undefined symbols for architecture arm64:
  "protocol witness table for GRPC.AsyncServerHandler<A, B, C, D> : GRPC.AsyncServerCallContextProvider in GRPC", referenced from:
      generic specialization <GRPC.ProtobufSerializer<demo....>, GRPC.ProtobufDeserializer<demo.....>, in ....grpc.o

However, when I changed the minimum iOS version required from 18.0 to 17.6, that error disappeared for v1.24.2. Obviously, I can't try and do this for v2.0 because GRPCCore's minimum deployment target is 18.0.

To reproduce

Steps to reproduce the bug you've found:

  1. Add grpc-swift v.2.0.0, grpc-swift-nio-transport v1.0.0, grpc-swift-protobuf v.1.0.0
  2. Try and archive the build.
  3. The process fails with the errors above

Expected behaviour

You can build for production.

@glbrntt glbrntt added the status/triage Collecting information required to triage the issue. label Feb 14, 2025
@glbrntt
Copy link
Collaborator

glbrntt commented Feb 14, 2025

Hi @DavidI7 -- I couldn't reproduce this.

Here's what I did using Xcode 16.2:

  • Created a new Xcode project for an iOS app
  • Added grpc-swift v.2.0.0, grpc-swift-nio-transport v1.0.0, grpc-swift-protobuf v.1.0.0
  • Imported the relevant modules in a view and used symbols from each
  • Product > Archive

This worked fine.

Are there any settings you have which deviate from the defaults? And could you provide a minimal repro for this?

@DavidI7
Copy link
Author

DavidI7 commented Feb 18, 2025

Hi ! First of all, thank you very much for your reply.

I attached 2 archives.

testy-test has a project with grpc-swift v2.0.
This is what I get when trying to archive this

 "protocol witness table for NIOHTTP2.NIOHTTP2AsyncSequence<A>.Continuation : NIOHTTP2.AnyContinuation in NIOHTTP2", referenced from:
      generic specialization <(NIOCore.NIOAsyncChannel<GRPCCore.RPCRequestPart<GRPCNIOTransportCore.GRPCNIOTransportBytes>, GRPCCore.RPCResponsePart<GRPCNIOTransportCore.GRPCNIOTransportBytes>>, NIOCore.EventLoopFuture<GRPCCore.MethodDescriptor>)> of (extension in NIOHTTP2):NIOCore.ChannelPipeline.SynchronousOperations.configureAsyncHTTP2Pipeline<A where A: Swift.Sendable>(mode: NIOHTTP2.NIOHTTP2Handler.ParserMode, streamDelegate: NIOHTTP2.NIOHTTP2StreamDelegate?, configuration: NIOHTTP2.NIOHTTP2Handler.Configuration, streamInitializer: @Sendable (NIOCore.Channel) -> NIOCore.EventLoopFuture<A>) throws -> NIOHTTP2.NIOHTTP2Handler.AsyncStreamMultiplexer<A> in GRPCNIOTransportCore.o
      generic specialization <()> of (extension in NIOHTTP2):NIOCore.ChannelPipeline.SynchronousOperations.configureAsyncHTTP2Pipeline<A where A: Swift.Sendable>(mode: NIOHTTP2.NIOHTTP2Handler.ParserMode, streamDelegate: NIOHTTP2.NIOHTTP2StreamDelegate?, configuration: NIOHTTP2.NIOHTTP2Handler.Configuration, streamInitializer: @Sendable (NIOCore.Channel) -> NIOCore.EventLoopFuture<A>) throws -> NIOHTTP2.NIOHTTP2Handler.AsyncStreamMultiplexer<A> in GRPCNIOTransportCore.o

And the second one, testy-test-1.24.2 uses grpc-swift v1.24.2 and the same files from the other project but generated manually by me using protoc. For this one, there's the initial problem that I've opened the issue with - it works if the target version is <18, or throws if the targeted iOS version is 18.0

      generic specialization <GRPC.ProtobufSerializer<testy_test.nameGrpc_Journal_CreateJournalEntryResponse>, GRPC.ProtobufDeserializer<testy_test.nameGrpc_Journal_CreateJournalEntryRequest>, testy_test.nameGrpc_Journal_CreateJournalEntryRequest, testy_test.nameGrpc_Journal_CreateJournalEntryResponse> of GRPC.AsyncServerHandler.receiveInterceptedMetadata(NIOHPACK.HPACKHeaders) -> () in journal.grpc.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried using both XCode 16.0 and 16.2.

testy-test-1.24.2.zip
testy-test.zip

@glbrntt
Copy link
Collaborator

glbrntt commented Feb 18, 2025

Thanks for providing those, however, I can archive both of those with Xcode 16.2 (I didn't have a copy of Xcode 16.0 around to try out).

Have you tried deleting your derived data?

@DavidI7
Copy link
Author

DavidI7 commented Feb 19, 2025

I managed to solve it, it was a combination of using only XCode 16.2, cleaning the build folder, deleting DerivedData and making sure to do all of this before using XCode 16.2 if coming from XCode 16.0.

I did only parts of this flow before and didn't get it to work, so I'm pretty sure it's something that got cached when I used XCode 16.0.

Thank you for your support, I think we can close the issue. If everyone ever encounters this error, make sure you have at least XCode 16.2 and a clean state of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/triage Collecting information required to triage the issue.
Projects
None yet
Development

No branches or pull requests

2 participants