grpc / grpc-swift

The Swift language implementation of gRPC.
Apache License 2.0
2.04k stars 420 forks source link

Undefined Symbol Errors #846

Open cliedeman opened 4 years ago

cliedeman commented 4 years ago

What are you trying to achieve?

Switching to SwiftNIO implementation from gRPC C library

When trying to build I get the following error:

Screenshot 2020-06-17 at 16 50 21

Undefined symbols for architecture x86_64:
  "nominal type descriptor for Network.NWConnection.PendingDataTransferReport", referenced from:
      _symbolic _____ 7Network12NWConnectionC25PendingDataTransferReportC in NIOTransportServices.o
  "nominal type descriptor for Network.NWConnection.EstablishmentReport", referenced from:
      _symbolic _____y_____SgG 3NIO15EventLoopFutureC 7Network12NWConnectionC19EstablishmentReportV in NIOTransportServices.o
      _symbolic _____Sg 7Network12NWConnectionC19EstablishmentReportV in NIOTransportServices.o
  "Network.NWConnection.requestEstablishmentReport(queue: __C.OS_dispatch_queue, completion: (Network.NWConnection.EstablishmentReport?) -> ()) -> ()", referenced from:
      NIOTransportServices.NIOTSConnectionChannel.getOption0<A where A: NIO.ChannelOption>(option: A) throws -> A.Value in NIOTransportServices.o
  "Network.NWConnection.startDataTransferReport() -> Network.NWConnection.PendingDataTransferReport", referenced from:
      NIOTransportServices.NIOTSConnectionChannel.getOption0<A where A: NIO.ChannelOption>(option: A) throws -> A.Value in NIOTransportServices.o
  "type metadata accessor for Network.NWConnection.PendingDataTransferReport", referenced from:
      NIOTransportServices.NIOTSConnectionChannel.getOption0<A where A: NIO.ChannelOption>(option: A) throws -> A.Value in NIOTransportServices.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What have you tried so far?

change the ios deployment target to 13. Same error The example SpeechToText project compiles and runs

Is this minimum ios target is 13? I couldn't find that documented anywhere

Lukasa commented 4 years ago

Which Xcode version are you using to build? The minimum deployment target has not changed recently, but the minimum Xcode version has, as we rely on things added in the SDKs that shipped with Xcode 11.

cliedeman commented 4 years ago

Version 11.5 (11E608c)

Lukasa commented 4 years ago

Hmm. Can you clear your derived data and try the build again? If that doesn’t work, can you let me know what you’re using as your minimum deployment target, and also what version of grpc-swift you’re using?

cliedeman commented 4 years ago

@Lukasa thats for the help. Deleting Derived data did not help.

Back to the original error

I created a sample expo project and confirmed everything works as expected (This is with deployment target ios9) - https://github.com/cliedeman/swiftgrpcexample

Which leads me to believe the issue is not with this library. I am going to compare the projects and see if I can identify a difference

Lukasa commented 4 years ago

Thanks for doing that investigative work @cliedeman, please keep us informed.

glbrntt commented 4 years ago

Any luck with this @cliedeman?

cliedeman commented 4 years ago

@glbrntt I havent looked into it again. but seeing as it works with a fresh project I am going to close this out and re-open if I ever encounter it again

izone-airstream commented 4 years ago

I have the same issue here. It's a new project, deployment target is iOS12, swift-grpc from latest branch "main". Trying to figure it out before creating a new project.

cliedeman commented 4 years ago

@izone-airstream I never did figure it out but I had to drop grpc for reasons un-related to this.

izone-airstream commented 4 years ago

It's an OEM project and the code runs perfectly in previous project.

I just clone the previous project, rename the project and target, import the dependency, and the swift-grpc package was forced to switch from "master" to "main", the the related packages version are newer. When I rebuilt the app, the error popped up:

Undefined symbols for architecture x86_64: "type metadata accessor for Network.NWConnection.EstablishmentReport", referenced from: type metadata accessor for Network.NWConnection.EstablishmentReport? in NIOTransportServices.o "Network.NWConnection.requestEstablishmentReport(queue: __C.OS_dispatch_queue, completion: (Network.NWConnection.EstablishmentReport?) -> ()) -> ()", referenced from: NIOTransportServices.NIOTSConnectionChannel.getOption0(option: A) throws -> A.Value in NIOTransportServices.o "Network.NWConnection.startDataTransferReport() -> Network.NWConnection.PendingDataTransferReport", referenced from: NIOTransportServices.NIOTSConnectionChannel.getOption0(option: A) throws -> A.Value in NIOTransportServices.o "type metadata accessor for Network.NWConnection.PendingDataTransferReport", referenced from: NIOTransportServices.NIOTSConnectionChannel.getOption0(option: A) throws -> A.Value in NIOTransportServices.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Tried both debug and release mode, exactly the same.

izone-airstream commented 4 years ago

FYI. I tried many things, still with the same error. Finally I recreated a new project and reconfig everything again, then it works. Maybe something related to project configuration.

One interesting point is, the swift-nio-transport-services was v1.8.0 when the errors happened. I tried to set it to 1.7.0 manually(which works fine in other projects), reset package caches, but that error still presented.

When I recreated the new project which later builds without error, the swift-nio-transport-services is automatically set to v1.7.0 again, which I didn't manually set it at all. Don't know if that plays the trick.

chromakode commented 3 years ago

I bumped into this error as well. Interestingly, rolling back gRPC-Swift to 1.0.0-alpha.19 produced the same error. Adding use_frameworks! to the Podfile seems to have worked around this issue for me for now.

eholley commented 3 years ago

I fixed the issue by removing the library search paths for the project, but retaining the config paths (which pointed to the pods) and retaining the target paths, if any.

Project settings

Before:

LIBRARY_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)" "$(inherited)"

After:

LIBRARY_SEARCH_PATHS =

kbihani commented 2 years ago

I fixed the issue by removing the library search paths for the project, but retaining the config paths (which pointed to the pods) and retaining the target paths, if any.

Project settings

Before:

LIBRARY_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)" "$(inherited)"

After:

LIBRARY_SEARCH_PATHS =

@eholley Any idea why this would make it work? It does seem to work for us as well when we remove contents from LIBRARY_SEARCH_PATHS, but not sure why it would make it work.

aca-hakan-pinar commented 2 years ago

I've the same issue. Did someone find a solution?