1

I am following this tutorial for import socket.io to swift. http://socket.io/blog/socket-io-on-ios/

I did everything in the tutorial but I am getting this error:

Use of unresolved identifier 'SocketIOClient'

for this piece of code:

let socket = SocketIOClient(socketURL: "localhost:8900") 

My structure:

enter image description here

How can I resolve this problem ?

Popeye
  • 11,839
  • 9
  • 58
  • 91
Okan
  • 1,379
  • 3
  • 25
  • 38

3 Answers3

5

make sure about 2 things:

  • select "create groups" not "create folder references"
  • copy items if needed
Fareed Alnamrouti
  • 30,771
  • 4
  • 85
  • 76
1

In the bridging-header.h change this #import "SocketRocket/SRWebSocket.h" to this:

#import <SocketRocket/SRWebSocket.h>

If it does not work just add:

#import "SRWebSocket.h"

Also rename yout bridging header to Ribony-Bridging-Header.h and add it your project's target settings (refer to your bridging header path not just copy "TicTacIOiOS/Bridging-Header.h" from the documentation for websockets).

enter image description here

Nikos M.
  • 13,685
  • 4
  • 47
  • 61
0

Make sure when copying you actually are copying the files. Here's a screen shot showing what I mean.

Don't do this when copying files...

Remember to click "Copy items if needed" and in some cases "Create Groups"

In this image the options "Copy items if needed is deselected"

But be sure to do this

enter image description here

Select the option "Copy items if needed"

Also be sure to build your project after importing into the Bridging Header file. Be sure if it is a framework to import like so

#import <Framework/Framework.h>

But if it is a stand alone .h file then import it like so

#import "MyClass.h" 

UPDATE: I would also suggest having a look here to make sure you got the steps right - How to call Objective-C code from Swift

Community
  • 1
  • 1
Jesse Onolemen
  • 1,277
  • 1
  • 15
  • 32