a lap around monotouch

14
Bringing .NET to Apple iOS A Lap Around MonoTouch

Upload: mecurioj

Post on 12-Jun-2015

1.721 views

Category:

Technology


1 download

DESCRIPTION

Objective-C, CocoaTouch oh my! MonoTouch is an innovative platform that allows the C# developer to write applications for the iPhone and iPad using a subset of Mono, the open source implementation of the .Net Framework. In this talk, we will look at MonoTouch, what you need to work on MonoTouch and explore a simple application created using MonoTouch. If you are curious about MonoTouch, curious about how to get started with MonoTouch or simply curious about how .Net plays with Apple technologies, this is the lap for you.

TRANSCRIPT

Page 1: A lap around monotouch

Bringing .NET to Apple iOS

A LapAround

MonoTouch

Page 2: A lap around monotouch

A Lap Around MonoTouch Joey Filichia Research and Development

@ Denver Public Schools Email:

[email protected] [email protected] [email protected]

Twitter: @mecurioJ

On the interwebs: http://www.filichia.com

Note:• The opinions expressed today are my

own and do not represent my employer’s views in any way. Nothing discussed should be considered official or sanctioned by my employer or any other organization I’m affiliated with.

Joey Filichia has been writing code since 1982, turning a hobby into a career in 1997. Over the course of his career, Joey has worked as a systems administrator, web developer, architect, database administrator and developer. Although "Innovative and Creative" are sometimes negative when applied to programmers, over time Joey has made those traits work for his career. Currently, he is Lead of Research and Development for Denver Public Schools. His current passion is trying to find new ways to use technology as a tool to help students improve their learning skills. Currently, Joey is developing applications for the iPad, iPhone and Windows Phone 7.

Page 3: A lap around monotouch

What is Mono?• Open Source Project that provides a CLR compiler

for .NET on non-Windows OS• Web Site: http://www.mono-project.com/Main_Page• Most of the .NET framework exists in Mono• Here’s what doesn’t exist:• System.Management does not map to Linux• There are no plans to implement WPF• Windows Workflow is a future enhancement• Entity Framework isn’t available• Server-Side OData is not available, because it depends on

the Entity Framework• CodeContracts have been implemented in an API, but only

partial tooling exists.

Page 4: A lap around monotouch

What is MonoTouch?• Funded and managed by Novell• Allows .Net Developers to create native applications

using C# that can compile and run on iOS devices (iPhone, iPod, iPad)

• In essence, it compiles .Net code into Objective-C compatible code.

Page 5: A lap around monotouch

How does it do it without violating the Apple Licensing Agreement?

But it still won’t run Adobe Flash…

• April 2010 : “Third Party Tools are prohibited”• Tech Republic’s Justin James

said “…I believe that signing this agreement is about equal to selling your soul for a grilled cheese sandwich.”

• September 2010 : “Third Party Tools are not prohibited”

Page 6: A lap around monotouch

How much of MonoTouch matches .NET Framework?• Most of the .NET 2.0 Core• LINQ• Generics• WCF• ADO.NET wrappers for SQLite• Silverlight 2.0 API• Wraps iOS APIs

Page 7: A lap around monotouch

What doesn’t exist?• JIT-less environment is restricted by the kernel• Eliminates CodeDom• DRL• Reflection• Memory Management• P/Invoke methods

Page 8: A lap around monotouch

Just-In-Time versus Ahead-Of-Time

• Apple DOES NOT allow Just-In-time Compiling (JIT)• .NET uses Just-In-Time Compiling (JIT)• MonoTouch uses Ahead-of-Time Compiling (AOT)• Ahead of Time Compiling is also known as Static

Compilation• AOT Compiling creates all the native code that JIT

would normally generate• Links to runtime to create a single ARM processor

capable native binary• IL code is stripped from the managed assemblies,

leaving just metadata

Page 9: A lap around monotouch

Garbage Collection• Managed Code handles garbage collections• Objective-C for iOS uses Retain Counts• Retain Counts : Reference Counts : Memory Pointers !=

Dealloc Pointers• MonoTouch handles garbage collection • Creates an “AutoRelease” pool for anything that exists

on the main thread and any child threads

Page 10: A lap around monotouch

What do I need to do to get started with MonoTouch?• Intel Based Genuine Macintosh• “… MonoTouch is not supported when running on non-genuine

Apple hardware (Hackintsoshes) or other OS X installations virtualized in violation of Apple's license agreement, as we're unable to perform any kind of quality assurance testing for these systems, or otherwise diagnose issues that might occur in these scenarios.” – www.monotouch.net

• Latest iOS SDK• Currently at 4.02 (as of March 2011)

• Apple Developer’s Account ($99 a Year)• Familiarity with Apple’s Development Restrictions

Page 11: A lap around monotouch

Installing MonoTouch• Installation order is VERY IMPORTANT!• Remember, RTFI!!!!• http://monotouch.net/Documentation/

Installation• at least OSX version 10.5.7 Leopard (OSX

10.6.6 Snow Leopard needed for iOS 4)• Install iOS SDK • Install Mono Framework • (MonoDevelop is installed by default when

Mono is installed)• Install MonoTouch• iPhone Configuration Utility from Apple• Developer Certificates for testing on

devices (simulator comes default)

Page 12: A lap around monotouch

Now is the time we Demo and Code!

• Getting Started • You can’t escape the xibs!• Drop controls on the Interface Builder• Wire up the outlets in the AppDelegate• Access them from the C# Code Behind…

• Must use delegates, models and views…it’s the Objective C way.

• Virtual Machines…Visual Studio (2008\2010) via a VM (Virtual Box is free…) means you can use Visual Studio to handle coding using a familiar environment.• Just make sure to map a reference path within the project to the

directory that holds the Mono dll’s

Page 13: A lap around monotouch

References and Resources• Mono Project Main Page : http://

mono-project.com/Main_Page• Mono Develop : http://monodevelop.com/• MonoTouch : http://monotouch.net/• MonoTouch Pricing and Trials : http://monotouch.net/Store• Reference Book “Professional iPhone Programming with

MonoTouch and .NET/C#:” : http://www.softpro.com/0-470-63782-x.html

• MonoTouch Tutorials : http://monotouch.net/Tutorials