New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using socket.io-client-swift in an Objective-C framework. #393
Comments
I'm not sure. I know there's some problem where you can't make it a static framework. |
Right. In Xcode 7.3, after I added the swift files and tried to compiled my framework, it errored: Swift is not supported for static libraries. But maybe we can compile your lib into a framework first, then link to it? Haven't tried that yet. Just a thought. |
@hifall Change your build target from a static library to a framework. You can then use socket.io in it without issues. You can also build socket.io as a framework as import that. In my project I'm building socket.io and other frameworks using carthage without issues. |
@drekka, thanks for the hint. But any chance you could provide a bit more detail on "Change your build target from a static library to a framework", or provide any pointer to it? I am building my framework following this link: https://github.com/jverkoey/iOS-Framework. Thanks! |
Whoa. That information is really out of date - don't do that :-) Building a framework these days is dead simple. In Xcode add a new target using the Framework & Library/Cocoa Touch Framework template. Then just add your code like you would for a static library. XCode will build a *.framework file ready for use. I did a quick search and found this article: https://robots.thoughtbot.com/creating-your-first-ios-framework It seems to be very good in that it shows how easy it is, then goes on to handling dependencies, CocoaPods and Carthage support, and testing. Pretty much everything you would do as part of building an API. |
@drekka, thanks for getting back to me! I am indeed not up to date on iOS framework building these days. I will definitely do some research in this area by following your link shortly. Again, thanks for the link. |
I too am trying to get this library working from Objective-C. I've added a framework, added the swift source files, and built the framework. I shouldn't need to add @objc to the class as it is already inheriting from NSObject. The documentation herein regarding this seems to be missing some steps. |
I have an objective c project that I want to use the swift library in. I found out that there's a auto generated bridging header file that I have to include in my objective-C file that I want to use this swift library from. Not withstanding I'm not sure that this is even the correct library to use since I'm using websockets.I saw other issues where another library for specifically websockets was being mentioned.
|
ok. Can't speak for web sockets, but here is basically what I did to use the socket.io framework:
Hope that helps. |
Thanks! Sent from my iPhone
|
why have not oc,if use swift to create static framework,it will be add libSwiftBridge.a,has 100M+ |
@drekka I'm adding a dependency, and get the following error: *** Building scheme "Starscream" in Starscream.xcodeproj |
Hi,
We are trying to integrate your socket.io-client-swift library into our existing Objective-C framework which will be released to other developers to integrate into their applications.
Is this scenario considered when you develop socket.io-client-swift? Is there anything special (compared with integrating socket.io-client-swift into an app) we need to consider?
Thanks!
The text was updated successfully, but these errors were encountered: