Cross-Platform Development in Visual Studio
You can build apps for Android, iOS, and Windows devices by using Visual Studio. As you design your app, use tools in Visual Studio to easily add connected services such as Office 365, Azure Mobile Services, and Application Insights.
Build your apps by using C# and the .NET Framework, HTML and JavaScript, or C++. Share code, strings, images, and in some cases even the user interface itself.
If you want to build a game, install Visual Studio tools for Unity and enjoy all of the powerful productivity features of Visual Studio with Unity, the popular cross-platform game engine and development environment for games that run on iOS, Android, Windows, and other platforms.
In this article:
Build an app for Android, iOS, and Windows devices (.NET Framework)
Build an app for Android, iOS, and Windows devices (HTML/JavaScript)
Build an app for Android and Windows devices (C++)
Build a game for Android, iOS, and Windows devices by using Visual Studio Tools for Unity
Build an app for Android, iOS, and Windows devices (.NET Framework)
To build an app for Android or iOS, install Xamarin, and then create an Android or iOS project. To build an app for Windows devices, choose a Windows universal app project template. You can target Android, iOS, and Windows devices in the same solution if you want, and then share code between all your device projects by using a shared project or a Portable Class Library project.
Learn more |
---|
Install Visual Studio (VisualStudio.com) |
Learn about Xamarin in Visual Studio (VisualStudio.com) |
Learn about universal Windows apps in Visual Studio (VisualStudio.com) |
Learn about the similarities between Swift and C# (download.microsoft.com) |
Target Android and iOS devices
You can build native apps for Android and iOS by using C#. To get started, obtain a Xamarin license. Then, install Xamarin which installs the Xamarin extension for Visual Studio. When you’re done, Android and iOS project templates appear in the New Project dialog box, as the following illustration shows.
These templates expose the native functionality of Android and iOS devices as C# objects. Your apps have full access to native APIs and native user controls, so they’re just as responsive as Android and iOS apps written in Objective-C, Swift, or Java.
After you create a project, you’ll leverage all of the productivity features of Visual Studio. For example, you’ll use a designer to create your pages, and use IntelliSense to explore the native API’s of the Android and iOS platform. When you’re ready to run your app and see how it looks, you can use the Visual Studio Emulator for Android or the Android emulator of your choice. For iOS projects, connect to a networked Mac and start the Mac emulator from Visual Studio.
Design one set of pages that render across all devices by using Xamarin.Forms
Depending on the complexity of your apps design, you might consider building it by using Xamarin.Forms templates in the Mobile Apps group of project templates. Xamarin.Forms is a UI toolkit that lets you create a single interface that you can share across Android and iOS as well as the Windows Phone. When you compile a Xamarin.Forms solution, you’ll get an Android app, an iOS app, and a Windows phone app. If you use Xamarin.Forms for Windows Preview you can target Windows tablets as well.
While building one user interface that renders on all three platforms seems very appealing, make sure to review the strengths and limitations of that approach before making an investment. If you end up having to extend the framework by creating a lot of custom control renderers so that you can achieve more complicated and tailored UI experiences, you might want to design separate UI’s for each platform individually. You’ll still get all of the advantages of using a single language (C#), share large amounts of your code between your devices and as a bonus, all of the advanced design tools that are taylored specifically to each platform such as a visual designer for iOS storyboard files, and Blend for visually designing Windows universal apps.
Learn more |
---|
Learn about Xamarin (Xamarin website) |
Evaluate Xamarin licenses (Xamarin website) |
Install Xamarin (Xamarin website) |
Learn about Xamarin.Forms (Xamarin website) |
Connect your Android or IOS app to a Microsoft cloud backend (Azure.com) |
Learn about the Visual Studio Emulator for Android (VisualStudio.com) |
Target Windows devices
If you want to create a single app that targets the full breadth of Windows 10 devices, create a Windows universal app. You’ll design the app by using a single project and your pages will render properly no matter what device is used to view them.
Start with a Windows universal app project template. Design your pages visually, and then open them in a preview window to see how they appear for various types of devices. If you don’t like how a page appears on a device, you can optimize the page to better fit the screensize, resolution, or various orientations such as landscape or portait mode. You can do all of that by using intuitive tool windows and easily accessible menu options in Visual Studio. When you’re ready to run your app and step through your code, you’ll find all of the device emulators and simulators for different types of devices together in one drop-down list that is located on the Standard toolbar.
Windows 10 is fairly new, so you’ll also find project templates that target Windows 8.1. You can use those project templates if you want and your app will run on Windows 10 phones, tablets, and PCs. However, all devices that run Windows 8.1 will receive an automatic upgrade to Windows 10, so unless you have specific reasons why you’d rather target Windows 8.1, we recommend that you use the project templates that target Windows 10.
Learn more |
---|
Learn about universal Windows apps (Windows Dev Center) |
Learn about universal app project templates (Windows Dev Center) |
Share code between Android, iOS, and Windows apps
If you’re not using Xamarin.Forms and choose to design for each platform individually, you can share most of your non-UI code between platform projects (Android, iOS, and Windows). This includes any business logic, cloud integration, database access, or any other code that targets the .NET Framework. The only code that you can’t share is code that targets a specific platform.
You can share your code by using a shared project, a Portable Class Library project, or both. You might find that some code fits best in a shared project, and some code makes more sense inside a Portable Class Library project.
Learn more |
---|
Choose whether to share your code by using shared projects, Portable Class Library projects, or both. Sharing code across platforms (.NET Framework blog) Sharing Code Options (Xamarin website) Code sharing options with the .NET Framework (MSDN Library) |
Build an app for Android, iOS, and Windows devices (HTML/JavaScript)
If you’re a web developer, and you’re familiar with HTML and JavaScript, you can target Windows, Android, and iOS devices by using Visual Studio Tools for Apache Cordova. If you want to create an app that targets only Windows devices, create a Windows universal app by using templates that are specifically designed to help you build apps for Windows devices.
Target Android, iOS, and Windows devices by using Apache Cordova
If you want to build an app by using HTML, CSS, and JavaScript, that can run on Android, iOS, and Windows devices, use Visual Studio Tools for Apache Cordova. These apps can target all three platforms, and you can build them by using Apache Cordova.
Cordova is a plug-in model that you can use to access the native API’s of a device by using JavaScript code. You don’t have to write native code to access this functionality, and because the APIs are cross-platform, you can share most of what you write with other target platforms.
To get started, install Visual Studio along with Visual Studio Tools for Apache Cordova. This extension automatically installs all third-party software that’s required to build your multi-device app. In Visual Studio, create a Blank App (Apache Cordova) template to use these APIs and build your app. This template sets up a project for you. Then, you can develop your app by using JavaScript or TypeScript.
You can add plug-ins to extend the functionality of your app, and APIs from plug-ins appear in IntelliSense as you write code. In most cases, you don't have to install or configure any other tools to debug your app. Just use the Visual Studio debugger to target various emulators.
Learn more |
---|
Install Visual Studio (VisualStudio.com) |
Install the Visual Studio Tools for Apache Cordova. (VisualStudio.com) |
Getting Started with Visual Studio Tools for Apache Cordova (MSDN Library) |
Connect your Cordova app to a Microsoft Azure cloud backend (MSDN Blogs) |
Learn about the Visual Studio Emulator for Android (VisualStudio.com) |
Target only Windows devices
If you plan to target only Windows devices, the fastest way to get started is to use a Windows universal app project template. These templates provide starter HTML and JavaScript code, and give you complete access to native APIs and features via the Windows Runtime. You’ll find plenty of guidance to help you build your app on the Windows Dev Center. If you decide to target Android and iOS devices later, you can port your code to a Cordova project. There are open-source versions of the WinJS APIs, so you can reuse any code that consumes those APIs.
What’s great about a Windows universal app is it can target the full breadth of Windows 10 devices. You’ll design it by using a single project and your pages will render properly no matter what device is used to view them.
Windows 10 is fairly new, so you’ll also find project templates that target Windows 8.1. You can use those project templates if you want and your app will run on Windows 10 phones, tablets, and PCs. However, all devices that run Windows 8.1 will receive an automatic upgrade to Windows 10, so unless you have specific reasons why you’d rather target Windows 8.1, we recommend that you use the project templates that target Windows 10.
Learn more |
---|
Install Visual Studio (VisualStudio.com) |
Learn about universal Windows apps (Windows Dev Center) |
Learn about universal app project templates in Visual Studio (Windows Dev Center) |
Build an app for Windows Phone (Visual Studio blog) |
Build an app for Android and Windows devices (C++)
First, install Visual Studio and the Visual C++ for Cross Platform Mobile Development tools. Then, you can build a native activity application for Android or an app that targets Windows devices. C++ templates that target iOS devices are not yet available.
You can target Android and Windows devices in the same solution if you want, and then share code between them by using a cross-platform static or dynamic shared library.
Learn more |
---|
Download Visual Studio. (VisualStudio.com) |
Install the Visual C++ for Cross-Platform Mobile Development tools. (MSDN Library) |
Learn more about using C++ to target multiple platforms. (VisualStudio.com) Learn even more about using C++ to target multiple platforms (Visual C++ Team Blog) |
Target Android devices
If you need to build an app for Android that requires any sort of advanced graphics manipulation, such as a game, you can now use C++ to do it. Start with the Native-Activity Application (Android) project. This project has full support for the Clang toolchain.
When you’re ready to run your app and see how it looks, use the Visual Studio Emulator for Android. It’s fast, reliable, and easy to install and configure.
Learn more |
---|
Learn more about using C++ to target multiple platforms (VisualStudio.com |
Install what you need, and then create a native activity application for Android (MSDN Library) |
Learn about the Visual Studio Emulator for Android (VisualStudio.com) |
Target Windows devices
You can build an app that targets the full breadth of Windows 10 devices by using C++ and a Windows universal app project template.
Read more about this in the Target Windows devices section that appears earlier in this topic.
Share code between Android, iOS, and Windows devices
You can share C++ code between Android and Windows devices by creating a static or dynamic shared library.
You can consume that library in a Windows or Android project, like the ones described earlier in this section. You can also consume it in an app that you build by using Xamarin, Java, or any language that lets you invoke functions in an unmanaged DLL.
As you write code in these libraries, you can use IntelliSense to explore the native APIs of the Android and Windows platforms. These library projects are fully integrated with the Visual Studio debugger so you can set breakpoints, step through code, and find and fix issues by using all of the advanced features of the debugger.
Learn more |
---|
Learn more about sharing C++ code with Android and Windows apps (VisualStudio.com) |
Build a cross-platform game for Android, iOS, and Windows devices by using Visual Studio tools for Unity
Visual Studio Tools for Unity is a free extension for Visual Studio that integrates Visual Studio’s powerful code editing, productivity, and debugging tools with Unity, the popular cross-platform game engine and development environment for games that target Windows devices, iOS, Android, and other platforms.
With Visual Studio Tools for Unity (VSTU), you can use Visual Studio to write game and editor scripts in C# and then use its powerful debugger to find and fix errors. The latest release of VSTU brings support for Unity 5 and includes syntax coloring for Unity's ShaderLab shader language, better synchronization with Unity, richer debugging, and improved code generation for the MonoBehavior wizard. VSTU also brings your Unity project files, console messages, and the ability to start your game into Visual Studio so you can spend less time switching to and from the Unity Editor while writing code.
Start building your game with Unity and Visual Studio Tools for Unity today.
Learn more |
---|
Read more about Visual Studio Tools for Unity (MSDN Library) |
Start using Visual Studio Tools for Unity (MSDN Library) |
Read about the latest enhancements to the Visual Studio Tools for Unity 2.0 Preview (Visual Studio blog) |
Watch a video introduction to the Visual Studio Tools for Unity 2.0 Preview (Video) |
Learn about Unity (Unity website) |
See Also
Concepts
Application Insights for Visual Studio Online