+

Search Tips   |   Advanced Search

Including and excluding application features

If features such as JSONStore are not used in the application or in certain environments, we can reduce the application size by excluding them.

With IBM MobileFirst Platform Foundation, we can include or exclude features from the application build if those features are not required. For example, JSONStore offers many benefits, if code that references it is actually used in the application. If it is not used, the JSONStore resources greatly increase the application size, and thus slow both initial app download time and app start time.

There is a new <features> element in the Application Descriptor that controls the inclusion or exclusion of resources. In application-descriptor.xml itself, this element appears similar to the following example, which shows JSONStore resources being included in the build:

<application xmlns="http://www.worklight.com/application-descriptor" id="myApp" platformVersion="6.0.0">
    ...
    <features>
        <JSONStore/>
    </features>
    ...
</application>
For more information about Application Descriptor attributes, see The application descriptor.

When we first create a MobileFirst application, the <features> tag is automatically created in application-descriptor.xml, with no contents. What this means is that if we use JSONStore in the code, it is not automatically added to the builds. When we run the application, you receive an error, as shown in the following screen capture:

We can resolve this situation using an Eclipse QuickFix:

But we can also choose which features to include in the build with the MobileFirst Studio editor, as shown in the following procedure.


To include or exclude features in MobileFirst Studio

  1. In MobileFirst Studio, open application-descriptor.xml for the application with the Application Descriptor Editor:

    If the Optional Features element is empty (as in the screen capture), no features such as JSONStore are included in the build.

  2. To add features, click Add to display the Add Item window:

  3. Choose the feature to add to the build (in this example, JSONStore), and click OK.

  4. The Application Description Editor now displays JSONStore as an attribute of Optional Features, along with Details about the feature in the right panel:

  5. To remove a feature, select it in the left panel and click Remove.


Parent topic: Optimizing MobileFirst applications