This directory contains example projects demonstrating how to use the NMSSH framework.
A complete iOS application that demonstrates SSH terminal functionality using NMSSH. The example shows:
- SSH connection establishment
- Interactive terminal session
- Password and key-based authentication
- Real-time command execution
- Xcode with iOS development tools
- Development Team configured in Xcode for code signing
Option 1: Using Xcode IDE
- Open
Examples.xcworkspacein Xcode - Select the PTYExample scheme
- Choose your target device/simulator
- Configure signing team in project settings
- Build and run
Option 2: Command Line
First, build the NMSSH framework:
# Build macOS framework (works on all architectures)
cd /path/to/NMSSH
xcodebuild build -project NMSSH.xcodeproj -scheme NMSSH
# Build iOS framework (requires signing configuration)
xcodebuild build -workspace Examples/Examples.xcworkspace -scheme "NMSSH Framework" -destination 'platform=iOS Simulator,name=iPhone 16'Then build the example:
cd Examples/PTYExample
xcodebuild build -project PTYExample.xcodeproj -scheme PTYExample -destination 'platform=iOS Simulator,name=iPhone 16'- Code Signing Required: The iOS example requires a development team to be configured for code signing
- Deployment Target: The example may need iOS deployment target updates for newer Xcode versions
- Framework Dependencies: The example depends on the NMSSH iOS framework being built first
- Launch the app
- Enter SSH server details:
- Host (e.g.,
example.com:22) - Username
- Choose authentication method (password or key)
- Host (e.g.,
- Tap Connect to establish SSH session
- Use the terminal interface for command execution
NMViewController- Main connection interfaceNMTerminalViewController- Terminal session handlingNMAppDelegate- Application lifecycle management
To integrate NMSSH into your own project:
- Add Framework: Include NMSSH.framework in your project
- Import Headers: Add
#import <NMSSH/NMSSH.h>to your source files - Basic Usage:
// Create session
NMSSHSession *session = [NMSSHSession connectToHost:@"example.com:22"
withUsername:@"user"];
// Authenticate
if (session.isConnected) {
[session authenticateByPassword:@"password"];
if (session.isAuthorized) {
// Execute commands
NSString *response = [session.channel execute:@"ls -la" error:nil];
NSLog(@"Response: %@", response);
}
}
// Cleanup
[session disconnect];- macOS: Builds and runs on all architectures (arm64, x86_64)
- iOS: Requires code signing and may need deployment target updates
- Dependencies: Uses libssh2 and OpenSSL (included as precompiled binaries)
For more detailed API documentation, see the main project README and the API documentation.