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 ?
make sure about 2 things:
select "create groups" not "create folder references"
copy items if needed
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).
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
Related
I have wrote a wrapper for SQLite3 in Swift and it works fine.
I thought of making a framework of it.
The problem is:
To use SQLite3 in swift, we should import the sqlite3.h using bridging header. But I there is no option for bridging header in framework project.
I have created a .c and .h and imported sqlite3.h in .h and made the .h public header. But it doesn't work. It still gives use of unresolved identifier errors.
How can I import .c and .cpp files into swift framework project?
Thank you!
I think you can only use header files which are there in your project(Anyone correct me if I'm wrong). So, add the sqlite3.h to your project.
Step 1:
Search for sqlit3.h
Xcode.app(right-click)-> show package contents
Step 2:
Search for sqlite.h in your Xcode.app
Step 3:
Drag that file into your xcode project and select copy items if needed
Step 4:
Select the sqlite3.h from navigator and change it to Public in the right-side panel.
Step 5:
Import the sqlite3.h in the header file which Xcode has created for you. You should import it as #import "sqlite3.h"
Step 6:
Now Build the project. It should work fine.
I actually get confused some times about why we find only " #import " in all the header files that we create? And again why are we provided only 3 frameworks(Foundation, UIKit,CoreGraphics) when we create any iPhone Application?
UIKit requires Foundation, so it imports it itself. If you import UIKit, you get Foundation for free. Also, as Christoph says, your .pch causes all your files to import Foundation anyway.
In terms of being provided with three frameworks, you can link against whichever ones you like: look in the Target Settings for your app (top item on the left hand sidebar (named after your project), then click on your Target in the next column, then click the Build Phases tab):
Just click the Add button below the list, and you can choose whatever framework you want.
At least when starting a new project from xcode templates, the PreCompiled Headers (.pch) contains
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
so actually, no imports of those two would be required anywhere else.
I tend to drop
#import <UIKit/UIKit.h>
from all my source files and just keep the implicit one via the .pch file.
I'm running into a nasty issue trying to import a header from a project that is embedded in my main project. What is the proper way to import RKJSONParserJSONKit.h indicated below?
I'm trying :
#import "RestKit/Support/RKJSONParserJSONKit.h"
but Xcode cannot find that file.
Just do #import "RKJSONParserJSONKit.h", no need to include /ResKit/Support/
you have to import the JSONKit
#import <RestKit/JSONKit.h>
if you have a problem with importing it as above try to load the kit by
#import "RestKit/Code/Support/Parsers/JSON/RKJSONParserJSONKit.h"
but you should add a copy of the RKParser.h into your project
I ended up just copying the required files over from the sample project over to the main project. A very hasty choice, but spending hours debugging header search paths is not my favorite thing to do in Xcode :/
The instructions for installing the JSON Framework seem to be for older versions of Xcode. I'm relatively unfamiliar with Xcode and I can't figure out how to properly import the framework into my project. I selected all of the files in the "Classes" folder (JSON.h, NSObject+JSON.h, etc.) that comes in the download, dragged them into the main area of my project, and added #import <JSON/JSON.h> to my ViewController's .h and .m files, and I get a No such file or directory error for JSON/JSON.h
What am I doing incorrectly here?
If you’ve placed the files under the Classes group and haven’t taken any further action, they’re at the root of your project directory. As such, import it as
#import "JSON.h"
I think you're indicating that you're importing JSON.h from the JSON folder, and it sounds from your description you don't have those in a folder...
I'm referencing a static library.
I've dragged the library project into my app project and reference it relatively.
The .a file from the library is linked into my app target.
I've added a reference to the librarys .h files' folder via Header Search Paths in the app project.
Then I add an import in my apps .pch file to a particular .h file from the library.
I build and get this error:
some.h: No such file or directory
The project is given info on where to find .h files for the library. Why can't it see them?
Try with
#import <some.h>
instead of
#import "some.h"
I don't think so. I just got one set up today piecing it together from the links below. I didn't include any .h files in search paths. In fact the one tutorial told me to remove any existing search paths (but I had to add them back for another library). Hope this gets you on the right track.
http://www.clintharris.net/2009/iphone-app-shared-libraries/
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://blog.costan.us/2009/02/iphone-development-and-code-sharing.html