Build Hybrid Sample Apps
To build hybrid apps from the samples
directory of the SalesforceMobileSDK-Shared repository, you use forcehybrid and the Cordova command line. You create a hybrid_local
or hybrid_remote
app and then add the web assets—HTML, JavaScript, and CSS files—and the bootconfig.json
file from the Shared repo.
The ContactExplorer sample requires the cordova-plugin-contacts
and cordova-plugin-statusbar
plug-ins.
The other hybrid sample apps do not require special Cordova plug-ins.
To build one of the sample apps:
-
Open a command prompt or terminal window.
-
Clone the shared repo:
-
Use forcehybrid to create an app.
- For platform, enter one or both platform names: “ios”, “android”, or “ios,android”.
- For application type (or the
apptype
parameter), enter “hybrid_local”.
-
Change to your new app directory:
-
For each additional Cordova plug-in you want to add, type:
Go to https://plugins.cordova.io to search for available plug-ins.
-
(Optional—Mac only) To add iOS support to an Android project “after the fact”:
-
(Optional—Mac only) To add Android support to an iOS project “after the fact”:
-
Copy the sample source files to the
www
folder of your new project directory.On Mac:
On Windows:
If you’re asked, affirm that you want to overwrite existing files.
-
Do the final Cordova preparation:
- Android Studio refers to forcehybrid projects by the platform name ("android"). For example, to run your project, select "android" as the startup project and then click Run.
- On Windows, Android Studio sets the default project encoding to
windows-1252
. This setting conflicts with theUTF-8
encoding of the forcehybrid Gradle build files. For best results, change the default project encoding toUTF-8
. - On Windows, be sure to run Android Studio as administrator.