davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
506 stars 146 forks source link

Error: "Undefined symbol: _$s18SwiftPhoenixClient7ChannelCMn" #227

Closed timetraveler90 closed 1 year ago

timetraveler90 commented 1 year ago

After updating the SPM to 5.2.1 from 5.1.0 on M1 Macbook this error started to happen, tried the usual iOS developer procedure :) removing derived data, changing the branch, returning back to that branch, resetting the package cache but no matter what it's still present.

https://i.postimg.cc/6qMThYxd/Screenshot-2023-03-01-at-12-53-49.png

Do you have any other hint what would be the cause of this?

timetraveler90 commented 1 year ago
Undefined symbols for architecture arm64:
  "_$s18SwiftPhoenixClient7ChannelCMn", referenced from:
      _symbolic _____Sg 18SwiftPhoenixClient7ChannelC in AuthenticateChannel.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
timetraveler90 commented 1 year ago

@davidstump can you please take a look?

dsrees commented 1 year ago

@timetraveler90 I don't have access to an M1 and am not seeing this behavior in my project using 5.2.1. What version of Xcode are you on?

Also, 5.2.0 changed the signature of socket.onError and depending on how you have it implemented, it may or may not be the cause? Are you calling socket.onError? and if so could you share that snippet?

timetraveler90 commented 1 year ago

It's Xcode Version 14.2 (14C18).

For example:

protocol ConnectionManagerProtocol: AnyObject {
    var connectionManager: ConnectionManager! { get set }
    var channel: Channel? { get set }

    var channelName: ChannelName! { get set }
    var state: ChannelState { get set }

    init()
}

with this block of code, I am always getting that kind of error, and when I comment this line: var channel: Channel? { get set } the error is gone, which puzzles me the most. I do not see the reason why this line makes this error.

dsrees commented 1 year ago

Yeah I'm at a loss here. How are you including the library? pods? package manager? I'm assuming pinning the version to 5.1.0 resolves this? I want to say that somehow search paths got mixed up

timetraveler90 commented 1 year ago

I am importing the lib as a swift package, tried also resolving the cache and changing back the version to 5.1.0 but I am ending up with the same error all over again. Currently kinda clueless why this happens.

dsrees commented 1 year ago

Is it giving you the same error on 5.1.0 as well now?

timetraveler90 commented 1 year ago

It's definitely not version related, I have tried to change the version and the same message occurs. The reason why I thought it was the version related is that at that time when I had 5.1.0 I had only imported there, without referencing or instantiating anything from the lib, but when I added mode code and updated the lib to 5.2.1 this issue started to happen.

I have just now tried an even older version but it's the same behavior definitely. Also, one of my colleagues tried it on his mac machine, which is not M1, and he has the same issue.

dsrees commented 1 year ago

Resolving this issues can sometimes be like shooting in the dark. I would try removing the library dependency, commenting out any references and then cleaning, resetting caches, and rebuilding and get the project to build successfully without SwiftPhoenixClient. Then after that re-add the dependency, build, uncomment references, build, etc.

timetraveler90 commented 1 year ago

Well, I found the solution, and the issue was on my side absolutely, there was nothing to do with the lib itself.

I realized where was the issue only when I changed the approach from SPM to Pods, and then I realised that the part of the code where I want to use the lib is actually a framework on my project and it wasn't visible even tho it's added in the pods, so I switched back to SPM and added SwiftPhoenixClient to 'Link Binary With Libraries' permission in order to actually have it.

SPM gave me 'fake hope' that I can actually use the lib, which wasn't the case with Pods, when I tried to import the SwiftPhoenixClient. On Pods I was getting not found error.

Sorry for the false alarm guys, please close this ticket. @dsrees

dsrees commented 1 year ago

💯 awesome, glad you got it resolved! Please reach out in the future if you have any other issues.