Search code examples
ibm-mobilefirstworklight-studio

IBM Worklight 5.0.x - Changing the main HTML filename


I want my main html file to have a different name than my project.

I have found that Worklight will not reconnect if I don't use the same name. I have tried changing the mainFile tag in the application-descriptor.xml and changing the wlMainFile entry in worklight.plist on iOS.

Direct Update does not work. More importantly the application does not reconnect and I get a grey screen (presumably because iOS is trying to launch using the wrong file).

For example:

Project name: MyProject
main file: home.html
application-descriptor.xml: <mainFile>home.html</mainFile>
worklight.plist: <wlMainFile>home.html</wlMainFile>

The above does not work.

[Edited later to add my application-descriptor.xml]

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Licensed Materials - Property of IBM
             5725-G92 (C) Copyright IBM Corp. 2006, 2012. All Rights Reserved.
         US Government Users Restricted Rights - Use, duplication or
         disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
<!-- Attribute "id" must be identical to application folder name -->
<application xmlns="http://www.worklight.com/application-descriptor" id="agent" platformVersion="5.0.6">
 <displayName>My app</displayName>
 <description>My application description </description>
 <author>
    <name>Redacted</name>
    <email>redacted@foo.com</email>
    <homepage>http://redacted.com</homepage>
    <copyright>(c) redacted LLC</copyright>
 </author>
<height>748</height>
<width>1024</width>
<mainFile>home.html</mainFile>
<thumbnailImage>common/images/ipad-app-icon.png</thumbnailImage>
<!--  -->
<ipad bundleId="com.redacted.myproject" version="1.0">
    <worklightSettings include="true"/>
    <security>
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
    </security>
</ipad>
<!--  -->
<android version="1.0">
    <worklightSettings include="true"/>
    <security>
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
        <publicSigningKey>Replace this text with the public key of the certificate with which you sign the APK. 
        For details see the Worklight Developer's Reference Guide.</publicSigningKey>
    </security>
</android>
<worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
</application>

So, to be clear, if I have encountered an issue with my mainFile being a name other than the project name. Worklight does not always call the filename specified by mainfile, especially after the initial use of the application.


Solution

  • If changing the HTML filename, make sure to also change:

    1. The application folder name
    2. In application-descriptor.xml:

      • id attribute in the application element
      • mainFile element value

    All should match each other.

    Make sure to delete the native folder and re-build the project. Application will continue loading after the first time, and Direct Update will continue to function.