1

I am a hardcore Android developer new to Sencha Touch, Windows app development and VisualStudio environments. 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. 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. I started facing issues while trying to migrate this for Windows using VisualStudio 2013.

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.

Steps followed:

  1. Create sample sencha app

    >sencha generate app sample ../sample
    
  2. Initialize cordova

    >sencha cordova init

  3. Update app.json to add windows platform

    "platforms": "windows"

  4. Build for native packaging

    >sencha app build native

  5. Import the solution 'CordovaApp.sln' generated at \cordova\platforms\windows to VS2013

  6. Run the project CordovaApp.Windows80 inside VS and it slaps a "Unable to add dynamic content" exception due to the Windows CSP

  7. Wrap the calls to "document.write" with MSApp.execUnsafeLocalFunction() in the minified microloader script inside index.html and run again. 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). Both IE and chrome browsers render the app beautifully with the icons

  8. In Windows explorer, delete the contents of the \cordova\platforms\windows\www folder except the cordova.js and cordova_plugins.js

  9. Copy the contents of my old sencha project to the www folder, build and launch the app inside 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; another exception pops up: "document.body does not exist at this point" - google suggested that this could be due to an old framework version

  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

Now there are no errors in the console, but the app only shows a white screen after the cordova splashscreen. If I replace contents of my Main.js with that from the sample sencha application, the screen is still white! 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

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. No idea how the OP fixed the issues.

I am not sure if this is even the correct approach to migrate an old sencha touch app to a windows store app.

Any help would be much appreciated.

Community
  • 1
  • 1
Ashok
  • 435
  • 1
  • 4
  • 16

1 Answers1

2

First, I'd revert your workarounds and simply add the Windows Store Dynamic Content Shim library to your project. It is specifically designed to improve compatibility of web frameworks with Windows apps and resolve the problems you are encountering. It will only activate on Windows so it won't add overhead if you're running on Android or 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.

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. (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. 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.

Chuck Lantz
  • 1,440
  • 1
  • 8
  • 10
  • Thanks a lot for the pointers. I created a new Windows Store JS project in VS and replaced the default contents with that from the sencha project. Added the dynamic content shim and referenced the _winstore-jscompat.js_ in the `` before any other scripts and still received the same error for `document.write` in _development.js_. Wrapping it with `MSApp.exec..`, the error disappeared but the app layout and styling went up for a toss. Two questions at this point: **1. Why the error even after referencing the shim? Am I doing it right?** **2. The shim also fix CSS issues?** – Ashok Jul 30 '15 at 08:52
  • Just noticed that the new js project is rendered fine in Chrome but not in IE. Does IE11 not support webkit prefixed css? I should also mention that there are no cordova plugins involved in the project so far. – Ashok Jul 30 '15 at 09:02
  • @Ashok No, all browsers have own CSS vendor prefixes. Here are some links: http://webdesign.about.com/od/css/a/css-vendor-prefixes.htm and https://css-tricks.com/how-to-deal-with-vendor-prefixes/ – Baidaly Jul 30 '15 at 12:01
  • @Ashok 1. By looking at the source code of that shim, it doesn't look that it does anything with document write. So, I'd keep it wrapped in development.js. 2. No, that shim doesn't fix CSS rendering differences between – Baidaly Jul 30 '15 at 12:11
  • @Baidaly Thanks for the clarifications. So if the original sencha project is generating -webkit- prefixed css, there is no way we can get those working in windows 8? Any help from Sencha side? – Ashok Jul 30 '15 at 12:44
  • @Ashok So, usually all vendor-specific prefixes have counterparts in other browsers. Sencha has added support of Windows 8 in one of the latest versions, so I would recommend to upgrade the latest version of Touch. – Baidaly Jul 31 '15 at 12:35
  • @Baidaly Many thanks for the suggestions, I have already updated the original ST 2.1.1 project to ST 2.4.0 but that did not help. Currently trying to use Compass to generate css from sass file in a hope that it would generate non-webkit css equivalent to the '-webkit-' counterparts. Any further pointers would be greatly appreciated. – Ashok Aug 17 '15 at 10:31
  • I have a similar problem with the implementation in W8, thing is : "resource not found".. what is the problem in this case, under IOS is working properly.. thanks! – inane Feb 25 '16 at 08:34