iOS native bridge layer and libraries for Cordova-based hybrid mobile applications.
This repository provides the iOS native implementation for hybrid apps built with the Salesforce Mobile SDK and Apache Cordova. It bridges JavaScript Cordova plugins to iOS native SDK functionality, enabling hybrid apps to leverage authentication, SmartStore, MobileSync, and REST APIs.
- SalesforceHybridSDK: Cordova plugin bridges and hybrid view management
- SalesforceFileLogger: File-based logging for hybrid apps
- Sample Apps: Demo applications showcasing SDK features
- Dependencies: iOS SDK, Cordova, and CocoaLumberjack as submodules
Hybrid App (HTML/JS/CSS)
↓
Cordova Plugins (JavaScript)
↓
SalesforceHybridSDK (iOS Bridge - this repo)
↓
iOS Mobile SDK (Native)
↓
Salesforce Platform
We recommend using the forcehybrid command-line tool to create hybrid apps:
# Install CLI tools
npm install -g forcehybrid
# Create a new hybrid app
forcehybrid create
--platform ios
--appname MyHybridApp
--packagename com.mycompany.myhybridapp
--organization "My Company"This creates a complete Cordova-based hybrid app with the Salesforce Mobile SDK pre-configured.
If you want to work with the iOS Hybrid SDK source code:
Prerequisites:
- macOS with Xcode 15+
- Git (for submodule management)
- CocoaPods
Setup:
# Clone the repository
git clone https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Hybrid.git
cd SalesforceMobileSDK-iOS-Hybrid
# Pull submodule dependencies
./install.sh
# Open the workspace
open SalesforceMobileSDK-Hybrid.xcworkspaceImportant: Always open the .xcworkspace file, not individual .xcodeproj files.
SalesforceHybridSDK
- Main hybrid bridge library
- Cordova plugin implementations (OAuth, SmartStore, MobileSync, Network, SDKInfo)
- Hybrid view controller and configuration
- WKWebView cookie management
- Minimum iOS: 18.0
SalesforceFileLogger
- File-based logging with rotation
- Integration with CocoaLumberjack
- Log export for debugging
AccountEditor
- Basic CRUD operations on Account records
- Demonstrates Cordova plugin usage
- Local hybrid app example
MobileSyncExplorerHybrid
- Complete MobileSync demo
- Offline data synchronization
- SmartStore integration
- Conflict resolution
Git submodules for core dependencies:
- SalesforceMobileSDK-iOS: iOS native SDK
- shared: Shared JavaScript libraries (SalesforceMobileSDK-Shared)
- cordova: Apache Cordova for iOS
- CocoaLumberjack: Logging framework
Native iOS implementations of Salesforce Cordova plugins:
| Plugin | Purpose |
|---|---|
| OAuth | Authentication, login, logout, user management |
| SmartStore | Encrypted local storage (SQLCipher-backed) |
| MobileSync | Bidirectional data synchronization |
| Network | REST API requests to Salesforce |
| SDKInfo | SDK version and configuration information |
| AccountManager | Multi-user account management |
- SFHybridViewController: Manages Cordova WebView lifecycle
- SFHybridViewConfig: Configures local vs remote app behavior
- Cookie Management: Shares Salesforce sessions between native and WebView
- Authentication Flow: Handles OAuth before loading app content
# Build the library
xcodebuild -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
-scheme SalesforceHybridSDK \
-sdk iphonesimulator \
build
# Run tests
xcodebuild test -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
-scheme SalesforceHybridSDK \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15'- Open
SalesforceMobileSDK-Hybrid.xcworkspace - Select
AccountEditororMobileSyncExplorerHybridscheme - Choose a simulator or device
- Build and run (Cmd+R)
Unit Tests: Located in libs/SalesforceHybridSDK/SalesforceHybridSDKTests/
- Test Cordova plugin bridges
- Test hybrid view configuration
- Test cookie management
Integration Tests: Sample apps serve as integration tests
- Verify end-to-end plugin functionality
- Test authentication flows
- Validate data synchronization
// After including cordova.js and cordova.force.js
// OAuth - Get current user
navigator.oauth.getAuthCredentials(
function(creds) {
console.log('User:', creds.userName);
},
function(error) {
console.error('Auth error:', error);
}
);
// SmartStore - Query data
navigator.smartstore.querySoup(
false, // isGlobalStore
'accounts',
querySpec,
function(results) {
console.log('Found:', results.totalEntries, 'entries');
},
function(error) {
console.error('Query error:', error);
}
);
// Network - REST API call
com.salesforce.plugin.network.sendRequest(
'/services/data/v56.0/query/',
'SELECT Id, Name FROM Account LIMIT 10',
function(response) {
console.log('Accounts:', response.records);
},
function(error) {
console.error('API error:', error);
}
);// Example: Implementing a Cordova plugin
@interface MyPlugin : CDVPlugin
- (void)myMethod:(CDVInvokedUrlCommand*)command;
@end
@implementation MyPlugin
- (void)myMethod:(CDVInvokedUrlCommand*)command {
[self.commandDelegate runInBackground:^{
// Do work
NSString* result = @"Success";
CDVPluginResult* pluginResult = [CDVPluginResult
resultWithStatus:CDVCommandStatus_OK
messageAsString:result];
[self.commandDelegate sendPluginResult:pluginResult
callbackId:command.callbackId];
}];
}
@end| iOS Hybrid SDK | iOS SDK | Cordova iOS | iOS Min | Xcode |
|---|---|---|---|---|
| 13.2.0 | 13.2.0 | 7.1.1 | 17.0 | 15+ |
| 13.1.0 | 13.1.0 | 7.1.0 | 16.0 | 15+ |
| 13.0.0 | 13.0.0 | 7.1.0 | 16.0 | 15+ |
See release notes for detailed version history.
The SalesforceHybridSDK library is distributed via CocoaPods:
pod 'SalesforceHybridSDK', '~> 13.2'Note: Typically installed automatically by the Cordova plugin, not added directly.
This repo provides the iOS implementation consumed by the SalesforceMobileSDK-CordovaPlugin package.
- Mobile SDK Development Guide: https://developer.salesforce.com/docs/platform/mobile-sdk/guide
- iOS SDK Documentation: https://forcedotcom.github.io/SalesforceMobileSDK-iOS
- Mobile SDK Trail: https://trailhead.salesforce.com/trails/mobile_sdk_intro
- Cordova Documentation: https://cordova.apache.org/docs/
- iOS SDK (native): https://github.com/forcedotcom/SalesforceMobileSDK-iOS
- Android Hybrid: https://github.com/forcedotcom/SalesforceMobileSDK-Android (libs/SalesforceHybrid)
- Shared JavaScript: https://github.com/forcedotcom/SalesforceMobileSDK-Shared
- Cordova Plugin: https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin
- Templates: https://github.com/forcedotcom/SalesforceMobileSDK-Templates
- Issues: GitHub Issues
- Questions: Salesforce Stack Exchange
- Community: Trailblazer Community
We welcome contributions! Please:
- Read the CLAUDE.md file for development guidelines
- Follow existing code style and conventions
- Write or update tests for new functionality
- Test on iOS devices and simulators
- Ensure changes are compatible with Android hybrid implementation
- Submit a pull request with a clear description
- Run unit tests for SalesforceHybridSDK
- Build and test sample apps (AccountEditor, MobileSyncExplorerHybrid)
- Verify no Xcode warnings or errors
- Test with hybrid templates if changing public APIs
Salesforce Mobile SDK License. See LICENSE file for details.
Please report security vulnerabilities to security@salesforce.com. See SECURITY.md for more information.