0

Can we use ninja to build UWP apps and hence create the appx package for the same? I don't feel there is an online article for the same. I know how to do it using VS and Make.

  • You can try to set up a CMake project for a UWP app and use the Ninja generator (`-GNinja`). That generates the input files for Ninja, in case you want to play around with that. – IInspectable Sep 16 '18 at 21:29

2 Answers2

0

In theory: Yes

Notable one thing: Ninja just official support C++, I can't find any result Ninja support other programming languages

With C++ we have 2 options:

  • C++/CX: You should activate flag /ZW for Windows Metadata
  • C++/WinRT: With WinRT you just compile without any restrict, this doesn't need Windows Metadata anymore

C++/CX: we have long story behind Windows Runtime development before C++ 11/14 became official so Microsoft add their own implementation features to MSVC. So with C++/CX you can compile with very old SDK like 10240, 10586, ... and in theory it also work with Windows 8.0/8.1 SDK, Windows Phone 8.0/8.1 SDK. Another attemp try to compile UWP with C++/CX on FastBuild (system build like Ninja) is successful, you can read as a reference here: https://github.com/fastbuild/fastbuild/issues/623

C++/WinRT is reunion attempt make Windows Runtime back to standard C++ 17. C++/WinRT can also compile with Clang/GCC. Base on answer from Kenny Kerr (creator of C++/WinRT): C++/WinRT is not limit with old SDK, but he recommended to use newer SDK like 17134. Link his answer https://stackoverflow.com/a/53193711/8707331.

Some useful links for C++ UWP:

https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/porting/how-to-use-existing-cpp-code-in-a-universal-windows-platform-app.md

https://modernwindows.wordpress.com/2015/05/28/modern-c-and-clang/

Khoi V
  • 612
  • 8
  • 13
-1

you can create uwp apps in following ways:

  1. c# and xaml

  2. web technologies like html, css and js. and you can use any third party js libraries with it. you can even use hosted web apps as uwp apps or latest technologies like pwas can also be shipped as uwp apps. more here : https://developer.microsoft.com/en-us/windows/pwa

  3. c++ and xaml : with this approach you can use c++ libraries (if they comply by uwp platform) the reason you do not have much support online for this is because majority of uwp developers use c# and xaml approach.

There are some work around for that, and one of them is to create a Desktop app and then package that in MSIX packaging , which packages a windows Desktop app into a uwp app and you can even distribute it through Microsoft store.

CMake can't be used to generate UWP package. However, you could use make.exe or Visual Studio to generate UWP package. For more you could refer to Create an app package with the MakeAppx.exe tool and Package a UWP app with Visual Studio.

Muhammad Touseef
  • 4,357
  • 4
  • 31
  • 75
  • Wildly misleading. You can (probably even should) build UWP apps using C++. Since [Ninja](https://ninja-build.org/) (and CMake) are targeted for building native applications, this is quite significant, and this proposed answer doesn't acknowledge any of that. – IInspectable Sep 16 '18 at 10:20
  • This is still incorrect. You can write UWP apps with C++, without using XAML. And you **cannot** use *"any c++ library"* either. Libraries you use still need to meet the requirements imposed by UWP or the Microsoft Store. And it still fails to address, whether Ninja can be used as a build system to produce UWP apps, and if so, how to do it. Given the limited support for UWP provided by CMake, it's unlikely for Ninja do it, without *significant* customization. – IInspectable Sep 16 '18 at 20:46
  • thankyou for the correction I have again edited my question. – Muhammad Touseef Sep 16 '18 at 20:56
  • That's still failing to address the question. Ninja is a build system, like MSBuild, which you are using (knowingly or otherwise) to transform code and assets into deployable packages. MSBuild parses *.sln and *.csproj files to configure the environment to drive the build pipeline. Ninja takes the same responsibilities, in a native setting. The question isn't asking, whether you can write native UWP apps (yes, you can, and you should!), but whether it is possible to use Ninja to set up the build process, and if so, how. – IInspectable Sep 16 '18 at 21:25
  • When [copying another answer verbatim](https://stackoverflow.com/a/46522335/1889329), it is customary (even required) to provide attribution. Since the statement is provably untrue (you can execute *any* command in CMake using [add_custom_command](https://cmake.org/cmake/help/latest/command/add_custom_command.html)) you can then at least point fingers at others. You appear to be struggling to provide an answer requiring familiarity with tools and systems you do not know nor understand. Sometimes it's best to just let go. – IInspectable Sep 17 '18 at 23:03