Ionic app for Windows 8.1, Windows 10 and Windows Phone
If you like me have bumped into crazy issues like the ones mentioned below when attempting to build an Ionic app for Windows 8.1/ 10 and Windows Phone, then the following tips will definitely help you.
Adding the windows platform
ionic platform add windows
Note: ionic platform add wp8 is deprecated, but you can test this on windows 8.0 at your own risk.
Inside the platform/windows folder you will see a solution named CordovaApp. Open this and you will see three projects
- CordovaApp.Phone
- CordovaApp.Windows
- CordovaApp.Windows10
You can either choose to open the main solution containing all the three projects i.e CordovaApp or open each individually for a particular platform.
Note: I have used Visual Studio Community Edition 2015 and tested on both Windows 8.1 and Windows 10.
Now the interesting bit. When you build the project, you will see any or all of the below mentioned issues
1) A broken reference to Win JS "Could not find SDK Win JS 2.x...."
Under the references in the project if you find a broken link to this library, do the following to fix this error
- If your SDK is all setup and fully updated, then go to references and add it.
- If the SDK is not updated, then right click the project, click 'Manage NuGet Packages..", browse for WinJS and install it to all the projects. Once done, you should be able to see a WinJS folder in the project. Go to index.html and add the links to winjs/css/ui-light.css, winjs/js/base.js and winjs/js/ui.js.
- The best and the easiest is to install the Windows 8.1 SDK. You might have installed it, but don't trust it ;-). Install again. A lot of developers suggest tweaking the registry settings etc..just forget it. Install the SDK again and restart the machine. Re-open the project. This time, you rreference should be automatically fixed.
Note: WinJS is not needed as reference for Windows 10. It should be available by default.
2) Depending on your build you will see an error like this "10.0.10240.0 is not a supported value for TargetPlatformVersion"
- Again a lot of suggestions to edit the AppX Manifest Source File or the JavasScript app project file etc.. just forget it. Install the SDK, reinstall the SDK and restart the machine. Make sure you install Windows SDK 8.1 for 8.1 and Windows SDK 10 for 10. Simple as that.
3) Windows.props not found
- Again an issue with the SDK. Install the SDK for it to find the file.
4) "Unable to add dynamic content"
- This is a permission or a security issue. To solve this include the below mentioned ionic plugin
- https://github.com/vjrantal/cordova-plugin-winstore-jscompat
- It works, but do this first in your main project and then execute ionic add platform windows. If you already have the windows platform, delete it and add platform again.
5) Some other exceptions
- Some plugins won't work on windows. For instance I had issue with the nativepagetransitions plugin and had to comment out all of the its references.
6) DEP0600 - The following error occurred during deployment
- Just search for "how to register your phone for windows development" in Google.
Enjoy! And yes! Ionic is pretty damn awesome!!!
Comments