Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 version on PhoneGap Build #10

Open
brodycj opened this issue Nov 1, 2016 · 17 comments
Open

Windows 10 version on PhoneGap Build #10

brodycj opened this issue Nov 1, 2016 · 17 comments

Comments

@brodycj
Copy link
Owner

brodycj commented Nov 1, 2016

Similar to storesafe/cordova-sqlite-evcore-extbuild-free#1: if I build a test project (https://github.com/brodybits/Cordova-sqlite-legacy-PGB-W10-x86-test-app) with this plugin for Windows 10 UWP on PhoneGap Build I get the following in the log and then the test app crashes on startup:

Build Date: 2016-11-01 17:00:08 +0000
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-dialogs@~1.3.0" via npm
Installing "cordova-plugin-dialogs" at "1.3.0" for windows
Fetching plugin "https://github.com/litehelpers/Cordova-sqlite-legacy-build-support" via git clone
Using shallow clone
Repository "https://github.com/litehelpers/Cordova-sqlite-legacy-build-support" checked out to git ref "master" at "9d28834".
Installing "cordova-sqlite-legacy-build-support" at "1.3.4" for windows
Building project: C:\cygwin\tmp\gimlet\2334122\project\CordovaApp.Windows10.jsproj
	Configuration : debug
	Platform      : x86
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1610,5): warning : The referenced project '..\..\cordova\plugins\cordova-sqlite-legacy-build-support\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\SQLite3.UWP.vcxproj' does not exist. [C:\cygwin\tmp\gimlet\2334122\project\CordovaApp.Windows10.jsproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(4330,5): warning MSB3202: The project file "..\..\cordova\plugins\cordova-sqlite-legacy-build-support\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\SQLite3.UWP.vcxproj" was not found. [C:\cygwin\tmp\gimlet\2334122\project\CordovaApp.Windows10.jsproj]
  CordovaApp.Windows10 -> C:\cygwin\tmp\gimlet\2334122\project\AppPackages\CordovaApp.Windows10_0.0.1.0_x86_debug_Test\CordovaApp.Windows10_0.0.1.0_x86_debug.appx

I will submit this issue to https://github.com/phonegap/build for investigation.

@brodycj
Copy link
Owner Author

brodycj commented Nov 22, 2016

In response to https://forums.adobe.com/message/9123283 @vladimir-kotikov gave an excellent recommendation to use prebuilt SQLite3.winmd files in a similar fashion as phonegap / phonegap-plugin-barcodescanner (plugin.xml#L65-L67).

I tried building the SQLite3 libraries then using the following lines in the Cordova-sqlite-evcore-extbuild-free version (for Windows 10 UWP only):

      <framework src="src/deps/windows/release/x86/SQLite3.winmd" target-dir="x86" arch="x86" custom="true" versions="10.*" />
      <framework src="src/deps/windows/release/x64/SQLite3.winmd" target-dir="x64" arch="x64" custom="true" versions="10.*" />
      <framework src="src/deps/windows/release/arm/SQLite3.winmd" target-dir="ARM" arch="ARM" custom="true" versions="10.*" />

then I would get a build warning like this:

warning APPX1707: No implementation file was provided for the .winmd file 'C:\Users\Chris\Documents\git\akk\platforms\windows\plugins\cordova-sqlite-evcore-extbuild-free\x86\SQLite3.winmd'. To generate registration information in the app manifest, specify the 'Implementation' metadata on the .winmd reference item in the project file.

I found the following links:

If I try including the DLLs like this:

      <source-file src="src/deps/windows/release/x86/SQLite3.UWP.dll" target-dir="x86" />
      <source-file src="src/deps/windows/release/arm/SQLite3.UWP.dll" target-dir="ARM" />
      <source-file src="src/deps/windows/release/x64/SQLite3.UWP.dll" target-dir="x64" />

the warning would not go away.

I tried using lib-file entries but they did not seem to help at all.

Looking at the answer at http://stackoverflow.com/a/23435054/1283667 I tried applying the following changes by hand:

--- platforms\windows\CordovaApp.Windows10.jsproj.orig	Tue Nov 22 20:51:15 2016
+++ platforms\windows\CordovaApp.Windows10.jsproj	Tue Nov 22 20:51:27 2016
@@ -90,6 +90,7 @@
         <Reference Condition="'$(Platform)'=='x86'" Include="SQLite3">
             <HintPath>plugins\cordova-sqlite-evcore-extbuild-free\x86\SQLite3.winmd</HintPath>
             <IsWinMDFile>true</IsWinMDFile>
+            <Implementation>SQLite3.UWP.dll</Implementation>
         </Reference>
     </ItemGroup>
     <ItemGroup>

The build warning went away but it still would not work. I would get the following exception in the debug console output:

0x8007007e - JavaScript runtime error: The specified module could not be found.

Reaching out to @vladimir-kotikov for any further suggestions?

@vladimir-kotikov
Copy link

vladimir-kotikov commented Nov 24, 2016

@brodybits, sorry but I must admit I'm out of ideas, how this can be done without hooks. Also none of <resource-file>, <lib-file> or <source-file> tags is sufficient to properly include references to dll files to jsproj file (actually <resource-file> could help, but it doesn't copy files to platform's directory making them unaccessible at build time in Phonegap build - same as with frameworks). I guess to make it work properly we'd need to add support for winmd+dll into cordova-windows first.

@brodycj
Copy link
Owner Author

brodycj commented Nov 25, 2016

Thanks @vladimir-kotikov. When do you think it would be possible to add winmd+dll support to cordova-windows? Can someone from Microsoft or cordova-windows work on this or do I have to do this myself? Should I raise a Cordova issue for this?

@brodycj
Copy link
Owner Author

brodycj commented Nov 28, 2016

I just raised https://issues.apache.org/jira/browse/CB-12189 with a request to add WinMD+DLL support. Can someone from cordova-windows or Microsoft help or will I have to do this myself?

@vladimir-kotikov
Copy link

Acknowledged, thanks, Chris. I can't promise anything about timeline, but hope we can find some spare time in the near future.

@brodycj
Copy link
Owner Author

brodycj commented Nov 29, 2016

Thanks @vladimir-kotikov for whatever you can do. I already told my customer that this would be very difficult. Please let me know if there is anything I can do to help. No rush on my part.

/cc @mbraude

@vladimir-kotikov
Copy link

@brodybits, we've added support of implementation attribute for <framework> element in plugin.xml and will be sending corresponding PRs to cordova-windows, cordova-lib and docs soon. As of now you can try it out by cloning https://github.com/vladimir-kotikov/Cordova-sqlite-legacy-PGB-W10-x86-test-app/tree/patch-1 and running cordova prepare - platforms and plugins are saved in config.xml to be installed from respective repos and branches.

@vladimir-kotikov
Copy link

Ok, the PR has been published

@brodycj
Copy link
Owner Author

brodycj commented Dec 21, 2016

Ok, the PR has been published

apache/cordova-windows#219

along with:

@vladimir-kotikov thank you very much. I also saw your comments in CB-12189. I will try this within the next few days and keep you posted.

@brodycj
Copy link
Owner Author

brodycj commented Dec 21, 2016

I tried doing cordova prepare on the patch-1 branch then opening it in Visual Studio 2015. When tried running on x86 I got the following output and could not access the sqlite functionality:

'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/3.0)'. 
Exception was thrown at line 126, column 7 in ms-appx-web://com.brodybits.testapp/www/plugins/cordova-sqlite-storage/src/windows/SQLite3-Win-RT/SQLite3JS/js/SQLite3.js
0x8007007e - JavaScript runtime error: The specified module could not be found.
Exception was thrown at line 19, column 5 in ms-appx-web://com.brodybits.testapp/www/plugins/cordova-sqlite-storage/src/windows/SQLite3-Win-RT/SQLite3JS/js/SQLite3.js
0x800a139e - JavaScript runtime error: Error creating an SQLite database connection.

I suspect you guys would have tested the solution so I wonder if I did something wrong here. I am thinking to try this with a very simple C++ DLL project as well. Do you think I missed something?

A couple more things:

The plugin would probably depend on cordova-windows 4.5.0 or later. Would this imply that we should target Visual Studio 2017?

To get this to work on PhoneGap Build we would have to get the new version of cordova-windows integrated by PGB and then be sure we get the Visual Studio version to match. I suspect we would want to target Visual Studio 2017 but would like to see this coordinated with the PGB folks.

@vladimir-kotikov
Copy link

vladimir-kotikov commented Dec 22, 2016

Yeah, I've tested this in VS 2017 and Nikita has just checked if project builds with VS 2015 - everything works fine. Could you please confirm if :

  1. winmd and dll files are exist in platforms\windows\plugins\cordova-sqlite-storage\{ARM|x86|x64}

  2. CordovaApp.Windows10.jsproj contains references to winmd files with <Implementation> section added

  3. CordovaApp.Windows10.jsproj contains an SDK reference to VCLibs 14.0 (this is essential) and the reference is valid when project is opened in VS (there should be no yellow exclamation mark near it in Solution Explorer, see below)

    image

Also, please notice that the version of the plugin I pushed to my fork doesn't have binaries for windows 8.1, so it will work only when built for Windows 10

As for dependency on VS 2017 - technically the plugin will not require any specific version of VS since the binaries are already built. If anyone would want to rebuild binaries itself, then he/she would need to install a specific version of VS (or have VS Build tools installed separately)

@brodycj
Copy link
Owner Author

brodycj commented Dec 22, 2016

I forgot to mention that last time I only tried Release build. If I would try Debug builds it works with the following exception:

Following the link to page 2 or changing location to page 2 gives me a crash with the following JavaScript runtime error: 'WinJS' is undefined (if I click the button to do location.reload() it is OK)

The Release builds do not work for me. I took a quick look at https://github.com/vladimir-kotikov/Cordova-sqlite-legacy-PGB-W10-x86-test-app/commit/da713d911f96db43fed341bf3739b8f61dadd52f and matrosov-nikita/cordova-windows@99a7016 but could not directly see the cause of this problem.

@vladimir-kotikov
Copy link

My bad - it appeared that I uploaded debug libararies instead of release versions. I updated my fork (vladimir-kotikov/Cordova-sqlite-storage@4f6e588) w/ release versions - now everything should work in bot release and debug configuration. As for WinJS is undefined - I suspect this is caused by some changes, related to SplashScreen in Windows and has been already fixed in one of latest commits (apache/cordova-windows@707bf96). I rebased cordova-windows branch on top of latest master and don't see this error anymore.

@brodybits, could you give it a shot once more

@brodycj
Copy link
Owner Author

brodycj commented Dec 23, 2016

Hi @vladimir-kotikov it now works OK in both Debug and Release builds on desktop (x86 & x64) and mobile (ARM). I am now looking forward to seeing this fix released in cordova-windows (4.5) and then included by the PhoneGap Build system.

@fernandocode
Copy link

Hi, I'm having this problem in IonicFramework2 run windows 10 platform.

Anyone know if this is already fixed in Cordova?

What extra configuration was implemented in Solution in Visual Studio to be possible to build for UWP from Visual Studio 2015?

My project (generated by Ionic build) in Visual Studio is not recognizing SQLite3.UWP.vcxproj in dependencies. From what I saw you added a DLL in place of that reference. What DLL? And the DLL was added in the build Ionic or later in VisualStudio?

Solution Explorer:

cordovawindows

@brodycj
Copy link
Owner Author

brodycj commented Jan 17, 2017

@fernandocode that looks like a different issue and may be a problem with your setup. Please try again with a fresh, clean project and raise a new issue if it is still a problem for you.

@brodycj
Copy link
Owner Author

brodycj commented Jan 29, 2017

So the fix in apache/cordova-windows#219 (Apache CB-12189) is now included in cordova-windows 5.0.0, looking forward to seeing this included by Cordova CLI, PhoneGap CLI, and PhoneGap Build. Maybe in Visual Studio TACO, someday. Thanks @matrosov-nikita @vladimir-kotikov @mbraude for your efforts.

UPDATE: asked in https://forums.adobe.com/thread/2271279 when cordova-windows 5.0.0 with WinMD+DLL support can be included by PhoneGap Build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants