Introduction to MonoTouch

2,556 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,556
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
37
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to MonoTouch

  1. 1. MONOTOUCHEasier development of iOS applications using C# NNUG Bergen Jonas Follesø 29/02/2012
  2. 2. ABOUT ME Jonas Follesø Scientist & Manager BEKK Trondheim
  3. 3. AGENDA What is MonoTouch? FizzBuzz Demo + Unit Testing Buss Schedule Demo Cross Platform Apps Xamarin.Mobile + MonoTouch.Dialog
  4. 4. What isMono?
  5. 5. WHAT IS MONO?• Open source implementation of the .NET platform• 2001: Created to bring Windows applications to Linux• 2003: Acquired by Novell with Ximian• Matured at Novell – now a world-class runtime.
  6. 6. WHAT IS MONO? C# IronRuby IronPython Visual Basic F#
  7. 7. C# on iOS(iPhone, iPod Touch, iPad)
  8. 8. 15% discount for NNUG Commercial Product 339$ 399$xamarin.com/nnug(Free to run in emulator)
  9. 9. Demo:FizzBuzz
  10. 10. UNIT TESTING MONOTOUCH APPS • NUnit Lite Runner on device/simulator • Same NUnit syntax you already know • Possible to run the same NUnit tests on desktop, iOS and WP7 device
  11. 11. Demo:Unit Testing
  12. 12. .NET & MONO JIT ENGINE C# Memory Executable Source Code Machine Code MSIL Mono Just In Time .NET Bytecode Compilation
  13. 13. AHEAD-OF-TIME COMPILATION• Apple disallows Just-In-Time compilation (JIT)• Cannot make writable memory executable – enforced by OS• MonoTouch uses Ahead-of-Time Compilation (AOT) • Generates the native code that JIT would normally generate• Links to runtime to create single ARM process capable native binary
  14. 14. AHEAD-OF-TIME COMPILATION MSIL .NET Bytecode Native Code Mono Mono Cross Compilation (mtouch) Runtime
  15. 15. Thin layer on top ofCocoa Touch
  16. 16. Same UIComponentsnative look & fell
  17. 17. MONOTOUCH APIS.NET APIs Native APIs 3rd Party APIs• mscorlib • AddressBook • OpenTK• System • AudioToolbox • OpenGL• System.Core (LINQ) • CoreAnimation • OpenAL• System.Data • CoreGraphics • SQLite• Mono.Data.Sqlite • CoreLocation • MonoGame• System.ServiceModel • EventKit/EventKitUI • RestSharp• System.Json • ExternalAccessory • Json.NET• System.Web.Services • GameKit • ServiceStack• System.Xml • MapKit • Steema TeeChart• System.Xml.Linq • NewsstandKit • Flurry Analytics • StoreKit • RedLaser • UIKit • And so on... • And so on...
  18. 18. Demo: BussSchedule
  19. 19. Cross Platform Mobile Development
  20. 20. REUSABLE CODEEasily Reusable Reusable with some effort Not reusable• Domain Model • Code accessing • User Interface Code platform specific components that• Clients for your exist across all • Boot Strapping REST- and web platforms Code services • GPS• Data Access Code • Contacts (SQLite) • Picture Library • Accelerometer• Storage Code (Isolated Storage)• Business Logic
  21. 21. CODE REUSE FOR MWC APP• 100% reuse of Core Library (1635 LOC) iOS Android WP7• iPhone + iPad (2476 LOC) 65%• Android (1095 LOC)• WP7 (896 LOC) 60% 57%
  22. 22. COMMON API FOR SHARED FUNCTIONALITY Xamarin.Mobile Compass + Contacts Geolocation Camera Notifications Accelerometer
  23. 23. XAMARIN.MEDIA.MEDIAPICKER ImageView image = FindViewById<ImageView> (Resource.Id.image); var picker = new MediaPicker (this); picker.PickPhotoAsync() .ContinueWith (t => { if (t.IsCanceled || t.IsFaulted) // user canceled or error return; Bitmap b = BitmapFactory.DecodeFile (t.Result.Path); RunOnUiThread (() => image.SetImageBitmap (b)); });
  24. 24. XAMARIN.MEDIA.MEDIAPICKER
  25. 25. Demo:Xamarin. Mobile
  26. 26. Create UI faster usingMonoTouch.Dialog
  27. 27. GREATLY SIMPLIFIES CREATION OF SIMPLE UIS
  28. 28. TWO APIS: ELEMENTS API• MonoTouch.Dialog is a framework that brings declarative UI programming to iOSreturn new RootElement ("Settings") { new Section (){ new BooleanElement ("Airplane Mode", false), new RootElement ("Notifications", 0, 0) { new Section (null, "Turn off Notifications to disable Soundsn" + "Alerts and Home Screen Badges for thenapplications below."){ new BooleanElement ("Notifications", false) } }},
  29. 29. TWO APIS – REFLECTION API class AccountInfo { [Section] public bool AirplaneMode; [Section ("Data Entry", "Your credentials")] [Entry ("Enter your login name")] public string Login; [Caption ("Password"), Password ("Enter your password")] public string passwd; [Section ("Travel options")] public SeatPreference preference; }
  30. 30. Demo:MonoTouch.Dialog
  31. 31. Is it readyfor business?
  32. 32. CONTROVERSY 1: APRIL 2010 – APPLE’S SECTION 3.3.1• April 8nd: Apple changed license to state that: “Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs…”• September 9th: Apple changed license again: “In particular, we are relaxing all restrictions on the development tools used to create iOS apps, as long as the resulting apps do not download any code. This should give developers the flexibility they want, while preserving the security we need.”
  33. 33. CONTROVERSY 2: MAY 2011 - ATTACHEMATE• May 2nd: Attachemate buys Novell – Mono team laid off• Xamarin founded 2 weeks later• Angry Mono customers pressure Novell to cooperate with Xamarin• Xamarin secures a perpetual license to all Mono IP: copyrights, patents and trademarks
  34. 34. Basically:All good!
  35. 35. MONOTOUCH & iOS RELEASE HISTORY2009.07.17 2010.04.03 2010.06.21 2010.06.21 2011.10.12 iOS v3.0 iOS v3.2 iOS v4.0 iOS v4.0 iOS v5.0 (iPad) 2010.04.05 MT v2.0 2009.09.14 (iPad) 2011.04.06 2011.10.12 2012.01.17 MT v1.0 MT v4.0 MT v5.0 MT v5.2.5 2010.04.05 MT v3.0 (iPhone 4)
  36. 36. Summary
  37. 37. SUMMARYC# for iOS Cross Platform Useful resources• Makes iOS easily • Standard .NET libraries • http://xamarin.com/NNU accessible for .NET for tasks such as: G for 15% discount on developers. MonoTouch & Mono for • File Access Android• Thin layer on top of • Database Access CocoaTouch – same • Web Service Access • https://github.com/folles native look & feel oe/FlightsNorway/tree/w • Business Logic orkshop for 50 page workshop on cross• MonoTouch.Dialog for platform development easier UI creation • Xamarin.Mobile provides using Mono. same API for common phone functionality • NDC 2011 presentation on cross platform mobile: http://vimeo.com/267016 39
  38. 38. Questions?

×