Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How MonoTouch works?

I would really appreciate it anybody could briefly explain me, what's the general approach to implementing things like MonoTouch? I'm really amazed because it's not the first example I see when people get some platform like Java and make it translate into something like C/Objective-C. I can't really imagine how things like Garbage collector and stuff are being translated.

Thanks in advance.

EDIT: I understand theoretical possibility of translating one language into another. My question is a bit more technical: do they implement a complete runtime in ObjC and bundle it? (I doubt it...) Or they just translate C# code into ObjC/binary/etc?

like image 414
Anton Avatar asked Sep 21 '09 08:09

Anton


People also ask

How do Xamarin forms work?

At runtime, Xamarin. Forms uses platform renderers to convert the cross-platform UI elements into native controls on Android, iOS and Windows devices. It enables the developer to give the native look, feel and user experience to the application while using the feature of code-sharing across platforms.

What is Mono touch?

• Libraries that bind the native CocoaTouch APIs – toolsets that help to create native application interfaces for iPhone, iPad and iPod Touch. Mono for Android (MonoDroid)is a software development environment kit that allows to create the applications that run on Android phones and tablets.

What can I do with Xamarin?

Xamarin allows developers to develop native applications for Android, iOS and Windows Phone platforms, with a single codebase, i.e. C# and a single IDE, i.e. Visual Studio . Thus, a developer can be able to develop native mobile applications without knowing Java, Kotlin, Objective-C or Swift.

What is the purpose of Xamarin?

Xamarin is a software company that created the Common Language Infrastructure (CLI) implementations and was purchased by Microsoft in 2016. Xamarin is a development platform that aims to create mobile applications for iOS, Android and Windows.


1 Answers

MonoTouch isn't a translator. It's simply the Mono runtime running on iPhone, with some fancy trickery to make it compatible with the iPhone's restrictions.

The conventional Mono "runtime" isn't just the JIT, it also handles GC, reflection, I/O layer, threading, exceptions etc. There's also the class libraries. In order for your app to run on the iPhone, much of this must be included with the app. Slimming it down presents some challenges. In addition, the iPhone prevents JIT runtime code generation, only runs signed code, and doesn't allow dynamic libraries.

What MonoTouch does is to use an IL linker to combine just the parts of the class libraries that your code uses into a single IL binary. It then uses AOT compilation to pre-generate all the native code that the JIT would normally generate from the IL, then links this together with the JIT-less runtime into a single native binary that can be signed. Finally, the IL is stripped from the managed binary. leaving only metadata.

like image 93
Mikayla Hutchinson Avatar answered Sep 19 '22 04:09

Mikayla Hutchinson