iOS vs Android Differences
Connection Methods
The underlying implementation differs between platforms:- iOS
- Android
SFTP Disconnect
On iOS, the SFTP channel isn’t explicitly closed when calling
disconnectSFTP(). The workaround is to call client.disconnect() which closes both SSH and SFTP connections.File Permissions (chmod)
Event Emitters
The platforms use different event emitter implementations:- iOS: Uses
NativeEventEmitter - Android: Uses
DeviceEventEmitter
iOS Simulator Limitations
Why Simulators Don’t Work
The iOS implementation uses the NMSSH library, which depends on native SSH libraries that are not available in the iOS simulator environment.Workaround
Development Strategy
1
Use Android Emulator for development
The Android emulator fully supports SSH operations:
2
Test on physical iOS device
For iOS testing, always use a physical device:
3
Implement platform checks
Add runtime checks to gracefully handle simulator scenarios:
OpenSSL and Flipper Conflicts
The Problem
Flipper (React Native’s debugging tool) includes its own copy of OpenSSL, which conflicts with the OpenSSL version used by NMSSH.Symptoms
- Build failures with duplicate symbol errors
- Crashes on app launch
- SSH connection failures with cryptic OpenSSL errors
Solution: Disable Flipper
Edit yourios/Podfile:
Alternative: Use Expo Dev Tools
If you need debugging capabilities, consider using Expo Dev Tools or React Native Debugger instead of Flipper.Native Library Dependencies
The library wraps different native SSH implementations on each platform:- iOS
- Android
NMSSH LibraryAfter modifying the Podfile:
- Based on libssh
- Requires manual Podfile configuration
- Uses aanah0’s fork for updated libssh version
Best Practices for Cross-Platform Development
1
Abstract platform differences
Create wrapper functions that handle platform-specific code:
2
Test on both platforms
Always test your SSH functionality on both platforms:
3
Graceful degradation
Handle unavailable features gracefully:
Known Issues and Workarounds
iOS: Cannot test on simulator
iOS: Cannot test on simulator
Issue: SSH functionality doesn’t work on iOS simulator.Workaround: Use physical iOS device for testing, or develop/test primarily on Android emulator.See: GitHub Issue #20
iOS: SFTP disconnect incomplete
iOS: SFTP disconnect incomplete
Issue:
disconnectSFTP() doesn’t fully close the SFTP channel on iOS.Workaround: Use disconnect() to close both SSH and SFTP connections.iOS: OpenSSL conflicts with Flipper
iOS: OpenSSL conflicts with Flipper
Issue: Flipper’s OpenSSL conflicts with NMSSH’s OpenSSL.Workaround: Disable Flipper in your Podfile.
Android: No chmod support needed
Android: No chmod support needed
Issue: iOS doesn’t have native chmod support.Workaround: Use SSH execute() with chmod command.
Platform Detection Utilities
Here’s a utility module for common platform checks:Next Steps
- Review SSH command execution for remote operations
- Learn about file transfers with progress tracking
- Explore SFTP operations for file management