To upgrade native and hybrid, we strongly recommend creating a new app from the app templates in the forceios npm package, then migrating the artifacts specific to your app into the new template. Read on if you prefer to update the Mobile SDK artifacts in your existing app.
The easiest way to do this is delete everything in the Dependencies folder of your app's Xcode project, and then add the new libraries.
- In your Xcode project, in Project Navigator, locate the Dependencies folder. Control-click the folder, choose Delete, and select "Move to Trash".
- Download the following binary packages from the distribution repo:
- Cordova/Cordova-Release.zip
- SalesforceHybridSDK-Release.zip
- SalesforceOAuth-Release.zip
- SalesforceSDKCore-Release.zip
- SalesforceSecurity-Release.zip
- Also, download the following folders from the ThirdParty folder link in the distribution repo, for placement in your Dependencies folder:
- SalesforceCommonUtils
- openssl
- sqlcipher
- Recreate the Dependencies folder, under your app folder.
- Unzip the new packages from step 2, and copy the folders from step 3, into the Dependencies folder.
- In Project Navigator, control-click your app folder and select 'Add Files to "<App Name>"...'.
- Select the Dependencies folder, making sure that "Create groups for any added folder" is selected.
- Click Add.
- Click your project in Project Navigator.
- Select the Build Settings tab of your main target.
- Scroll down to (or search/filter for) Header Search Paths.
- Add the following search path:
- $(SRCROOT)/[App Name]/Dependencies/SalesforceSecurity/Headers
For your hybrid "local" apps, replace the following files in the www/ folder of your app with the new versions from the libs folder of the SalesforceMobileSDK-Shared repo:
- cordova.force.js
- forcetk.mobilesdk.js
- smartsync.js
Some of the APIs around user management have changed, as well as the patterns for handling logout and login host change events. It is highly recommended that you consult the AppDelegate code from a new version of a forceios hybrid app, to see the changes. At a high level, the changes are:
- Logout and login host change notifications have moved into delegate methods. Your AppDelegate should implement the
SFAuthenticationManagerDelegateandSFUserAccountManagerDelegatedelegates, specifically:[SFAuthenticationManagerDelegate authManagerDidLogout:]for user logout.[SFUserAccountManagerDelegate userAccountManager:didSwitchFromUser:toUser:]for login host changes, which effectively changes users now.
The easiest way to do this is to delete everything in the Dependencies folder of your app's Xcode project, and then add the new libraries.
- In your Xcode project, in Project Navigator, locate the Dependencies folder. Control-click the folder, choose Delete, and select "Move to Trash".
- Download the following binary packages from the distribution repo:
- MKNetworkKit-iOS-Release.zip
- SalesforceNativeSDK-Release.zip
- SalesforceNetworkSDK-Release.zip
- SalesforceOAuth-Release.zip
- SalesforceSDKCore-Release.zip
- SalesforceSecurity-Release.zip
- Also, download the following folders from the ThirdParty folder link in the distribution repo, for placement in your Dependencies folder:
- SalesforceCommonUtils
- openssl
- sqlcipher
- Recreate the Dependencies folder, under your app folder.
- Unzip the new packages from step 2, and copy the folders from step 3, into the Dependencies folder.
- In Project Navigator, control-click your app folder and select 'Add Files to "<App Name>"...'.
- Select the Dependencies folder, making sure that "Create groups for any added folder" is selected.
- Click Add.
- Click your project in Project Navigator.
- Select the Build Settings tab of your main target.
- Scroll down to (or search/filter for) Header Search Paths.
- Add the following search path:
- $(SRCROOT)/[App Name]/Dependencies/SalesforceSecurity/Headers
SalesforceSecurity is a new library in 2.2, and many of the security-related classes—particularly classes related to passcode management—have moved into this class from SalesforceSDKCore. If you have code that referenced passcode-related functionality from SalesforceSDKCore, you'll want to update your references to their SalesforceSecurity counterparts.
Some of the APIs around user management have changed, as well as the patterns for handling logout and login host change events. It is highly recommended that you consult the AppDelegate code from a new version of a forceios native app, to see the changes. At a high level, the changes are:
- Specifying your Connected App configuration is done through
SFUserAccountManagernow, where it was done throughSFAccountManagerin 2.1. Make the following changes:- Instead of using
[SFAccountManager setClientId:], use[SFUserAccountManager sharedInstance].oauthClientId [SFAccountManager setRedirectUri:]is set using[SFUserAccountManager sharedInstance].oauthCompletionUrl- Setting scopes goes from
[SFAccountManager setScopes:]to[SFUserAccountManager sharedInstance].scopes
- Instead of using
- Logout and login host change notifications have moved into delegate methods. Your AppDelegate should implement the
SFAuthenticationManagerDelegateandSFUserAccountManagerDelegatedelegates, specifically:[SFAuthenticationManagerDelegate authManagerDidLogout:]for user logout.[SFUserAccountManagerDelegate userAccountManager:didSwitchFromUser:toUser:]for login host changes, which effectively changes users now.
To upgrade native and hybrid, we strongly recommend creating a new app from the app templates in the forceios npm package, then migrating the artifacts specific to your app into the new template. Read on if you prefer to update the Mobile SDK artifacts in your existing app.
The easiest way to do this is delete everything in the Dependencies folder of your app's Xcode project, and then add the new libraries.
- In your Xcode project, in Project Navigator, locate the Dependencies folder. Control-click the folder, choose Delete, and select "Move to Trash".
- Download the following binary packages from the distribution repo:
- Cordova/Cordova-Release.zip
- SalesforceHybridSDK-Release.zip
- SalesforceOAuth-Release.zip
- SalesforceSDKCore-Release.zip
- Also, download the following folders from the ThirdParty folder link in the distribution repo, for placement in your Dependencies folder:
- SalesforceCommonUtils
- openssl
- sqlcipher
- Recreate the Dependencies folder, under your app folder.
- Unzip the new packages from step 2, and copy the folders from step 3, into the Dependencies folder.
- In Project Navigator, control-click your app folder and select 'Add Files to "<App Name>"...'.
- Select the Dependencies folder, making sure that "Create groups for any added folder" is selected.
- Click Add.
Update the header search paths of your project in Xcode:
- Click your project in Project Navigator.
- Select the Build Settings tab of your main target.
- Scroll down to (or search/filter for) Header Search Paths.
- Add the following search paths:
- $(SRCROOT)/[App Name]/Dependencies/SalesforceSDKCore/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceOAuth/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceCommonUtils/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceHybridSDK/Headers
For your hybrid "local" apps, replace the following files in the www/ folder of your app with the new versions from the libs folder of the SalesforceMobileSDK-Shared repo:
- cordova.force.js
- forcetk.mobilesdk.js
- smartsync.js
The easiest way to do this is to delete everything in the Dependencies folder of your app's Xcode project, and then add the new libraries.
- In your Xcode project, in Project Navigator, locate the Dependencies folder. Control-click the folder, choose Delete, and select "Move to Trash".
- Download the following binary packages from the distribution repo:
- MKNetworkKit-iOS-Release.zip
- SalesforceNativeSDK-Release.zip
- SalesforceNetworkSDK-Release.zip
- SalesforceOAuth-Release.zip
- SalesforceSDKCore-Release.zip
- Also, download the following folders from the ThirdParty folder link in the distribution repo, for placement in your Dependencies folder:
- SalesforceCommonUtils
- openssl
- sqlcipher
- Recreate the Dependencies folder, under your app folder.
- Unzip the new packages from step 2, and copy the folders from step 3, into the Dependencies folder.
- In Project Navigator, control-click your app folder and select 'Add Files to "<App Name>"...'.
- Select the Dependencies folder, making sure that "Create groups for any added folder" is selected.
- Click Add.
Update the header search paths of your project in Xcode:
- Click your project in Project Navigator.
- Select the Build Settings tab of your main target.
- Scroll down to (or search/filter for) Header Search Paths.
- Add the following search paths:
- $(SRCROOT)/[App Name]/Dependencies/SalesforceSDKCore/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceOAuth/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceNetworkSDK/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceCommonUtils/Headers
- $(SRCROOT)/[App Name]/Dependencies/SalesforceNativeSDK/Headers
In 2.1, the Mobile SDK has replaced RestKit with MKNetworkKit as the network library for native apps. MKNetworkKit is wrapped by the new SalesforceNetworkSDK library, which in turn is wrapped by the SFRestAPI class and its supporting classes. Most of the interfaces remain the same. Some notable changes include:
- REST requests are now automatically initiated on background threads, and their responses will be returned to your delegate on the same thread as the request. This means that if you plan to do UI-related updates from your delegate methods, you need to explicitly ensure that such code runs on the main thread, via
dispatch_async(dispatch_get_main_queue(), ^{ })or a similar construct. [SFRestAPI sharedInstance].rkClientno longer exists.[SFRestAPI send:delegate:]now returns the newSFNetworkOperationassociated with the request.SFRestRequest.networkOperationpoints to the underlyingSFNetworkOperationobject associated with the request.
If your app was using any of the underlying RestKit members for networking, you'll need to look at the equivalent functionality in MKNetworkKit and the SalesforceNetworkSDK.