+

Search Tips   |   Advanced Search

Add hooks to an application component

You add hooks to an application component to facilitate automation when the component is added to a MobileFirst project. These additional hooks are optional.

To add hooks, we need to edit the component.wcp file by adding XML inner elements. If we do this directly within MobileFirst Studio, the edited component.wcp file is included in the next version of the application component. If we edit the component.wcp file outside MobileFirst Studio, copy the edited file manually into the MobileFirst Studio workspace location and then run the Create Application Component command again so the application component is updated with the latest version of the component.wcp file.

Before we add hooks, we need to add the appropriate environment element according to the environment that the application component supports. The following table lists the element that we add for each supported environment:

Environment Element
Android <Android>
iPhone <IPhone>
iPad <IPad>
The following example component.wcp file includes the Android environment tag:

<ComponentData>
  <ID>BarCodeScannerUniqueID</ID> 
  <Name>Barcode Scanner Android</Name>
  <Author>IBM</Author>
  <Description>Barcode Scanner for Android by IBM</Description>
  <Version>1.0.0</Version>
  <Image>barcodeIcons.jpg</Image>
  <WLVersion>6.1.0</WLVersion>
  <Android></Android>
</ComponentData>

Table 2 lists the inner elements supported on Android and the order in which they must appear in the schema.

Order Inner element
1 CordovaPlugin
2 Activities
3 UserPermissions
4 Receivers
5 Strings
6 ExternalLibraries
7 Libraries

Table 3 lists the inner elements supported on iOS and the order in which they must appear in the schema.

Order Inner element
1 CordovaPlugin
2 Files
3 Libraries

Some hooks result in the insertion of properties in the config.xml file or the AndroidManifest.xml file when the associated application component is added to a MobileFirst project. Every insertion is enclosed in comments that mention the element and application component unique name. For example:

<!--BEGIN ANDROID CORDAVA-PLUGIN AUTOINSERTION FOR BarCodeScannerUniqueID -->
 <!--END ANDROID CORDAVA-PLUGIN AUTOINSERTION FOR BarCodeScannerUniqueID -->


Add and removing Android library projects

Additional Android projects can be packaged as part of the component.wlc file.

Additional projects are packaged in the COMPONENT-DATA folder under the folder ExternalProjects. Any compressed file under that folder is considered to be an "external project" and will be automatically added.

When the component is added to a MobileFirst project, the following things happen:

When the component is removed, the following things happen:


Parent topic: Application components