Header Ads

iOS & Android App development using C#

app-development-ios_android

C# is the best language for mobile app development With Xamarin, you write your apps entirely in C#, sharing the same code on iOS, Android, Windows, Mac and more. Anything you can do in Objective-C, Swift or Java, you can do in C#.

What is Xamarin?
Divisions-of-Xamarin

Xamarin is a cross-platform tool that helps building of Android and iOS apps using C# as the language of coding. Xamarin opens up a way for C# programmers to build Android and iOS apps. Xamarin includes Xamarin.iOS for iOS app development and Xamarin.Android for Android app development.

iOS app development using Xamarin

IDEs-for-Xamarin iOS-app-development


Developing iPhone, iPad, iPod and Mac apps have been made possible using XCode IDE and using Objective-C, from a long time. Building iOS applications i.e. applications for iPhones and iPads using C# language on .NET platform can be made possible by making use of Xamarin.iOS. The only key entity in building iOS apps using Xcode is the use of Objective-C as the language to develop these iOS apps. Currently, C# developers who are interested in iOS development don't have to learn Objective-C to develop iOS apps. They are only required to know the basic concepts of Xamarin.iOS. Xamarin.iOS is a part of Xamarin. Xamarin is a cross-platform mobile application development software which aids in building iOS, Android and Windows apps using C# .NET platform. Xamarin provides Xamarin Studio and Xamarin plugin to Visual Studio to develop applications

In order to deploy the developed iOS app on iOS devices or to submit it to the app store, you need an Apple Developer Account. Deploying and debugging an iOS app requires generating the development certificate and creating the provision profile for the particular device in which the app will be deployed to. Provisioning is nothing but configuring the app to run on devices. Here, while creating provision profile, you will set the devices that can run your iOS app. Here, you need to provide them with the generated .ipa file.

1. Development in Windows environment

Always remember that we don't have an iOS simulator available for Windows. The iOS simulator works only on Mac OSX and therefore it is a mandate to have a Mac for testing and simulations of apps on a Mac screen using iOS simulator. Therefore, though we are developing iOS apps on Windows, we need a Mac for development. However Mac need not necessarily be placed beside you! You need a Mac on your network (i.e. Network to which your Windows machine is connected to) and you should able to connect to Xamarin Build Host present on the Mac by connecting to the Mac (Assuming that Xamarin development tools and iOS development tools are already installed on the Mac).

If you are planning to develop iOS apps using Xamarin.iOS in Windows environment, then, you have two choices. One is to use Xamarin plugin with Visual Studio and writing the C# programs in Visual Studio IDE to build your iOS apps using Xamarin library. If you are intended to develop Xamarin.iOS application using Visual Studio, then, see to it that you use Visual Studio 2010 or higher versions. Also see to it that you don't use Visual Studio Express edition. Another option is to have Xamarin Studio installed on Windows to develop Xamarin.iOS applications. However, both these options require a Xamarin.iOS Build Host. This Xamarin.iOS Build Host should be installed and setup on the Mac machine. In fact, this certifies that though we don't use the Mac directly to write the code in it, we need a Mac machine for iOS development using Xamarin. We cannot deploy iOS applications without Apple's certificates and the iOS simulator can only be run on Mac. This dependency has led to the fact that though we don't use Mac directly for coding, we still need to rely on Mac for iOS development. Therefore, in this scenario, Mac only acts as a build host.

Some of the key criteria to discuss before you connect your Windows machine enabled with Xamarin (i.e. Xamarin plug-in to Visual Studio or Xamarin Studio) to the Mac (i.e. Mac with Xamarin Build Host) are listed below:
Both machines, i.e. machine containing Windows and the Mac machine should be within the same network.

On the Mac machine, see to it that you have Xamarin Build Host. This is done by installing Xamarin on Mac. Once Xamarin is installed, you can setup Xamarin Build Host. See that you have installed iOS SDK and XCode on the Mac.

Versions of both Xamarin on Windows and Xamarin build host should be the same.

Turn off Mac's Firewall.


2. Development in Mac environment

To build applications using Xamarin.iOS in Mac, you need to have Mac OS 10.8 or above. You need to have iOS SDK with XCode installed on Mac as a prerequisite. In order to build user interfaces, you have to select either Storyboard or XIB. Storyboard file will have .storyboard extension and XIB file will have .xib extension. Storyboard and XIB files are purely UI files where you can drag and drop different controls from the toolbox on top of the View Controller placed in the Storyboard or XIB. The toolbox itself contains different View Controllers. Latest version of iOS SDK and XCode IDE can be downloaded from Apple's App Store.
There are two ways to develop iOS apps using Xamarin.iOS in Mac machines. One method is to use Xamarin Studio directly, and another is to use Visual Studio with Xamarin plug-in passively as illustrated below.

Using Xamarin Studio

Using Xamarin Studio for iOS app development on Mac is pretty simple. It is just a matter of installing the Xamarin Studio for Mac available and installing other necessary software like iOS SDK, XCode IDE etc. Thereafter, directly using Xamarin Studio to develop iOS applications is made possible.

Using Visual Studio with Xamarin plug-in

If you are using Visual Studio with Xamarin plug-in for Xamarin.iOS development and you are intended to use the same on Mac machine, then, it's a mandate to install the virtual machine (VM) software for Mac and then install Windows within this Virtual Machine created out of VM software. Thereafter, you can install all the tools including Visual Studio and Xamarin plug-in into the Windows operating system present inside the Virtual Machine. You must have to install the Xamarin.iOS development tools including Xamarin Studio, and other tools like iOS SDK and XCode IDE into the Mac. Setting up the Xamarin.iOS Build Host on the Mac is necessary as the Xamarin plug-in to Visual Studio communicates with Xamarin.iOS Build Host during the build phase of the Xamarin.iOS application.

MonoTouch:

There is something called as Mono which is an open source version of Microsoft .NET. Ahead of Time (AOT) compiler belongs to Mono runtime code generator. Open source Mono architecture comprises of class library and Common Language Runtime (CLR).

JIT is Just In Time compiler and AOT is Ahead of Time compiler. Commanding Mono runtime to generate AOT code is possible as AOT is a part of Mono runtime. MonoTouch (which is based on Mono) aids C# developers to create iOS applications using C# language. Remember that MonoTouch deals only with iOS and Mono for Android deals with Android. MonoTouch SDK which is a part of Mono empowers the development of iOS devices including iPhones, iPads, iPods etc. A C# binding to native iOS APIs is nothing but monotouch.dll, which is a part of MonoTouch.

iOS developer library provides Foundation Framework. This Foundation Framework is written in Objective-C as Objective-C classes. Apple's Foundation Framework classes include classes each of which target more functionality such as Object Creation and Disposal, OS services, Data Storage, Texts and Strings, Date and Time etc. All these functionalities are either individual classes or group of classes, which fall under the Foundation Framework. Apple's Foundation Framework offers a root class named "NSObject" class. Along with this, the Foundation framework also offers other group/individual classes that come under this NSObject. As I mentioned before, we have groups of classes or individual classes to perform all the functionalities specified previously. MonoTouch.Foundation mocks Apple's Foundation Framework. The NSObject of Apple's Foundation Framework (In Objective-C) could be utilized into Xamarin.iOS base C# application by utilizing MonoTouch.Foundation.NSObject. Even though we use Objective-C's Foundation Framework functionalities by means of utilizing MonoTouch.Foundation namespace, when it comes to the matter of using data types such as arrays and strings, the namespace (MonoTouch.Foundation) automatically maps to basic .NET types (i.e. arrays and strings in .NET) instead of mapping to the data types of Objective-C's Foundation Framework.

After reading the above paragraph with certain set of facts, we shouldn't consider Xamarin.iOS as just a binding to Objective-C because it mixes C# and Objective-C and extends .NET runtime to bind C# objects to Objective-C objects. A typical scenario is when we don't use NSString provided by NSObject in C# while working with Xamarin.iOS. Rather, we would use C# "string" type. Probably this is the best example which certifies the fact that Xamarin.iOS is not just binding to Objective-C library. Rather, it mixes both Objective-C and C#.

Managed binding to Apple's CocoaTouch library is available and it is known as CoCoaTouch.NET

References: http://xamarin.com

No comments:


Powered by Blogger.