2013-06-21 27 views
1

我希望我的主要html文件具有與我的項目不同的名稱。IBM Worklight 5.0.x - 更改主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> 

上面不起作用。

[編輯後加入我的應用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>[email protected]</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指定的文件名,特別是在初次使用應用程序之後。

回答

3

如果更改HTML文件名,請務必同時修改:

  1. application folder
  2. 在應用descriptor.xml:

    • id屬性在application元素
    • mainFile元素值

所有應該匹配對方。

確保刪除本機文件夾並重新構建項目。 應用程序將在第一次後繼續加載,直接更新將繼續運行。

+0

感謝您回覆@Idan Adar。我徹底仔細檢查。我沒有提到你提到的其他任何文件(主CSS文件,主JavaScript文件)中的主HTML文件。我改變了application-descriptor.xml中各個地方的文件名,文件名本身(顯然)以及worklight.plist(iOS版)。 – user2217751

+0

在worklight.plist中改變它沒有意義,文件的內容是在編譯時生成的,所以需要關注其他文件。我的意思是,你想改變我提到的所有相同的名稱。用你的application-descriptor.xml編輯你的問題。 –

+0

確保在更改文件名和引用之後重新構建項目。並使用更新後生成的Xcode項目在您的設備上運行。 –

1

我發現的唯一解決方案是將我的主文件命名爲與項目中的應用程序相同的名稱。當我這樣做時,我的應用程序運行良好。

[請注意,這已被編輯以匹配@Idan Adar上面的建議。這並不是說必須mainFile匹配的項目,但應用程序的名稱]

下正常工作:

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) 

看來,工作燈使用wlMainFile指定的文件正確啓動的iOS應用程序的第一次。然後,當它恢復或重新啓動時,它將查找應用程序名稱,而不是在wlMainFile中指定的值。

+0

發生這種情況是因爲您沒有在需要時完全更改它。看到我的答案。 –

+0

我完全改變了你所需要的所有地方的文件名。有趣的是,在初始應用程序啓動時,將使用wlMainFile和application-descriptor.xml中提到的HTML文件。重新啓動iOS應用程序時,與項目名稱相同的HTML文件就是被調用的文件。請考慮刪除-1的投票。至少我的答案是一個解決方案。 – user2217751

相關問題