Initial experience of Xamarin.ios development

Source: Internet
Author: User
Tags gtk

Xamarin is a cross-platform development framework that supports the development of iOS, Android, Windows phone, and Mac applications in C #, a framework that is implemented in mono.

Mono is an open-source project based on the. NET Framework that includes the C # language compiler, the CLR runtime, and a set of class libraries that can run on Windows, Linux, Unix, Mac OS, and Solaris. For. NET programmer, Xamarin is a cross-platform development artifact for Android, IOS, and Mac that can be developed not only in familiar C #, but also in Visual Studio as an IDE. This article is a xamarin.ios version of the development of the first experience.

I. Installing the development environment

For developing IOS apps with Xamarin, the preparation is two-step: (1) Install the Xamarin.ios SDK under Windows and VS, (2) Install Xamarin.iOS.Build host and Xcode under Mac. Because Xamarin iOS for Visual Studio allows iOS apps to be written under Windows, it can only be deployed and debugged on a remote MAC host or iOS device. 1.Windows under the Windows system, first make sure that Xamarin's Full Installation Wizard is downloaded from Xamarin's website, and that the installation Wizard will provide iOS and Android suite installation, which you can choose. I was stuck here when I was using the Setup Wizard to install Xamarin: The process of getting Android and iOS optional kits has been linked to failure, at first thinking it was a system version issue (I'm Win8.1 64 bit), and after interacting with some experts, I discovered that these resources were dropped by the wall ... FQ self-addressed. I also contacted the customer service to receive the following reply:

There is a couple possible causes of the issue, but it looks like a manual uninstall/reinstall would get everything Worki ng properly. 1) Press the Windows button + R to open the Run window. 2) Type appwiz.cpl to open the ADD & Remove Programs window. 3) Find Xamarin & Xamarin Studio (Optional) and uninstall them. 4) Once They ' re uninstalled, or if you ' re unable to find them; Please follow the installation steps below.

Download and install the packages shown below in the order listed:

1. JDK 1.6:http://download.xamarin.com/installer/monoforandroid/jdk-6u39-windows-i586.exe 2. Android Sdk:http://dl.google.com/android/installer_r22-windows.exe 3. gtk#: Http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.25.msi 4. Xamarin Studio:http://download.xamarin.com/studio/windows/xamarinstudio-5.0.0.878-0.msi 5. Xamarin for Windows (includes xamarin.ios for Visual Studio and xamarin.android): http://download.xamarin.com/ Xamarinforvisualstudio/windows/xamarin.visualstudio_setup-3.0.54.0.msi

I Hope this helps! -kent Green Developer Support

Ignoring Android SDK/JDK and Xamarin studio,gtk# is an encapsulation of the cross-platform graphical user interface library GTK +, which Windows users can ignore and install with mono on a non-Windows platform gtk# Similar to Windows Forms and WPF. So you just need to install one xamarin for Windows alone. The latest version of Xamarin for Windows supports VS2012 and VS2013, please poke here

After the installation is complete, open VS2013, the new Project window can see more iOS and Android directories, indicating successful installation: 2.MAC xamarin.ios support Mac OS 10.7 and later. First download Xcode 5 to IOS Dev Center and then choose to install the full Xamarin, or just install the Xamarin.ios Build Host

Two. Configuring the Deployment Debugging Environment

Because there is no iOS emulator under Windows, you need to link to a networked remote Mac host. In addition to the previous section where Xcode and Xamarin.ios are installed, the network needs to be configured. On your Mac, in Network preferences, enable and set up the proxy for the current network, and shut down the firewall in security and privacy in System preferences. Open Xamarin.ios Build Host: Click on the pairing to automatically generate a bunch of pins, used in the VS settings under Windows: Back to Windows, open VS2013, first automatically let us account login, The account you use is the account you need to create when you download on Xamarin website, I use the trial version of license, the ability to pay for the official version of it, of course, the free version can also be used, but in the release of the program has a size limit. On the Menu Tools->options->xamarin->ios Settings tab, click Find Mac Build Host: Enter the pin generated under MAC, complete the pairing, This allows Windows to make remote connections to the MAC host and remotely debug the iOS program under Windows.

Three. Create an iOS app

Open VS2013, create a new project, select the Ios->iphone->blank app template, named Helloopenxlive, you can see the project structure as follows: You can see the Monotouch in the reference node, that is, Xamarin.ios SDK, which implements the basic functionality of iOS with. Net.

Main.cs for the entry of the program, start an inherited from Uiapplicationdelegate named Appdelegate, in the Appdelegate to complete the program start and initialization work.

AppDelegate.cs, in the Finishedlaunching method, we can add the desired image (View) through the rootviewcontroller of the form, which is somewhat similar to the MVC pattern. We right-click the item, add an item, add an iphone View Controller, named Hellouiviewcontroller: Open HelloUIViewController.cs:

View Source print?
1 publicoverride voidViewDidLoad()
2 {
3     View = newUniversalView();
4
5     base.ViewDidLoad();
6 }

First, a common view is added, that is, the background view, you can modify the default background color arbitrarily, in the Initialize method of the Universalview class

View Source print?
1 voidInitialize()
2 {
3     BackgroundColor = UIColor.White;
4 }

So far the picture is still blank, we go back to the Hellouiviewcontroller class Viewdidload method, add a label, display a paragraph of text:

View Source print?
01 publicUILabel CustomLabel;
02
03 publicoverride voidViewDidLoad()
04 {
05     View = newUniversalView();
06
07     base.ViewDidLoad();
08
09     // Perform any additional setup after loading the view
10     CustomLabel = newUILabel(newRectangleF(0, 100, 300, 30))
11     {
12         Text = "Hello, OpenXLive!",
13         TextAlignment = UITextAlignment.Center,
14     };
15     View.Add(CustomLabel);
16 }

In the toolbar, set debug options, select Debug, Iphonesimulator, and specify an emulator type (such as iphone Retina (4-inch) IOS 7.1), press F5 to start debugging under Mac Host, You can see that an iOS simulator is started and initialized, our program is deployed after the simulator is started, and then you can debug breakpoints: Do not spit groove why there is no iphone shell, this is because the use of the Mac host is older, no retina screen, resolution, So the fruit shell is not shown; If the resolution is enough, it will be displayed automatically.

Next I'll show you how to migrate a. NET third-party library to iOS via Xamarin (iOS calls openxlive via Xamarin)

Summarize

This article describes the mono-based Xamarin framework, which supports the development of IOS, Android, Windows phone, and Mac apps using C #, describes the installation and configuration methods of Xamarin.ios, and describes how to use Xamarin.ios The SDK is developed under Windows and is debugged on a Mac remote host.

Reprint Please specify: Unbridled Ltech»xamarin.ios Development first Experience

Xamarin.ios Development First Experience

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.