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.
- Create Android Native-Activity applications, Native-Activity applications are implemented purely in native code (C/C++) and used typically for games and applications requiring advanced graphic manipulation. Developers will be able to build, 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.
FYI, the first section of this post renders with justified text alignment, and the results are awful, with lots of excessive spaces between words (at least on iOS). The rest of the article reads fine.
@Mike, thanks for the feedback, the alignment should be fixed now.
Why are the different platforms in cross platform projects actual separate vcxproj's rather than there just being an android-arm, android-x86 and whatnot platform toolsets?
@m, not sure I understand the question. Can you give an example of how you expect cross-platform solutions to work?
@M are you asking in (cross-platform) templates why we have separate VCXProj's for Android and Windows targets?
@Eric: The same way having win32 and x64 in the same project works now for desktop C++ projects; and showing different property pages and whatnot depending on the chosen platform.
@ankit: Yes.
The post mentions being able to build C++ libraries that can be consumed by Xamarin or Java based Android apps. All the #vsconnect content has shown debugging with a Xamarin C#-C++ application though. Is it possible to debug into a C++ component from a Java application, or can we only build the Android lib for Java consumption?
@Rob. Yes there is a way to debug your java-c++ application in visual studio as well. If you can reach out to me offline I'll happy to walk you through that experience (aasthan@microsoft.com). We will post more blog posts going over these scenarios soon. Thanks for trying out our product bits.
Is there any plan to support iOS?
It would be very useful for an game dev like me to code and debug in visual studio for both Android and iOS.
There is iOS remote build and debug support in "Visual Studio Tools for Apache Cordova" and Xamarin, I think it would be possible to add remote C++ and Objective C build and debug support in Visual Studio, and it would be really really useful
@Zhao This is great feedback for us and will take this into account as we plan for future product bits. I would still encourage you to play with our current product bits and provide us additional feedback with our android enablement. Thanks for reading this post :).
The more important question: Will the menus still be ALL CAPS?
@Kristine You can turn off ALL CAPS since 2013 Update 3.
For the cross platform dynamic libraries, is there a plan to support windows desktop as well as windows phone?
Hi, will it can be done using c#?
Is this a re licensed Embarcadero Appmethod technology?
LLVM is write anywhere, run anywhere.
JVM is write once, run anywhere.
If your going to support LLVM, this is really a game changer for our developer teams.
We run our development IDE#s in the cloud itself, because we currently inject abut 48 petabytes per year (currently, but in 6 months will be double to triple that) and need to process it.
The only way to keep them all productive is to run whole development in the cloud with VNC style connections over ssh.
It would be very helpful if you supported the Native Client SDK. This allows us to compile our c++ directly to PNACL and Emscripten (javascript).
I know this is MS feeding the beast to a degree. As a CTO, i can easily augment your tooling to allow Visual Studio to target NACL / PNACL and Emscripten.
So someone will do it anyway is my point. Even if not from the IDE, but from the command line.
Would be great if you integrated support for it anyway and let everyone through away QT Creator, and VIM, and use the best IDE there is.
Wow this sounds awesome. Really looking forward to where you guys take this. Been playing with Xamarin lately and it's great but this looks even more interesting (and possibly easier to work with). I too like the 'No Mac required' part. I assume you guys are planning Visual Studio support and the whole shebang eventually?
I hope for someone to guide me through the toolchains(I'm not a new ) ,send me emails(805600352@qq.com) if you're available offline ^_^thanks
What workflow will be used to create Cross Platform C++ apps for IOS and Android (And posibly Mac OS)
We will surely need to mix the C++ code with Objective-C for IOS, MAC and Java (with JNI) for Android.
And also we will need to create a GUI!
Is Cocoa GUI editor will be included in Visual Studio (which sounds a little strange)?
Or Visual Studio will know to how to compile the NIB GUI file, and this NIB file will be created in XCode using Interface Builder?
What workflow for mixing C++ with those languages will be used?
my suggestions:
1 write once, run anywhere
2 support ios
3 the look of GUI should be native alike
Any word on when iOS implementation will be available?
I take this does not support ARM
What do you suggest for converting an Objective-C program into one that runs on Windows and can be maintained using Visual Studio? It is graphics intensive. Is it easier to convert Objective-C into C++ or C#? What do you think would be the best replacement for the Objective-C libraries?
Hi,
I want to using the same c++ code for 3d rendering in IOS and Android what's role this approach for Context in android and ios ? for example rendering stage in android is GlSurfaceView and …. is we have the same place for rendering ?
Hi, the link to Apache Ant is broken, it is:
http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/=http:/ant.apache.org/
instead of
http://ant.apache.org/