External library usage in xcode

最后都变了- 提交于 2020-01-03 03:20:12

问题


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:

How can I resolve this problem ?


回答1:


make sure about 2 things:

  • select "create groups" not "create folder references"
  • copy items if needed



回答2:


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).




回答3:


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...

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

But be sure to do this

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



来源:https://stackoverflow.com/questions/28987400/external-library-usage-in-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!