Further libssh2 wrapper updates
I’ve written a small shell script that takes the archive downloaded from http://www.libssh2.org, extracts it, compiles it, extracts the headers and archive library and then tidies up after itself. The results just need adding to Xcode and you have a working libssh2 implementation.
Updated source code:
https://github.com/thebsdbox/DFSSHWrapper
Read MoreUpdate to the sshwrapper
Had quite a few emails recently about using the ssh wrapping class I wrote aaaages ago. I’ve traded a couple of emails back and forth.. and decided that it would be easier for everyone if I just updated these old classes.
So the changes:
- Added DFSSHConnectionType, this class is used to define how ssh will attempt to connect (password/key/keyboard)
- Moved everything to a namespace (DF)
- ARC
- Tidied up the code, and sorted an issue with CStrings making a mess when converting to an NSString
- Other things I did ages ago.. (no idea)
It’s uploaded to github.. let me know if there is any problems..
https://github.com/thebsdbox/DFSSHWrapper
[UPDATE]: Added the ability to place a timeout on a command sent over ssh…
Read MoreObjective-C graphing and plotting with little-plot
As development has continued on a personal project it became obvious that I would need to implement UI elements that simply weren’t part of the Cocoa UI-kit. Essentially the main goal is presenting the user with a graph interface allowing them to quickly see a data set without having to read through line after line of figures. I looked at Core Plot (http://code.google.com/p/core-plot/), which whilst providing some great functionality looks like a HUGE amount of overkill when wanting a simple UI element.
So after a few days of tinkering I’ve created a couple of NSView subclasses allowing either manually created Views that can be presented arrays and will display the data accordingly.
I present Little-plot :

The above screenshot consists of three NSViews (LineView, PieView and LabelView), which each display a line graph, a pie chart and graph labels (or legends).
The project is available on GitHub here.
Updates will appear soon, along with some real documentation.
Read MoreObjective-C modal Window using sheets and Panels
Adding a modal sheet to a window in objective-C isn’t highly complicated however there are a number of issues to watch for that can leave you scratching your head. Most of the examples I’ve found on the internet point to an older useModal: (*window) function which is deprecated. From what i’ve read, the correct manner for using a modal dialog is to display a sheet that scrolls down from the menu bar and takes modal control. There are numerous examples of this in System Preferences:
Implementing this in an application coded with objective-C isn’t relatively complicated however missing a particular setting can leave you with numerous errors or causing the application to fall back to the debugger.
Read MoreCocoa libssh2 wrapper
I’ve modified a simple wrapper for the libssh2 library that now has the following functionality:
- Code moved to separate classes to allow reusability
- Multiple sessions to different servers can be achieved with a few lines of code
- A Session can be passed to the operator class allowing operations (commands sent to it), more will be added
SSH with Cocoa (Xcode and libssh2)
I fought with this about a year ago, and for some strange reason never managed to get things to compile or link. I chalk this down now to my lack of understanding with Objective-C/linking concepts. However it turns out that it is relatively simple (ensure you have Xcode 4 installed before trying).
- Point browser to http://www.libssh2.org/ and download the latest snapshot to a temporary location.
- Open a terminal window and navigate to the directory containing the the source files and run the following:
dan$ ./configure
- This will output numerous content to the terminal window, present a summary of the configuration options and create a header file needed for compilation. (Running make / make install is NOT required).
- Open Xcode and create a new Xcode project, which should be a (Mac OS X -> Framework & Library -> C/C++ Library) and give it a Product Name (e.g. libssh2) and ensure that the type is Static then click create.
- Xcode will open with an empty project displaying the Build Settings. At this point we can start adding the files that are part of the libssh2 source tree.



