Frugghi / SwiftSH

A Swift SSH framework that wraps libssh2.
MIT License
195 stars 75 forks source link

Using SwiftSH in Objective C #3

Closed iDevo closed 6 years ago

iDevo commented 6 years ago

Hi Frugghi! First of all thank you all so much for sharing your awesome library! I switched from NMSSH and already tested your project in a tiny Swift Hello-World, which worked great.

Due to the fact that my existing App is written in ObjC, I'd like to get everything running within a ObjC class but the compiler can't find any classes, like for example the Command class or the SSHConnection class beyond. I tried multiple lines of code, in order to import the framework into my ObjC wrapper class:

#import "<MyProjectName>-Swift.h"

#import <SwiftSH/SwiftSH-Swift.h>
#import <SwiftSH/SwiftSH-umbrella.h>

@import SwiftSH;

Of course I followed your handy description to install the framework via CocoaPods. Do you have any idea, recommendation or workaround?

Thank you very much!

iDevo commented 6 years ago

I figured out, the best way is to simply create a swift wrapper and use this swift wrapper to interact between your ObjC classes and the framework.

So simply create a new NSObject swift file and follow Frugghi's documentation, to set everything up. Then go to your ObjC file and import your <MyProjectName>-Swift.hfile, so you can call your swift functions using ObjC.