简体   繁体   English

将Sencha Touch应用程序从iOS迁移到Android和Windows

[英]Migrate Sencha Touch app from iOS to Android and Windows

I am a hardcore Android developer new to Sencha Touch, Windows app development and VisualStudio environments. 我是Sencha Touch,Windows应用程序开发和VisualStudio环境的新手,是一名铁杆Android开发人员。 So please bear with the lengthy description of the problem, just did not want to miss any crucial detail. 因此,请耐心地对问题进行冗长的描述,只是不想错过任何关键细节。

I have received an old Sencha Touch 2.1 (Cmd 3.0) based app that has been running on ipad (iOS), developed by someone from Kepler-452b. 我收到了一个旧的基于Sencha Touch 2.1 (Cmd 3.0)的应用程序,该应用程序已在由Kepler-452b开发的ipad(iOS)上运行。 I recently ported the app to Android by copying the project contents to an android cordova project (www folder) and is working without a problem on a Nexus 10 tablet. 我最近通过将项目内容复制到android cordova项目(www文件夹)将应用程序移植到Android,并且在Nexus 10平板电脑上可以正常使用。 I started facing issues while trying to migrate this for Windows using VisualStudio 2013. 在尝试使用VisualStudio 2013将其迁移到Windows时,我开始遇到问题。

The intention is to create a Windows Store app out of the existing code that can run on a Win 8/8.1 PC or a HP Omni 10 tablet. 目的是利用可在Win 8 / 8.1 PC或HP Omni 10平板电脑上运行的现有代码创建Windows Store应用程序。

Steps followed: 遵循的步骤:

  1. Create sample sencha app 创建示例sencha应用

     >sencha generate app sample ../sample 
  2. Initialize cordova 初始化科尔多瓦

    >sencha cordova init

  3. Update app.json to add windows platform 更新app.json以添加Windows平台

    "platforms": "windows" “平台”:“窗口”

  4. Build for native packaging 为本地包装打造

    >sencha app build native

  5. Import the solution 'CordovaApp.sln' generated at \\cordova\\platforms\\windows to VS2013 将在\\ cordova \\ platforms \\ windows中生成的解决方案'CordovaApp.sln'导入到VS2013

  6. Run the project CordovaApp.Windows80 inside VS and it slaps a "Unable to add dynamic content" exception due to the Windows CSP 在VS中运行项目CordovaApp.Windows80,由于Windows CSP,它会抛出“无法添加动态内容”异常

  7. Wrap the calls to "document.write" with MSApp.execUnsafeLocalFunction() in the minified microloader script inside index.html and run again. 将MSApp.execUnsafeLocalFunction()的调用包装在index.html中缩小的microloader脚本中,然后再次运行。 This successfully launches the sample sencha touch app as a store app (the icons in the tab bar for 'Home' and 'Get Started' tabs are replaced with a 'H' and 'R' though). 这将成功启动示例sencha touch应用程序作为商店应用程序(“主页”和“入门”选项卡的选项卡栏中的图标替换为“ H”和“ R”)。 Both IE and chrome browsers render the app beautifully with the icons IE和chrome浏览器均使用图标精美呈现应用程序

  8. In Windows explorer, delete the contents of the \\cordova\\platforms\\windows\\www folder except the cordova.js and cordova_plugins.js 在Windows资源管理器中,删除\\ cordova \\ platforms \\ windows \\ www文件夹中除cordova.js和cordova_plugins.js之外的内容

  9. Copy the contents of my old sencha project to the www folder, build and launch the app inside VS. 将我的旧sencha项目的内容复制到www文件夹,在VS中构建并启动该应用程序。 "Unable to add dynamic content" again! 再次“无法添加动态内容”!

  10. Inside /www/touch/microloader/development.js, update "function write(content)" to wrap the document.write with MSApp.execUnsafeLocalFunction() and run; 在/www/touch/microloader/development.js内部,更新“函数write(content)”以使用MSApp.execUnsafeLocalFunction()包装document.write并运行; another exception pops up: "document.body does not exist at this point" - google suggested that this could be due to an old framework version 弹出另一个异常:“此时尚不存在document.body”-谷歌建议这可能是由于旧框架版本引起的

  11. Replace the old 2.1 "touch" folder inside the project with the new 2.4.0 "touch" folder from my sencha workspace and run again 用我的sencha工作区中的新2.4.0“ touch”文件夹替换项目中的旧2.1“ touch”文件夹,然后再次运行

Now there are no errors in the console, but the app only shows a white screen after the cordova splashscreen. 现在,控制台中没有错误,但是该应用程序仅在cordova初始屏幕之后显示白色屏幕。 If I replace contents of my Main.js with that from the sample sencha application, the screen is still white! 如果我用示例sencha应用程序中的内容替换Main.js的内容,屏幕仍然是白色的! By adding a 'initialize' event listener, I confirm that the view is being loaded 通过添加“初始化”事件侦听器,我确认该视图正在加载

I am using Sencha Cmd 6.0.0 and touch-2.4.0 我正在使用Sencha Cmd 6.0.0和touch-2.4.0

I ve been stuck with this for more than a week now to no avail. 我已经为此坚持了一个多星期,但无济于事。 Had a look in stackoverflow here , but the instructions are for Ext JS and not Sencha Touch. 这里查看了stackoverflow,但说明是针对Ext JS而非Sencha Touch的。 No idea how the OP fixed the issues. 不知道OP如何解决问题。

I am not sure if this is even the correct approach to migrate an old sencha touch app to a windows store app. 我不确定这是否是将旧的sencha touch应用迁移到Windows应用商店的正确方法。

Any help would be much appreciated. 任何帮助将非常感激。

First, I'd revert your workarounds and simply add the Windows Store Dynamic Content Shim library to your project. 首先,我将恢复您的解决方法,只需将Windows Store动态内容Shim库添加到您的项目中。 It is specifically designed to improve compatibility of web frameworks with Windows apps and resolve the problems you are encountering. 它专门用于提高Web框架与Windows应用程序的兼容性并解决您遇到的问题。 It will only activate on Windows so it won't add overhead if you're running on Android or iOS. 它只会在Windows上激活,因此如果您在Android或iOS上运行,它不会增加开销。 I'd start there as it might resolve most if not all of your problems - more than likely one of your updates above is causing the problem or there's another one that just isn't causing an error. 我从这里开始,因为它可能会解决大多数(如果不是全部)问题,很可能是上述更新之一导致了该问题,或者还有一个更新没有引起错误。

You should also verify all of the underlying Cordova plugins you are using support Windows as that could be causing a JavaScript exception that is before rendering occurs given how Sencha works. 您还应该验证您正在使用的所有支持Windows的基础Cordova插件,因为这可能会导致JavaScript异常,并且在Sencha正常工作的情况下,渲染之前会发生JavaScript异常。

Finally, note that Cordova plugin code is not platform agnostic - so you cannot safely just copy the contents of an Android project to another platform. 最后,请注意,Cordova插件代码与平台无关,因此您不能安全地将Android项目的内容复制到另一个平台。 (Android to iOS, iOS to Windows, or whatever.) It sounds like the steps you took should have worked, but be aware that you can't copy plugin code itself from one native project type to another. (Android到iOS,iOS到Windows,或其他。)听起来您应该采取的步骤应该起作用,但是请注意,您无法将插件代码本身从一种本机项目类型复制到另一种本机项目类型。 The Cordova Command Line Interface that most of these tools use will automatically add the native and web plugin correct code to your project based on the platform you are building. 这些工具大多数使用的Cordova命令行界面将根据您正在构建的平台,将本机和Web插件正确的代码自动添加到您的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM