Use Xamarin to develop mobile chat programs-Basic (a large number of text to explain step by step, with source download)

Source: Internet
Author: User
Tags macbook

If it is. NET developers, want to learn mobile app development (Android and iOS), Xamarin is undoubtedly the best choice, written once, can be published to the Android and iOS platform, is a sharp weapon in the weapon Ah! Moreover, Xamarin has been acquired by Microsoft and has been aggressively promoted. NET developers to invest time on Xamarin to cope with the boom in mobile development should be worthwhile.

Well, don't say much, just start. This series of articles will detail how to use Xamarin to develop a simple instant Messaging IM chat system (at the end of the source download, can sneak peek), this article as the first article, will focus on the Xamarin Android and Xamarin iOS environment, including installation, Setup, Simulator, deployment, run debugging, and so on. The following articles in this series will detail the structure of mobile phone chat system and the implementation of specific code.

I. Building the Environment

1. Install Xamarin.

VS2017 has integrated Xamarin, so long as it is installed, it will be "used." NET Mobile development "option is selected.

2. Set up Xamarin Android.

(1) After starting vs 2017, open the menu tool,->xamarin->android settings, and make the following settings on the settings panel:

(2) Use Genymotion as an Android simulator.

3. Set up Xamarin IOS.

(1) Install Visual Studio for Mac on my MacBook notebook.

(2) to find the "share" option in the MacBook's system preferences, open the "Share" interface below. Turn on remote management and telnet.

(3) Select the IOS->xamarin.mac agent in the PC-side vs "Tools" tab, click the "Add Server" button at the bottom left, enter the IP corresponding to the remote MacBook Machine and log in.

(4) After successful login, the interface will display the following link icon indicates remote success.

(5) After the connection is successful, the emulator or the real machine on the Mac machine can be debugged in vs.

(6) In PC-side vs, open the menu tool,->xamarin->ios settings, and do the following settings on the settings panel:

  

Two. Create a new Xamarin.Forms project, compile

Xamarin.Forms is a suite provided by Xamarin for form application development across mobile platforms, so if you are using Xamarin to develop apps, Xamarin.Forms will be a good choice.

1. Create a new Cross-platform cross-platform project and select the Platform App (Xamarin).

2. After the project is created successfully, three projects are generated in Solution Manager.

The Xamarindemo project is a portable class library where most of the logic and UI of the app is done.

The Xamarindemo.droid project corresponds to the Android version, and the Xamarindemo.ios project corresponds to the IOS version, both of which refer to the Esframework.xamarindemo project.

For a simple application, you just need to write the code in Xamarindemo, and the code in Xamarindemo.droid and Xamarindemo.ios only needs a few changes.

3. Compiling the Xamarindemo.droid project

In Solution Manager, select the Xamarindemo.droid project, right-click Properties, and open the Settings panel.

In the project Properties panel, to select the version number of the Android SDK that was used for compilation, I chose the latest 6.0.

4. Compiling the Xamarindemo.ios project

In Solution Manager, select the Xamarindemo.ios project, right-click Properties, and open the Settings panel.

In the Project Properties panel, select the CPU architecture supported by the compilation, and since you are now using the iOS emulator, select X86_64.

If you are debugging with a real machine, you should choose Armv7+armv7s+arm64.

Three. Deployment, commissioning

Once the compilation is successful, you can try to deploy to the virtual machine and run debugging.

1. Android version

(1) Launch the Android virtual machine.

Run the above genymotion.

Select the 6.0 virtual machine and click the Start button to run.

(2) Deployment

On the VS toolbar, select the virtual machine instance you just launched Genymotion Custom Phone-6.0.0, click the Debug button (green triangle) to begin the process of deployment and operation. (Note that to select Debug mode)

  

(3) Commissioning

After the deployment is successful, the emulator displays the demo APP's UI interface:

    

At this point, you can add a breakpoint in the source code to start debugging programs.

Version 2.iOS

(1) Start the virtual machine

(2) on the VS toolbar, select iphone 6 Plus IOS 11.2, click the Debug button (green triangle) to start the process of deployment and operation.

(3) Commissioning

Once the deployment is successful, the emulator will display the following demo login interface:

Four. Source code download

Although not formally started to introduce the implementation of the Code of the chat program, but still first to share the demo source to everyone, based on the above introduction of the content, we have been able to run the demo to see the effect. Moreover, the source code in addition to the Xamarin mobile side, also contains the chat server and the PC client and WebSocket client, and, Xamarin Mobile and PC client and the Web side can chat with each other Oh!

The following are mobile phone-side running:

(1) Source: Server +PC Client (VS 2010 based)

(2) Source: Xamarin Mobile (including Android and IOS) (vs 2017 based)

Finally, in the process of using Xamarin to develop this demo, we have stepped over a lot of "pits", and the solutions to these pits will be shared in this series of articles so that we can save some time for later. Please look forward to!

  

Use Xamarin to develop mobile chat programs-Basic (a large number of text to explain step by step, with source download)

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.