Cross-Platform Development in Visual Studio

Visual Studio 2013

You can build apps for iOS, Android, and Windows devices by using Visual Studio, and you can easily add connected services such as Office 365, Azure Mobile Services, and Application Insights to your apps. It’s less expensive to target multiple devices because you can share code, images, strings, and other assets between all your device projects. You can build your app by using the .NET Framework, or by using HTML.

In this article:

To build an app for Windows devices, install Visual Studio 2013 Update 2 or later, and then choose a Windows or Windows Phone project. You can target all Windows devices by using a universal app project template. To build an app for Android or iOS, install Xamarin, and then create an Android or iOS project. You can target Windows, Android, and iOS 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

To

See

Install Visual Studio 2013 Update 3

Visual Studio 2013 Update 3 download

Learn about Xamarin

Xamarin website

Learn about shared projects

Shared projects in Xamarin (Xamarin website)

Learn about Portable Class Library projects

Portable Class Library projects

Starting with Windows 8.1 and Visual Studio 2013 Update 2, you can build apps that target Windows phones, desktops, and tablets.

Windows Devices

If you want to target all three, consider starting with a universal app project template. These templates give you a solution that contains a Windows project (for desktops and tablets), a Windows Phone project, and a shared project. Shared projects are new in Visual Studio 2013 Update 2. They make it easier for you to write code in one place and consume that code in both Windows and Windows Phone projects.

The following illustration shows all three projects (Windows Phone, Windows, and shared) in a single solution. This solution was created by using the Hub App (Universal Apps) project template.

universal Windows app solution

Universal app projects are available in C# and C++. However, if you’re a Visual Basic developer, you can still target both types of devices by adding separate Windows and Windows Phone projects to a solution, and then using a Portable Class Library project to share code between them.

Learn more

To

See

Install Visual Studio 2013 Update 3

Visual Studio 2013 Update 3 download

Learn about universal Windows apps

Create universal Windows apps (Windows Dev Center)

Learn about universal app project templates

Build universal Windows apps that target Windows and Windows Phone

Learn about Portable Class Library projects

Portable Class Library projects

You can build apps for Android and iOS devices by using C#. To get started, install Xamarin. After you install Xamarin, Android and iOS project templates appear in the New Project dialog box, as the following illustration shows.

iOS and Android projects in Visual Studio

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 or Java.

You can include Android, iOS, and Windows projects in the same solution. Here’s a universal app solution that includes Windows, Windows Phone, Android, and iOS projects. All projects can use the code in the shared project.

Solution with Windows, Android, and iOS projects

Learn more

To

See

Learn about Xamarin

Xamarin website

Install Xamarin

Xamarin download (Xamarin website)

Learn about universal app project templates

Build universal Windows apps that target Windows and Windows Phone

You can share most of your code between device projects. This includes any business logic, cloud integration, database access, or any other code that targets the .NET Framework. You can share quite a bit more between Windows and Windows Phone projects, because so many aspects of the two platforms have converged. The only code that you can’t share is code that targets a specific platform.

Share code between Windows, iOs, and Android UI's

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

To

See

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

You can target multiple devices or just one. If you target only one device, you can always add devices later. This section describes two potential paths.

Start with Android, and build an iOS version later

Step

See

Install Xamarin.

Xamarin download (Xamarin website)

Install the Shared Project Reference Manager.

Shared Project Reference Manager download

Create an Android app.

Introduction to Android development with Xamarin (Xamarin website)

Create a shared project and move as much code as possible to that project.

Shared Projects in Xamarin (Xamarin website)

Add conditional compilation symbols to your Android project.

For example, add a symbol named _ANDROID_ to your project. Then, use that symbol as part of a compiler directive in your shared code to enclose blocks of Android-specific code.

Conditional compilation symbols in Visual Studio (Pinter Computing website)

Add an iOS project to your solution.

Introduction to iOS development with Xamarin (Xamarin website)

Reference the shared project from your iOS project.

Shared Projects in Xamarin (Xamarin website)

Add conditional compilation symbols to your iOS project.

For example, add a symbol named _IOS_ to your project. Then, use that symbol as part of a compiler directive in your shared code to enclose blocks of iOS-specific code.

Conditional compilation symbols in Visual Studio (Pinter Computing website)

Start with Windows devices, and build an iOS version later

Step

See

Create a universal Windows app.

Build universal Windows apps that target Windows and Windows Phone

Install the Shared Project Reference Manager.

Shared Project Reference Manager download

Add an iOS project to your solution.

Introduction to iOS development with Xamarin (Xamarin website)

Reference the shared project from your iOS project.

Shared Projects in Xamarin (Xamarin website)

Add compiler conditional compilation symbols to your iOS project.

For example, add a symbol named _IOS_ to your project. Then, use that symbol as part of a compiler directive in your shared code to enclose blocks of iOS-specific code.

Use the WINDOWS_PHONE_APP symbol to enclose code specific to Windows Phone. Use the WINDOWS_APP symbol to enclose code specific to Windows.

Use WINDOWS_PHONE_APP || WINDOWS_APP to enclose code that applies to either Windows or Windows Phone.

Conditional compilation symbols in Visual Studio (Pinter Computing website)

If you’re a web developer and you’re familiar with HTML and JavaScript, you can target Windows, Android, and iOS devices by creating a multi-device hybrid app. You can create a multi-device hybrid app that targets only Windows devices, or you can create a universal Windows app by using templates that are specifically designed to help you build apps for Windows devices.

If you want to build a Windows app that works on Android or iOS, or you think you might want to add support for an Android or iOS device later, create a multi-device hybrid app. These apps can target all three platforms, and you can build them by using Apache Cordova.

Cordova is a set of device APIs that let you access native device functions such as the camera or accelerometer by using JavaScript. 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.

Multi-Device Hybrid Apps

To get started, install the Multi-Device Hybrid Apps for Visual Studio extension. 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

To

See

Learn about Cordova project templates in Visual Studio.

Getting Started with Multi-Device Hybrid Apps Using HTML and JavaScript

Install the Multi-Device Hybrid Apps extension for Visual Studio

Multi-Device Hybrid Apps for Visual Studio extension

If you plan to target only Windows devices (desktop, phone, and tablet), the fastest way to get started is to use a Windows, Windows Phone, or 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.

Windows Devices

Universal app templates are more versatile than Windows and Windows Phone app templates. They provide a solution that includes both a Windows project and a Windows Phone project. Even if you want to target only one device (for example, a Windows Phone) right now, you’ll be glad that you used a universal app template if you decide to target other Windows devices (such as tablets or desktop computers) later. That’s because the solution contains a shared project where you can write code in one place and then use that code in both your device projects. You can share quite a bit of your code between Windows and Windows Phone projects, because so many aspects of the two platforms have converged.

The following illustration shows all three projects (Windows Phone, Windows, and shared) in a single solution. This solution was created by using the Hub/Pivot App (Universal Apps) project template.

Universal app solution

Learn more

To

See

Install Visual Studio 2013 Update 3

Visual Studio 2013 Update 3 download

Learn about universal Windows apps

Building universal Windows apps for all Windows devices (Windows Dev Center)

Learn about universal app project templates in Visual Studio

Universal app templates

Build an app for Windows Phone

Building Windows Phone 8.1 Apps in HTML (Visual Studio blog)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft