For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Enabling JSONStore
To use JSONStore in MobileFirst applications, we must take steps to enable it.
For iOS native apps, we must import the JSONStore iOS framework into the Xcode project.We can obtain the JSONStore feature in two ways:
- We can import the JSONStore framework manually or with CocoaPods. For more information, see Set up the Xcode project for iOS manually.
To use CocoaPods:
- You must have CocoaPods, the dependency manager for Xcode projects installed in your development environment. For more information, see the "Getting Started" guide for CocoaPods installation.
- Your application must be set up to use CocoaPods. For more information, see Using CocoaPods.
- You must have an existing Podfile. If one does not exist, create one by using the pod init command. For more information, see Using CocoaPods.
- Create a Podfile file or edit an existing one.
- Create a new file named Podfile by using the pod init command.
- Open the Podfile file that is in the root directory of the project with a text editor.
- Add the following lines and save the file:
pod 'IBMMobileFirstPlatformFoundationJSONStore'
Note: The above syntax imports assumes you are using the latest version of the IBMMobileFirstPlatformFoundation. If you are are not using the latest version of MobileFirst, you need to indicate the version. For example, for importing the latest pod for 8.0.0 IBMMobileFirstPlatformFoundation the line would look like this:
pod 'IBMMobileFirstPlatformFoundationJSONStore', '~> 8.0.0'
Open Terminal and navigate to the location of the Podfile file. Verify that the Xcode project is closed. Type pod install to run the pod install command. This command installs the JSONStore Framework for IBM MobileFirst Platform Foundation, called the IBMMobileFirstPlatformFoundationJSONStore.framework component, and integrates it with the mobile application Xcode project.
You must import the JSONStore.h header file in your code to use the JSONStore API. For Objective C add #import <IBMMobileFirstPlatformFoundationJSONStore/IBMMobileFirstPlatformFoundationJSONStore.h>. For Swift, add import IBMMobileFirstPlatformFoundationJSONStore.
For more information about creating native MobileFirst iOS applications, see Develop native applications for iOS in Xcode.
For native Android applications, we must add the files using gradle. For more information about creating native MobileFirst Android applications, see Set up Android Studio projects with Gradle.
After adding the JSONStore SDK, we can use the classes inside the com.worklight.jsonstore.api package to use JSONStore.
For Cordova applications, we must add the cordova-plugin-mfp-jsonstore plug-in to our MobileFirst Cordova app. For more information see Add MobileFirst features to an existing Cordova app.
Parent topic: JSONStore