Create a Template Project
First, make sure you’ve installed Salesforce Mobile SDK using the NPM installer. For iOS instructions, see iOS Preparation. For Android instructions, see Android Preparation.
Also, download the ratchet.css file from http://goratchet.com/.
Once you’ve installed Mobile SDK, create a local hybrid project for your platform.
-
At a Terminal window or Windows command prompt, run the forcehybrid
create command using the following values:
Here’s a command line example:
Prompt (or Parameter) Value Platform (--platform) ios, android, or ios,android Application type (--apptype) hybrid_local Application name (--appname) UserSearch Package name (--packagename) com.acme.usersearch Organization (--organization) “Acme Widgets, Inc.” Output directory (--outputdir) Leave blank for current directory, or enter a name to create a new subdirectory for the project 1forcehybrid create --platform=ios,android --apptype=hybrid_local 2 --appname=UserSearch --packagename=com.acme.usersearch 3 --organization="Acme Widgets, Inc." --outputdir="" -
Copy all files—actual and symbolic—from the
samples/usersearch directory of the https://github.com/forcedotcom/SalesforceMobileSDK-Shared/
repository into the www/ folder, as follows:
- In a Mac OS X terminal window, change to your project’s root
directory—./UserSearch/—and type this command:
1cp -RL <insert local path to SalesforceMobileSDK-Shared>/samples/UserSearch/* www/ - In Windows, make sure that every file referenced in the
<shared repo>\samples\usersearch
folder also appears in your
<project_name>\www folder. Resolve
the symbolic links explicitly, as shown in the following
script:
1cd <your project's root directory> 2set SHARED_REPO=<insert local path to SalesforceMobileSDK-Shared> 3copy %SHARED_REPO%\samples\usersearch\UserSearch.html www 4copy %SHARED_REPO%\samples\usersearch\bootconfig.json www 5copy %SHARED_REPO%\dependencies\ratchet\ratchet.css www 6copy %SHARED_REPO%\samples\common\styles.css www 7copy %SHARED_REPO%\test\MockCordova.js www 8copy %SHARED_REPO%\samples\common\auth.js www 9copy %SHARED_REPO%\dependencies\backbone\backbone-min.js www 10copy %SHARED_REPO%\libs\cordova.force.js www 11copy %SHARED_REPO%\dependencies\fastclick\fastclick.js www 12copy %SHARED_REPO%\libs\force.js www 13copy %SHARED_REPO%\libs\force+promise.js www 14copy %SHARED_REPO%\dependencies\jquery\jquery.min.js www 15copy %SHARED_REPO%\libs\mobilesync.js www 16copy %SHARED_REPO%\samples\common\stackrouter.js www 17copy %SHARED_REPO%\dependencies\underscore\underscore-min.js www
- In a Mac OS X terminal window, change to your project’s root
directory—./UserSearch/—and type this command:
-
Run the following command:
1cordova prepare - Open the platforms/android/ project folder in Android Studio (for Android) or Xcode (for iOS) by following the onscreen instructions printed by forcehybrid.
- From the www folder, open UserSearch.html in your code editor and delete all its contents.