Xamarin Experience: Developing ios/android apps with C #

Source: Internet
Author: User
Tags gtk

Original: Xamarin Experience: Developing ios/android apps with C #

Xamarin is a company created by Mono's founder Miguel de Icaza, designed to enable developers to write iOS, Android, Mac applications, or cross-platform mobile development in C #.

Brief introduction

Xamarin is a mono-based platform that currently has the following products (see: http://xamarin.com/products):

    • Xamarin Studio:ide, was renamed from the original MonoDevelop. Now downloaded from the MonoDevelop official website is also the Xamarin studio:http://monodevelop.com/. (Say MonoDevelop is also a branch of sharpdevelop development)
    • Xamarin.ios: Formerly known as Monotouch, used to develop IOS apps and can be published on the App Store.
    • Xamarin.mac: For developing MAC OS X applications, similar to Windows desktop apps.
    • Xamarin.android: Formerly known as Monodroid/mono for Android, used to develop Android apps.
    • Xamarin for Visual studio:visual Studio plug-ins, including iOS and Android, but currently only supports vs2010/vs2012.
    • Xamarin Test Cloud: Testing your app to publish your application to the cloud on Xamarin, which automatically helps you test your app on hundreds of of devices.
    • Component Store: The component store, which has a variety of fees/free controls available for download.

And then there's the windows phone that doesn't know where to run ...

Interface Designer

For Android, whether it's Xamarin studio or Xamarin for Visual Studio, there is a designer that makes it easy to design the interface directly, see: http://docs.xamarin.com/guides/ android/user_interface/designer_overview/.

While iOS is not so lucky, Xamarin for Visual Studio does not have a designer. While Xamarin Studio has a designer provided, but currently only available in the Xamarin Studio Alpha version on iOS, it is estimated that the stability is not enough, see: http://docs.xamarin.com/guides/ios/ User_interface/designer/, had to look forward to the future to provide.

You have already installed Xamarin studio or Visual Studio that can be updated directly by switching channels: Http://docs.xamarin.com/recipes/cross-platform/ide/change_ updates_channel/, currently has stable stable version, beta version, and alpha version.

Working style

The android application is compiled into IL code and then JIT-compiled (dynamically compiled) at startup, and a mono runtime is included when the program is published.

iOS, however, compiles the code directly to the arm through AOT compilation (static compilation).

See details: Http://xamarin.com/how-it-works

API documentation

Xamarin provides the API documentation:

    • Android:http://androidapi.xamarin.com/?link=root%3a%2fmonoandroid-lib
    • Ios:http://iosapi.xamarin.com/?link=root%3a%2fmonotouch-lib

Install Xamarin Studio

Xamarin Studio can be downloaded directly from Http://monodevelop.com/Download, and the latest stable version is now 4.0.13.

    • Windows edition relies on the. NET Framework 4.0 and gtk# for. NET 2.12.22 to install Xamarin Studio directly after two dependencies are installed.
    • Mac OSX relies on Mono + gtk# and requires the first download from http://www.go-mono.com/mono-downloads/download.html MRE (mono Runtime) or MDK (mono Developmentkit) installation. Both MRE and MDK contain gtk# and mono.

Android

Android relies on JDK6 and Android SDK, so you need to download it first:

    • Jdk6:http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html
    • Android SDK and NDK:HTTP://DEVELOPER.ANDROID.COM/SDK, where the NDK is not required.
    • Xamarin.android:http://xamarin.com/download

After installing the JDK and ANDROIDSDK, installing xamarin.android will let you choose whether to install the Visual Studio plugin.

After installing the Visual Studio plugin, set the path to the Android SDK and NDK in the menu tools->options->xamarin->android settings.

Needless to say, Eclipse is too bad to compare with IntelliJ idea, if Android Studio is the best choice for Java development, ADT doesn't have to think about it.

Android Simulator and debugging

Since the emulator provided by the Android SDK is in the big slow, too bad, so have to find a replacement.

Virtual box-based genymotion is definitely the best choice and runs very smoothly, but currently only supports Android4.1.1, 4.2.2.

On the official website: http://www.genymotion.com/registered a good account, and download the installation of Genymotion, the latest version of the current 1.3.0.

You need to install virtual box on your PC before installation (currently the latest version is 4.3.2), but I found that I installed the virtual box 4.3.2 Genymotion Unable to start, so later replaced by the official recommended 4.2.12, from https:// Www.virtualbox.org/wiki/Download_Old_Builds_4_2 download.

After the installation is complete:

    • Via the "Settings" button: Set up the Android SDK path and tick "when a virtual devices starts, connect it automatically to ADB", "ADB from Android Deve Loper Tools successfully found ".
    • Via the "ADD" button
      • Add a device and then need to sign in
      • If the selected device image is not downloaded, you will need to download the vbox image of a device online, with a typical image size of 200M.
      • Add a virtual machine with the wizard prompts, enter a name such as "Lwme Nexus s-4.2.2-with Google apps-api 17-480x800" and wait for the virtual machine to be created.
      • Running a virtual machine from the Play button

After the virtual machine is started, the Xamarin.android toolbar of VS will list the name of the device and you can select the device to debug the Android application on the Genymotion emulator.

IOS on Mac

In Mac OS X to use Xamarin Studio, you must first install Xcode. If you have already installed Xamarin Studio, you can also install Xamarin.ios directly, and then directly develop and debug your iOS application directly from Xamarin Studio.

IOS on Windows

Xamarin.ios is installed directly under Windows, and because there is no emulator under Windows, you need to connect to a Mac emulator for debugging.

Prerequisites are (see: http://docs.xamarin.com/guides/ios/getting_started/installation/mac/):

    • Install and activate Xamarin Studio and Xamarin.ios under Mac
    • Enable Web Proxy (HTTP) in Network->proxies
    • Shutting down the firewall

One of the most important prerequisites is that you must have an iPhone Developer program (IDP) certificate, otherwise there is no way to debug, no need to: https://developer.apple.com/programs/ ios/Application (individual developer $ per year).

After doing the above actions:

    • Tools->options->xamarin->ios Settings->mac Build Host->configure->configure host in Visual Studio Manually
    • Enter the IP address of your Mac and wait for your Mac device to display ready
    • Click the Connect button to connect the device
    • Connection Successful
      • SDK updates may be prompted after a successful connection, select Update, or you will be prompted for a version mismatch cannot connect to Mac
      • Update successful requires re-opening vs

There are two modes of Xamarin.ios Visual Studio plug-in debugging:

    • Real Machine (iphone): By default, you need to connect the iphone to your Mac via USB
    • Simulator (iphonesimulator): Simulator debugging

The iphone is the default and can be changed at Build->configuration Manager's platform, otherwise the iphone will show "no Devices attached" without a connection.

For specific configuration, see: http://docs.xamarin.com/guides/ios/getting_started/introduction_to_Xamarin_iOS_for_visual_studio/.

You can then debug, some situations may mtouch not have permission to run, and you need to chmod +x/developer/monotouch/usr/bin/mtouch to give permission to run.

Visual Studio 2013

The Visual Studio plug-in for Xamarin does not currently support vs 2013, so you'll need to select all 2010 and 2012 when installing Xamarin's vs plugin (as there are only 2013 left in My Computer, Installing VS2013 will also install some VS2010 shells, so the VS plugin will be installed in the VS2010 directory.

Next you need to manually copy some files (if VS2013 is installed on C drive):

    • Copy C:\Program files (x86) \microsoft Visual Studio 10.0\common7\ide\extensions\xamarin to C:\Program files (x86) \ Microsoft Visual Studio 12.0\common7\ide\extensions\xamarin
    • Copy C:\Program Files (x86) \microsoft The Android directory and iOS directory under the Visual Studio 10.0\common7\ide\projecttemplates\csharp directory to C + + Program Files (x86) \microsoft Visual Studio 12.0\common7\ide\projecttemplates\csharp
    • Put C:\Program Files (x86) \microsoft Visual Studio 10.0\common7\ide\itemtemplates\ Xamarin.android directory in CSharp directory and iOS ramps copied to C:\Program Files (x86) \microsoft Visual Studio 12.0\common7\ide\itemtemplates\ CSharp
    • Run the C:\Program files (x86) \microsoft Visual Studio 12.0\common7\ide\devenv.exe/setup/nosetupvstemplates Build project and file template cache

The above method is from: http://blog.fire-development.com/2013/07/01/install-xamarin-in-vs-2013-preview-1/, and then by the embarrassing month transformation.

Android and iOS apps can now be developed on the VS2013.

For more information please see the official developer center:http://docs.xamarin.com/

More information in Chinese:
http://www.microsoft.com/taiwan/vstudio/Xamarin/
Terry ' s IT note:http://www.dotblogs.com.tw/taihon64/tags/xamarin/default.aspx
James ' s Tech blog:http://www.dotblogs.com.tw/jamestsai/category/9345.aspx
Donma When: http://www.dotblogs.com.tw/junegoat/Tags/Xamarin/default.aspx
Technology Research website: http://www.dotblogs.com.tw/toysboy21/category/9451.aspx

Finally, two books are recommended by the way:

    • "C # developing Android App": http://product.dangdang.com/23169905.html
    • Monotouch Application Development Practice Guide: Developing iOS apps using C # and. NET: http://product.dangdang.com/22922216.html

--eof--

Xamarin Experience: Developing ios/android apps with C #

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.