pusher / pusher-websocket-swift

Pusher Channels websocket library for Swift
https://pusher.com/channels
MIT License
273 stars 167 forks source link

Undefined Symbols Build Errors When Adding Pusher #400

Closed tjolsen-vn closed 1 year ago

tjolsen-vn commented 2 years ago

Steps to reproduce

I'm having trouble importing Pusher into a (mostly) Obj-C code base. I plan on doing this integration in Swift, however. But, when I added Pusher to the target via SPM (https://github.com/pusher/pusher-websocket-swift.git), I got a bunch of "Undefined symbols for architecture arm64" errors for NWWebSocket stuff. So, then I tried also adding NWWebSocket via SPM (https://github.com/pusher/NWWebSocket.git).

It seems it got me past the previous errors, but now I'm seeing errors like:

Undefined symbols for architecture arm64:
  "_$s7Network10NWEndpointO3urlyAC10Foundation3URLVcACmFWC", referenced from:
      _$s11NWWebSocketAAC3url20connectAutomatically7options15connectionQueueAB10Foundation3URLV_Sb7Network013NWProtocolWebB0C7OptionsCSo17OS_dispatch_queueCtcfc in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO4contyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO4pingyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC4pingyyF in NWWebSocket.o
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO4pongyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO4textyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC4send6stringySS_tF in NWWebSocket.o
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO5closeyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC10disconnect9closeCodey7Network013NWProtocolWebB0C05CloseE0O_tF in NWWebSocket.o
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
      _$s11NWWebSocketAAC4send33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataVSg_7Network12NWConnectionC14ContentContextCtFyAK7NWErrorOSgcfU_ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeO6binaryyA2EmFWC", referenced from:
      _$s11NWWebSocketAAC4send4datay10Foundation4DataV_tF in NWWebSocket.o
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC6OpcodeOMa", referenced from:
      _$s11NWWebSocketAAC4send6stringySS_tF in NWWebSocket.o
      _$s11NWWebSocketAAC4send4datay10Foundation4DataV_tF in NWWebSocket.o
      _$s11NWWebSocketAAC4pingyyF in NWWebSocket.o
      _$s11NWWebSocketAAC10disconnect9closeCodey7Network013NWProtocolWebB0C05CloseE0O_tF in NWWebSocket.o
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
      _$s11NWWebSocketAAC4send33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataVSg_7Network12NWConnectionC14ContentContextCtFyAK7NWErrorOSgcfU_ in NWWebSocket.o
      _$s7Network19NWProtocolWebSocketC6OpcodeOAESYAAWl in NWWebSocket.o
      ...
  "_$s7Network19NWProtocolWebSocketC6OpcodeOSYAAMc", referenced from:
      _$s7Network19NWProtocolWebSocketC6OpcodeOAESYAAWl in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC7OptionsC13autoReplyPingSbvsTj", referenced from:
      _$s11NWWebSocketAAC14defaultOptions7Network013NWProtocolWebB0C0D0CvgZ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC7OptionsC15setSubprotocolsyySaySSGFTj", referenced from:
      _$s11PusherSwift0A0C3key7optionsACSS_AA0A13ClientOptionsCtcfc in PusherSwift.o
  "_$s7Network19NWProtocolWebSocketC7OptionsCMa", referenced from:
      _$s11NWWebSocketAAC14defaultOptions7Network013NWProtocolWebB0C0D0CvgZ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC7OptionsCyAeC7VersionOcfC", referenced from:
      _$s11NWWebSocketAAC14defaultOptions7Network013NWProtocolWebB0C0D0CvgZ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC7VersionO9version13yA2EmFWC", referenced from:
      _$s7Network19NWProtocolWebSocketC7OptionsCyAeC7VersionOcfcfA_ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC7VersionOMa", referenced from:
      _$s11NWWebSocketAAC14defaultOptions7Network013NWProtocolWebB0C0D0CvgZ in NWWebSocket.o
      _$s7Network19NWProtocolWebSocketC7OptionsCyAeC7VersionOcfcfA_ in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC8MetadataC14setPongHandler_7handlerySo17OS_dispatch_queueC_yAA7NWErrorOSgctFTj", referenced from:
      _$s11NWWebSocketAAC4pingyyF in NWWebSocket.o
  "_$s7Network19NWProtocolWebSocketC8MetadataC6opcodeAC6OpcodeOvg", referenced from:
      _$s11NWWebSocketAAC14receiveMessage33_DD5690483DE4B48780ABA23BEFB7EAA1LL4data7contexty10Foundation4DataV_7Network12NWConnectionC14ContentContextCtF in NWWebSocket.o
...

I'm sure this is something on my end, but am I missing something? I don't see any other dependencies in the README.

If I build with Pusher removed from the target, it builds fine.

Expected behavior

Just trying to get the target to build with Pusher added.

Actual behavior

I get build errors when adding Pusher.

Any improvements you suggest

Just looking for some help. ...

benjamin-tang-pusher commented 2 years ago

When you add PusherSwift as an SPM package, did you use the XCode Menu's File -> Add Packages ... (or right click ->Add Packages on the left sidebar), or are you adding it in your own Package.swift?

SPM should resolve PusherSwift's dependencies automatically. That you manually added NWWebsocket sounds like something gone wrong here.

tjolsen-vn commented 2 years ago

When you add PusherSwift as an SPM package, did you use the XCode Menu's File -> Add Packages ... (or right click ->Add Packages on the left sidebar), or are you adding it in your own Package.swift?

SPM should resolve PusherSwift's dependencies automatically. That you manually added NWWebsocket sounds like something gone wrong here.

Yes, I used Xcode's menu (File -> Add Packages ...) and added https://github.com/pusher/pusher-websocket-swift.git. But, when I did that, I got a bunch of errors about not finding symbols for NWWebSocket referenced from Pusher. So then I also added NWWebSocket (also through Xcode's menu), and then ended up with the errors above.

At any rate, I was able to successfully integrate with your work around in another issue thread. But I wasn't able to use SPM. Which at this point is fine on my end. I just really didn't want to integrate Carthage or CocoaPods into this legacy code base. So the manual download was great for me.

benjamin-tang-pusher commented 1 year ago

If you're able to use my workaround then I will close this Github issue for now.