Cross-Platform Mobile Development with Visual C++

November 12th, 2014

Overview

Modern application customers are demanding applications be available for multiple device platforms (such as Windows, Android and iOS). Today there exist multiple approaches in writing applications which target these device platforms. One approach is to simply create multiple versions of the application in different source trees-in other words a Windows specific version, an iOS specific version and an Android specific version of the application programmed to the native technologies available on the platform. While this is a simple straight forward approach it amounts to considerably more expensive development cost and time. C++ is unique as it provides the ability to write efficient, fast and feature rich cross-platform mobile code once which can then be shared across these different device platforms.

Visual Studio 2015 Preview (download here) introduces support for developers to be able to build cross-platform mobile native (C/C++) binaries targeting Windows platforms (through the Visual C++ toolchain C1xx/C2) and the Android platform (through Clang/LLVM toolchain). Using this experience, developers will be able to share their cross-platform mobile code easily while making use of advanced development features like cross-platform Intellisense, refactoring, cross-platform debugging and more driving developer productivity.

The Android Platform with API Level 3 introduced the Native Development Kit (NDK) which enables creation and consumption of libraries written in C/C++. Using Visual Studio 2015 preview, developers will be able to:

Easily build dynamic shared libraries and static libraries which encapsulate all the native (C/C++) code for the application. These libraries can then be used as part of other Android applications (.apk’s) using technologies like Xamarin and Java . We have been working with Xamarin to enable a smooth experience in Visual Studio when building Xamarin Android applications leveraging C/C++ code.



and which encapsulate all the native (C/C++) code for the application. These libraries can then be used as part of other Android applications (.apk’s) using technologies like and . We have been working with to enable a smooth experience in Visual Studio when building Android applications leveraging C/C++ code. Create Android Native-Activity applications, Native-Activity debug and deploy native-activity android applications to emulators and devices alike.



applications, debug and deploy native-activity android applications to emulators and devices alike. Quickly Iterate over the edit-build-debug cycle by making use of the fast x86 based Android emulators for deployment and targeted application testing utilizing the simulated sensors (like Zoom, Orientation, Accelerometer, Power and others). For more information please refer to this blog-post here.



Getting Started

In order to get started with doing cross-platform mobile development with Visual C++ download Visual Studio 2015 Preview (download here). On running the installer please choose the following installation option (‘Visual C++ for cross-platform mobile development’) as shown in the figure 1. below.



Fig1: Choose Visual C++ for Cross-Platform Mobile Option Fig 2: Choose ‘Restart and Install’ option Fig 3: Choose required additional software

Once this primary installation is complete, cross-platform mobile development users are provided with an additional install of third party software as part of the secondary installer shown in figure 2. (Choose ‘Restart and Install’ option). Once the secondary installer comes up after a system restart, make sure the following entities are all (Android SDK, Android NDK, Apache Ant, Oracle Java SDK and Microsoft Visual Studio Emulator for Android) selected as shown in Figure 3 and follow through the rest of the installation process.



Cross-Platform Mobile Templates

Once a successful installation is complete. As a part of the File->New->Visual C++ ->Cross Platform node you should see a collection of templates being introduced (as shown in figure 4 below).



Fig 4: New templates introduced under Visual C++ -> Cross Platform node

The templates decorated with the (Android) specific keywords such as the ‘Dynamic Shared Library (Android)’ template allows developers to create binaries specifically for the Android Platform where as templates decorated with (Cross Platform) keyword will allow developers to currently create binaries targeting both the Windows and Android platform respectively. The Cross Platform template will also highlight Visual C++’s ability to share and author code across these platforms easily. Please look forward to specific blogs talking about these templates in more detail which we will be posting soon.

Wrap up

This blog should give you an overview about the work we have done in VS2015 preview introducing Visual C++ Cross-Platform mobile development. We will follow up this blog post with additional posts diving deeper into key features. This is a preview release and as with any preview release, the goal for us is to collect feedback and learn from you. We are considering future support for other platforms too and your feedback is critical in shaping the direction of our product.



Sharing feedback is easy! Make feature suggestions on UserVoice, log bugs you find on our Connect site and send us a smile or frown from inside the IDE. You can also leave comments below. In addition to this if you are looking to have a directed conversation with our product team on this topic, please reach out to us through email (aasthan@microsoft.com). We would love to know more and connect with you.