【问题标题】:IBM Worklight 5.0.x - Changing the main HTML filenameIBM Worklight 5.0.x - 更改主 HTML 文件名
【发布时间】:2013-06-21 22:04:12
【问题描述】:

我希望我的主 html 文件具有与我的项目不同的名称。

我发现如果我不使用相同的名称,Worklight 将不会重新连接。我尝试更改 application-descriptor.xml 中的 mainFile 标记并更改 iOS 上 worklight.plist 中的 wlMainFile 条目。

直接更新不起作用。更重要的是,应用程序没有重新连接,我得到一个灰屏(可能是因为 iOS 试图使用错误的文件启动)。

例如:

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

上述方法无效。

[稍后编辑以添加我的 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>

所以,需要明确的是,如果我遇到的问题是我的 mainFile 是项目名称以外的名称。 Worklight 并不总是调用 mainfile 指定的文件名,尤其是在初次使用应用程序之后。

【问题讨论】:

    标签: ibm-mobilefirst worklight-studio


    【解决方案1】:

    如果更改 HTML 文件名,请确保也更改:

    1. application folder 名称
    2. 在 application-descriptor.xml 中:

      • application 元素中的id 属性
      • mainFile元素值

    所有都应该相互匹配。

    确保删除本机文件夹并重新构建项目。 应用程序将在第一次后继续加载,直接更新将继续运行。

    【讨论】:

    • 感谢您回复@Idan Adar。我彻底检查了一遍。在您提到的任何其他文件(主 CSS 文件、主 JavaScript 文件)中,我没有对我的主 HTML 文件的引用。我确实在 application-descriptor.xml、文件名本身(显然)和 worklight.plist(对于 iOS)中的各个位置更改了文件名。
    • 在worklight.plist中改没意义,文件内容是在build时生成的,所以需要关注其他文件。我的意思是你想把我提到的所有东西都改成同一个名字。使用您的 application-descriptor.xml 编辑您的问题。
    • 确保在更改文件名和引用后重新构建项目。并使用更新后生成的 Xcode 项目在您的设备上运行。
    • 谢谢伊丹。是的,我肯定会在进行更改后重建项目。这包括验证 worklight.plist 是否已更新。问题是除非 mainFile 与项目相同,否则应用程序无法可靠运行。
    • 似乎我确实错过了更改应用程序文件夹重命名部分(不是项目文件夹)。请看我修改后的答案。
    【解决方案2】:

    我找到的唯一解决方案是将我的主文件命名为与项目中的应用程序相同的名称。当我这样做时,我的应用程序运行良好。

    [请注意,这已被编辑以符合上述@Idan Adar 的建议。必须匹配mainFile的不是PROJECT,而是APPLICATION名称]

    以下工作正常:

    Project name: MyProject
    main file: MyProject.html
    application-descriptor.xml: <mainFile>MyProject.html</mainFile>
    worklight.plist: <wlMainFile>MyProject.html</wlMainFile> (this is a generated file)
    

    Worklight 似乎第一次使用 wlMainFile 中指定的文件正确启动了 iOS 应用程序。然后当它必须恢复或重新启动时,它会查找应用程序名称而不是 wlMainFile 中指定的值。

    【讨论】:

    • 发生这种情况是因为您没有在需要的地方完全更改它。看我的回答。
    • 我确实在您需要的所有地方完全更改了文件名。有趣的是,在初始应用程序启动时,wlMainFile 中提到的 HTML 文件和 application-descriptor.xml 被使用。在 iOS 应用程序重新启动时,与项目同名的 HTML 文件就是被调用的文件。请考虑删除 -1 否决票。至少我的答案是一个解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多