SlideShare a Scribd company logo
1 of 48
What is new on Xamarin.iOS
Xamarin Inc
New in Xamarin.iOS
• Features added in the last year
– Based on the Mono 2.10/Silverlight-ish stack
• Features based on the Beta channel:
– Mono 3.0-based stack
– SGen GC
– Based on the .NET 4.5 API surface
Released
Beta
Visual Studio!
Released
F# Support
• Functional Programming comes to iOS!
• The pitch is simple:
– Fewer bugs
– Focus on intent
– Reuse C# libraries, experience
– More features, less time
Beta
SIZE REDUCTIONS
TweetStation – Reference App
• Comprehensive app
• Networking
• SQL
• Background
• Retina artwork
• Full (unlinked)
MonoTouch.Dialog
TweetStation Size Reduction
6,200
6,400
6,600
6,800
7,000
7,200
7,400
7,600
4.2.2 5.0.4 5.2.13 5.4.1 6.0.10
iOS 6
6.2.1 6.3.3.2
Async
(Mono3)
Size in KB
Size in KB
Released
New: SmartLink
• By default, all native code is linked-in
• SmartLink merges Mono and System linker
– Only code that is directly referenced is included
– Caveat: dynamic Objective-C code can fail
– Big savings:
Beta
SmartLink effect on Samples
-
2,000
4,000
6,000
All code
Smart Linking
Beta
Size Savings
0
100,000
200,000
300,000
400,000
500,000
Savings
RUNTIME IMPROVEMENTS
Generic Value Type Sharing
• Reduces these kinds of errors:
Unhandled Exception: System.ExecutionEngineException: Attempting to
JIT compile method
• By generating generics code that can be shared across
value types
– like reference types today
• Enables more LINQ, RX and other generic-rich apps to run
without changes, or without manual static stubs
Beta
Source of the Error
• Static compiler is unable to infer that certain
generic methods will be used at runtime with
a specific value type.
• Because the instantiations are delayed until
runtime.
Beta
Generic Sharing
• Consider: List<T>.Add (T x)
• If “T” is a reference type:
– Code can be shared between all reference types
– Only one List<RefType>.Add (RefType x) exists
– Because all reference types use same storage (one
pointer).
Beta
Generics and Value Types
• Value types use different storage:
– byte – 1 byte
– int – 4 bytes
– long – 8 bytes
• List<byte>.Add (byte x) has different code
than List<long>.Add (long x)
Beta
Generic Sharing Today
• Using string, Uri, object, int, long on Add:
– Generates one shareable for Uri, object, string
– Generates one for int
– Generates one for long
With new Generic Value Type Sharing
• Using string, Uri, object, int, long on Add:
– Generates one shareable for Uri, object, string
– Generates one for int
– Generates one for long
– Generates a value-type shareable
• Can be used by dynamic users of Add<ValueType>
Beta
Shareable Value Type Generic
• Runtime fallback for generic instantiations that
could not be statically computed
• Uses a “fat” value type
• Generates code that copies “fat” value types
• Limitation: large value types can not be shared
• You can disable if not needed:
– -O=-gsharedvt
Beta
Cost of Value Type Sharing
6,200
6,400
6,600
6,800
7,000
7,200
7,400
7,600
4.2.2 5.0.4 5.2.13 5.4.1 6.0.10
iOS 6
6.2.1 6.3.3.2
Async
(Mono3)
VT
Sharing
Size in KB Size in KB
394 Kb
Today: For TweetStation, the cost is 394kb
We are working to reduce this
Beta
Native Crypto
• System.Security.Cryptography now
powered by iOS native CommonCrytpo
• Covers
– Symmetric crypto
– Hash functions
• Hardware accelerated
– AES and SHA1 (when plugged)
• Made binaries using crypto/https 100k lighter
Released
SGen
• SGen can now be used in production on iOS
• It is no longer slower than Boehm
• And much faster on most scenarios
Beta
DEBUGGING AIDS
NSObject.Description
• New API that provides Objective-C “ToString”
• NSObject.ToString() calls Description
• Sometimes overwritten
– You can always call NSObject.Description
Released
Helping you write Threaded Apps
• UIKit is not thread safe
– No major commercial UI toolkit is thread safe
– Thread safety is just too hard for toolkits
• Very few UIKit methods are thread safe
• During debug mode, you get an exception
Released
UIApplication.CheckForIllegalCrossThreadCalls
• If set, accessing UI elements
– Throws UIKitThreadAccessException
• Most UIKit classes/methods
• UIViewController implemented outside UIKit
• Checks enabled on Debug, disabled on Release builds
– Force use: --force-thread-check
– Force removal: --disable-thread-check
Released
Thread Safe APIs
Thread Safe Classes
• UIColor
• UIDocument
• UIFont
• UIImage
• UIBezierPath
• UIDevice
Key Thread Safe Methods
• UIApplication.SharedApplica
tion, Background APIs
• UIView.Draw
See API docs for
[ThreadSafe] attribute
Released
ASYNC
Async Support
• Base Class Libraries:
– Expect all the standard Async APIs from .NET BCL
– Coverage is .NET 4.5 Complete for BCL
• MonoTouch specific:
• 114 methods on the beta
• Easy to turn ObjC methods into Async ones
– Details on the Objective-C bindings talk
Beta
Async Synchronization Contexts
• For UI thread, we run a UIKit Sync Context
– What you get from the main thread
– Code resumes execution on UIKit thread
– Using async just works
– Transparent
• Grand Central Dispatch Sync Context
– If you are running on a GCD DispatchQueue
– Will resume/queue execution on the current queue
Beta
General Async Pattern
• Methods with the signature:
void Operation (…, Callback onCompletion)
• Become:
Task OperationAsync (…)
Beta
API IMPROVEMENTS
More Strong Type Constructors
• Where you saw
– NSDictionary options
• We now support strongly typed overloads
– Give preference to strongly typed overloads
– Reduce errors
– Trips to the documentation
– Unintended effects
Released
Screen Capture
• To capture UIKit views:
– UIScreen.Capture ()
• To capture OpenGL content:
– iPhoneOSGameView.Capture ()
Released
UIGestureRecognizers
Before
void Setup ()
{
var pan= new UIPanGestureRecognizer (
this, new Selector (”panHandler"));
view.AddGestureRecognizer (pan);
}
[Export(”panHandler")]
void PanImage (UIPanGestureRecognizer rec)
{
// handle pan
}
Problems:
• Error prone: Parameter of PanImage must be right type
• No checking (mismatch in selector names)
Now
void Setup ()
{
var pan = new UIPanGestureRecognizer (PanImage);
view.AddGestureRecognizer (pan);
}
void PanImage (UIPanGestureRecognizer rec)
{
// handle pan
}
Pros:
• Compiler enforced types
• No selectors to deal with
Released
UIAppearance
• Previously:
var appearance = CustomSlider.Appearance;
appearance.SetMaxTrackImage (maxImage, UIControlState.Normal);
– Problem: does not work for subclasses
• Now:
var appearance = CustomSlider.GetAppearance<CustomSlider> ();
appearance.SetMaxTrackImage (maxImage, UIControlState.Normal);
Released
Notifications
• Used in iOS/OSX to broadcast messages
– Untyped registration
– Notification payload is an untyped NSDictionary
• Typically require a trip to the docs:
– To find out which notifications exist
– To find what keys exist in the dictionary payload
– To find out the types of the values in dictionary
Released
Xamarin.iOS Notifications
• Discoverable, nested “Notifications class”
• For example: UIKeyboard.Notifications
• Pattern:
– Static method ObserveXXX
– Returns observer token
– Calling Dispose() on observer unregisters interest
Released
Example – Full Code Completion
notification = UIKeyboard.Notifications.ObserveDidShow ((sender, args) => {
// Access strongly typed args
Console.WriteLine ("Notification: {0}", args.Notification);
// RectangleF values
Console.WriteLine ("FrameBegin", args.FrameBegin);
Console.WriteLine ("FrameEnd", args.FrameEnd);
// double
Console.WriteLine ("AnimationDuration", args.AnimationDuration);
// UIViewAnimationCurve
Console.WriteLine ("AnimationCurve", args.AnimationCurve);
});
// To stop listening:
notification.Dispose ();
Released
NSAttributedString
• On iOS 5:
– Introduced for use in CoreText
• On iOS 6:
– It became ubiquitous on UIKit
– UIKit views use it everywhere
• Cumbersome to create
Released
NSAttributedString
• Standard Objective-C esque approach:
//
// This example shows how to create an NSAttributedString for
// use with UIKit using NSDictionaries
//
var dict = new NSMutableDictionary () {
{ NSAttributedString.FontAttributeName,
UIFont.FromName ("HoeflerText-Regular", 24.0f), },
{ NSAttributedString.ForegroundColorAttributeName, UIColor.Black }
};
• Error prone:
– Get right values for keys
– Get right types for values
– Requires documentation trips
Released
NSAttributedString – C# 4 style
var text = new NSAttributedString (
"Hello, World",
font: UIFont.FromName ("HoeflerText-Regular", 24.0f),
foregroundColor: UIColor.Red);
• Uses C# named parameters
• Uses C# optional parameter processing
• Use as many (or few) as you want
Released
AudioToolbox, AudioUnit, CoreMidi
• Completed MIDI support
– Our CoreMIDI binding is OO, baked into system
– Equivalent to what 3rd party APIs people use
• AudioUnit
– Now complete supported (since 6.2)
– Full API coverage
• AudioToolbox
– Improved support for multiple audio channels
– Strongly typed APIs
Released
CFNetwork-powered HttpClient
• Use Apple’s CFNetwork for your HttpClient
– Avoid StartWWAN (Url call)
– Turns on Radio for you
– Integrates with Async
• Replace:
var client = new HttpClient ()
• With:
var client = new HttpClient (new CFNetworkHandler ())
Beta
New Dispose Semantics
• Changes in NSObject() Dispose
• If native code references object:
– Managed object is kept functional
– Actual shut down happens when native code
releases the reference.
• Allows Dispose() of objects that might still be
used by the system.
Released
Razor Integration
• Sometimes you want to generate HTML
• Razor offers a full template system
– Blend HTML and C#
– Code completion in HTML
• Easily pass parameters from C# to Template
Released
New File -> Text Template -> Razor
Released
Razor
• Creating template, passing data:
– Model property, typed in cshtml file
var template = new HtmlReport () { Model = data };
• Run:
class HtmlReport {
string GenerateString ()
void Generate (TextWriter writer)
}
Released
THANK YOU

More Related Content

Similar to What's new in Xamarin.iOS, by Miguel de Icaza

Cincom smalltalk roadmap 2015 draft3
Cincom smalltalk roadmap 2015 draft3Cincom smalltalk roadmap 2015 draft3
Cincom smalltalk roadmap 2015 draft3ArdenCST
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingBitbar
 
A Framework Driven Development
A Framework Driven DevelopmentA Framework Driven Development
A Framework Driven Development정민 안
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Kubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster SystemKubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster SystemTomoya Fujita
 
Janus Workshop @ ClueCon 2020
Janus Workshop @ ClueCon 2020Janus Workshop @ ClueCon 2020
Janus Workshop @ ClueCon 2020Lorenzo Miniero
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroMohammad Shaker
 
Introduction to Cross Platform Development with Xamarin/ Visual Studio
Introduction to Cross Platform Development with Xamarin/ Visual StudioIntroduction to Cross Platform Development with Xamarin/ Visual Studio
Introduction to Cross Platform Development with Xamarin/ Visual StudioIndyMobileNetDev
 
Optimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark HarknessOptimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark Harknessozlael ozlael
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyMark Proctor
 
C# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch GlasgowC# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch GlasgowChris Hardy
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web DevelopersKyle Cearley
 
IE10 PP4 update for W3C HTML5 KIG
IE10 PP4 update for W3C HTML5 KIGIE10 PP4 update for W3C HTML5 KIG
IE10 PP4 update for W3C HTML5 KIGReagan Hwang
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application SecurityEgor Tolstoy
 

Similar to What's new in Xamarin.iOS, by Miguel de Icaza (20)

Eclipse e4
Eclipse e4Eclipse e4
Eclipse e4
 
Cincom smalltalk roadmap 2015 draft3
Cincom smalltalk roadmap 2015 draft3Cincom smalltalk roadmap 2015 draft3
Cincom smalltalk roadmap 2015 draft3
 
Hyperloop
HyperloopHyperloop
Hyperloop
 
Hyperloop
HyperloopHyperloop
Hyperloop
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App Testing
 
A Framework Driven Development
A Framework Driven DevelopmentA Framework Driven Development
A Framework Driven Development
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Kubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster SystemKubernetes Robotics Edge Cluster System
Kubernetes Robotics Edge Cluster System
 
Top 10 python ide
Top 10 python ideTop 10 python ide
Top 10 python ide
 
Janus Workshop @ ClueCon 2020
Janus Workshop @ ClueCon 2020Janus Workshop @ ClueCon 2020
Janus Workshop @ ClueCon 2020
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
Introduction to Cross Platform Development with Xamarin/ Visual Studio
Introduction to Cross Platform Development with Xamarin/ Visual StudioIntroduction to Cross Platform Development with Xamarin/ Visual Studio
Introduction to Cross Platform Development with Xamarin/ Visual Studio
 
0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri
 
Optimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark HarknessOptimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark Harkness
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
 
C# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch GlasgowC# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch Glasgow
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
IE10 PP4 update for W3C HTML5 KIG
IE10 PP4 update for W3C HTML5 KIGIE10 PP4 update for W3C HTML5 KIG
IE10 PP4 update for W3C HTML5 KIG
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application Security
 

More from Xamarin

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinXamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushXamarin
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureXamarin
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksXamarin
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinXamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningXamarin
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UIXamarin
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesXamarin
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilityXamarin
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeXamarin
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Xamarin
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsXamarin
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureXamarin
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Xamarin
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureXamarin
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Xamarin
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioXamarin
 

More from Xamarin (20)

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

What's new in Xamarin.iOS, by Miguel de Icaza

  • 1. What is new on Xamarin.iOS Xamarin Inc
  • 2. New in Xamarin.iOS • Features added in the last year – Based on the Mono 2.10/Silverlight-ish stack • Features based on the Beta channel: – Mono 3.0-based stack – SGen GC – Based on the .NET 4.5 API surface Released Beta
  • 4. F# Support • Functional Programming comes to iOS! • The pitch is simple: – Fewer bugs – Focus on intent – Reuse C# libraries, experience – More features, less time Beta
  • 6. TweetStation – Reference App • Comprehensive app • Networking • SQL • Background • Retina artwork • Full (unlinked) MonoTouch.Dialog
  • 7. TweetStation Size Reduction 6,200 6,400 6,600 6,800 7,000 7,200 7,400 7,600 4.2.2 5.0.4 5.2.13 5.4.1 6.0.10 iOS 6 6.2.1 6.3.3.2 Async (Mono3) Size in KB Size in KB Released
  • 8. New: SmartLink • By default, all native code is linked-in • SmartLink merges Mono and System linker – Only code that is directly referenced is included – Caveat: dynamic Objective-C code can fail – Big savings: Beta
  • 9. SmartLink effect on Samples - 2,000 4,000 6,000 All code Smart Linking Beta
  • 12. Generic Value Type Sharing • Reduces these kinds of errors: Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method • By generating generics code that can be shared across value types – like reference types today • Enables more LINQ, RX and other generic-rich apps to run without changes, or without manual static stubs Beta
  • 13. Source of the Error • Static compiler is unable to infer that certain generic methods will be used at runtime with a specific value type. • Because the instantiations are delayed until runtime. Beta
  • 14. Generic Sharing • Consider: List<T>.Add (T x) • If “T” is a reference type: – Code can be shared between all reference types – Only one List<RefType>.Add (RefType x) exists – Because all reference types use same storage (one pointer). Beta
  • 15. Generics and Value Types • Value types use different storage: – byte – 1 byte – int – 4 bytes – long – 8 bytes • List<byte>.Add (byte x) has different code than List<long>.Add (long x) Beta
  • 16. Generic Sharing Today • Using string, Uri, object, int, long on Add: – Generates one shareable for Uri, object, string – Generates one for int – Generates one for long
  • 17. With new Generic Value Type Sharing • Using string, Uri, object, int, long on Add: – Generates one shareable for Uri, object, string – Generates one for int – Generates one for long – Generates a value-type shareable • Can be used by dynamic users of Add<ValueType> Beta
  • 18. Shareable Value Type Generic • Runtime fallback for generic instantiations that could not be statically computed • Uses a “fat” value type • Generates code that copies “fat” value types • Limitation: large value types can not be shared • You can disable if not needed: – -O=-gsharedvt Beta
  • 19. Cost of Value Type Sharing 6,200 6,400 6,600 6,800 7,000 7,200 7,400 7,600 4.2.2 5.0.4 5.2.13 5.4.1 6.0.10 iOS 6 6.2.1 6.3.3.2 Async (Mono3) VT Sharing Size in KB Size in KB 394 Kb Today: For TweetStation, the cost is 394kb We are working to reduce this Beta
  • 20. Native Crypto • System.Security.Cryptography now powered by iOS native CommonCrytpo • Covers – Symmetric crypto – Hash functions • Hardware accelerated – AES and SHA1 (when plugged) • Made binaries using crypto/https 100k lighter Released
  • 21. SGen • SGen can now be used in production on iOS • It is no longer slower than Boehm • And much faster on most scenarios Beta
  • 23. NSObject.Description • New API that provides Objective-C “ToString” • NSObject.ToString() calls Description • Sometimes overwritten – You can always call NSObject.Description Released
  • 24. Helping you write Threaded Apps • UIKit is not thread safe – No major commercial UI toolkit is thread safe – Thread safety is just too hard for toolkits • Very few UIKit methods are thread safe • During debug mode, you get an exception Released
  • 25. UIApplication.CheckForIllegalCrossThreadCalls • If set, accessing UI elements – Throws UIKitThreadAccessException • Most UIKit classes/methods • UIViewController implemented outside UIKit • Checks enabled on Debug, disabled on Release builds – Force use: --force-thread-check – Force removal: --disable-thread-check Released
  • 26. Thread Safe APIs Thread Safe Classes • UIColor • UIDocument • UIFont • UIImage • UIBezierPath • UIDevice Key Thread Safe Methods • UIApplication.SharedApplica tion, Background APIs • UIView.Draw See API docs for [ThreadSafe] attribute Released
  • 27. ASYNC
  • 28. Async Support • Base Class Libraries: – Expect all the standard Async APIs from .NET BCL – Coverage is .NET 4.5 Complete for BCL • MonoTouch specific: • 114 methods on the beta • Easy to turn ObjC methods into Async ones – Details on the Objective-C bindings talk Beta
  • 29. Async Synchronization Contexts • For UI thread, we run a UIKit Sync Context – What you get from the main thread – Code resumes execution on UIKit thread – Using async just works – Transparent • Grand Central Dispatch Sync Context – If you are running on a GCD DispatchQueue – Will resume/queue execution on the current queue Beta
  • 30. General Async Pattern • Methods with the signature: void Operation (…, Callback onCompletion) • Become: Task OperationAsync (…) Beta
  • 32. More Strong Type Constructors • Where you saw – NSDictionary options • We now support strongly typed overloads – Give preference to strongly typed overloads – Reduce errors – Trips to the documentation – Unintended effects Released
  • 33. Screen Capture • To capture UIKit views: – UIScreen.Capture () • To capture OpenGL content: – iPhoneOSGameView.Capture () Released
  • 34. UIGestureRecognizers Before void Setup () { var pan= new UIPanGestureRecognizer ( this, new Selector (”panHandler")); view.AddGestureRecognizer (pan); } [Export(”panHandler")] void PanImage (UIPanGestureRecognizer rec) { // handle pan } Problems: • Error prone: Parameter of PanImage must be right type • No checking (mismatch in selector names) Now void Setup () { var pan = new UIPanGestureRecognizer (PanImage); view.AddGestureRecognizer (pan); } void PanImage (UIPanGestureRecognizer rec) { // handle pan } Pros: • Compiler enforced types • No selectors to deal with Released
  • 35. UIAppearance • Previously: var appearance = CustomSlider.Appearance; appearance.SetMaxTrackImage (maxImage, UIControlState.Normal); – Problem: does not work for subclasses • Now: var appearance = CustomSlider.GetAppearance<CustomSlider> (); appearance.SetMaxTrackImage (maxImage, UIControlState.Normal); Released
  • 36. Notifications • Used in iOS/OSX to broadcast messages – Untyped registration – Notification payload is an untyped NSDictionary • Typically require a trip to the docs: – To find out which notifications exist – To find what keys exist in the dictionary payload – To find out the types of the values in dictionary Released
  • 37. Xamarin.iOS Notifications • Discoverable, nested “Notifications class” • For example: UIKeyboard.Notifications • Pattern: – Static method ObserveXXX – Returns observer token – Calling Dispose() on observer unregisters interest Released
  • 38. Example – Full Code Completion notification = UIKeyboard.Notifications.ObserveDidShow ((sender, args) => { // Access strongly typed args Console.WriteLine ("Notification: {0}", args.Notification); // RectangleF values Console.WriteLine ("FrameBegin", args.FrameBegin); Console.WriteLine ("FrameEnd", args.FrameEnd); // double Console.WriteLine ("AnimationDuration", args.AnimationDuration); // UIViewAnimationCurve Console.WriteLine ("AnimationCurve", args.AnimationCurve); }); // To stop listening: notification.Dispose (); Released
  • 39. NSAttributedString • On iOS 5: – Introduced for use in CoreText • On iOS 6: – It became ubiquitous on UIKit – UIKit views use it everywhere • Cumbersome to create Released
  • 40. NSAttributedString • Standard Objective-C esque approach: // // This example shows how to create an NSAttributedString for // use with UIKit using NSDictionaries // var dict = new NSMutableDictionary () { { NSAttributedString.FontAttributeName, UIFont.FromName ("HoeflerText-Regular", 24.0f), }, { NSAttributedString.ForegroundColorAttributeName, UIColor.Black } }; • Error prone: – Get right values for keys – Get right types for values – Requires documentation trips Released
  • 41. NSAttributedString – C# 4 style var text = new NSAttributedString ( "Hello, World", font: UIFont.FromName ("HoeflerText-Regular", 24.0f), foregroundColor: UIColor.Red); • Uses C# named parameters • Uses C# optional parameter processing • Use as many (or few) as you want Released
  • 42. AudioToolbox, AudioUnit, CoreMidi • Completed MIDI support – Our CoreMIDI binding is OO, baked into system – Equivalent to what 3rd party APIs people use • AudioUnit – Now complete supported (since 6.2) – Full API coverage • AudioToolbox – Improved support for multiple audio channels – Strongly typed APIs Released
  • 43. CFNetwork-powered HttpClient • Use Apple’s CFNetwork for your HttpClient – Avoid StartWWAN (Url call) – Turns on Radio for you – Integrates with Async • Replace: var client = new HttpClient () • With: var client = new HttpClient (new CFNetworkHandler ()) Beta
  • 44. New Dispose Semantics • Changes in NSObject() Dispose • If native code references object: – Managed object is kept functional – Actual shut down happens when native code releases the reference. • Allows Dispose() of objects that might still be used by the system. Released
  • 45. Razor Integration • Sometimes you want to generate HTML • Razor offers a full template system – Blend HTML and C# – Code completion in HTML • Easily pass parameters from C# to Template Released
  • 46. New File -> Text Template -> Razor Released
  • 47. Razor • Creating template, passing data: – Model property, typed in cshtml file var template = new HtmlReport () { Model = data }; • Run: class HtmlReport { string GenerateString () void Generate (TextWriter writer) } Released