Diet

Jul 6 2017

Cross-Platform Mobile Development in Visual Studio #mobile #app #cross #platform #development

#

Cross-Platform Mobile Development in Visual Studio

Target Android, iOS, and Windows from a single code base

You can build native apps for Android, iOS, and Windows by using C# or F# (Visual Basic is not supported at this time). To get started, install Visual Studio 2015, select the Custom option in the installer, and check the box under Cross Platform Mobile Development C#/.NET (Xamarin). You can also start with the Xamarin Installer. which is required to install Xamarin for Visual Studio 2013.

If you already have Visual Studio 2015 installed, run the installer from Control Panel Programs and Features and select the same Custom option for Xamarin as above.

When you’re done, project templates appear in the New Project dialog box. The easiest way to find Xamarin templates is to just search on “Xamarin.”

Xamarin exposes the native functionality of Android, iOS, and Windows as .NET objects. Thus your apps have full access to native APIs and native user controls, and they’re just as responsive as apps written in the native platform languages.

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 mobile platforms. 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 SDK emulator, run Windows apps natively, or run Windows apps on the Windows Phone emulator. You can also use tethered Android and Windows devices directly. For iOS projects, connect to a networked Mac and start the Mac emulator from Visual Studio, or connect to a tethered device.

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, iOS, and Windows. When you compile a Xamarin.Forms solution, you’ll get an Android app, an iOS app, and a Windows app. For more details, see Learn about mobile development with Xamarin .

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.

If you’re a web developer, and you’re familiar with HTML and JavaScript, you can target Windows, Android, and iOS by using Visual Studio Tools for Apache Cordova. These apps can target all three platforms and you can build them by using the skills and processes that you’re most familiar with.

Apache Cordova is a framework that includes a plug-in model. This plug-in model provides a single JavaScript API that you can use to access the native device capabilities of all three platforms (Android, iOS, and Windows).

Because these APIs are cross-platform, you can share most of what you write between all three platforms. This reduces your development and maintenance costs. Also, there’s no need to start from scratch. If you’ve created other types of web applications, you can share those files with your Cordova app without having to modify or redesign them in any way.

To get started, install Visual Studio 2015 and choose the HTML/JavaScript (Apache Cordova) feature during setup. If you’re using Visual Studio 2013, install the Visual Studio Tools for Apache Cordova extension. Either way, the Cordova tools automatically install all third-party software that’s required to build your multi-platform app.

After you’ve installed the extension, open Visual Studio and create a Blank App (Apache Cordova) project. Then, you can develop your app by using JavaScript or Typescript. You can also add plug-ins to extend the functionality of your app, and APIs from plug-ins appear in IntelliSense as you write code.

When you’re ready to run your app and step through your code, choose an emulator, such as the Apache Ripple emulator or Visual Studio Emulator (Android or Windows Phone), a browser, or a device that you’ve connected directly to your computer. Then, start your app. If you’re developing your app on a Windows PC, you can even run it on that. All of these options are built into Visual Studio as part of the Visual Studio Tools for Apache Cordova.

Project templates for creating universal Windows apps are still available in Visual Studio so feel free to use them if you plan to target only Windows devices. If you decide to target Android and iOS later, you can always 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. That said, if you plan to target other platforms in the future, we recommend that you start with the Visual Studio Tools for Apache Cordova.

First, install Visual Studio 2015 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. C++ templates that target iOS are not yet available. You can target Android and Windows in the same solution if you want, and then share code between them by using a cross-platform static or dynamic shared library.

If you need to build an app for Android that requires any sort of advanced graphics manipulation, such as a game, you can 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.

You can also build an app that targets the full breadth of Windows 10 devices by using C++ and a universal Windows app project template. Read more about this in the Target Windows 10 devices section that appears earlier in this topic.

You can share C++ code between Android and Windows 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.





Written by admin


Leave a Reply

Your email address will not be published. Required fields are marked *