SlideShare a Scribd company logo
1 of 32
Sébastien Pouliot
So!ware Developer
Xamarin
sebastien@xamarin.com
Advanced iOS build mechanics
Improving performance and
reducing executable size
Why Should You Care?
Quicker Builds
Smaller Applications
Faster Applications
Prime Directive:
Time Everything - Often
Best Default Worse
14
7
2
27
19
6
How Much Time? Field Service Sample
Build Time (Debug) Deploy Time
Best Default Worse
37
16
14
169
49
16
Simulator Devices
Building for the iOS Simulator
.dll
C#
.exe
+ =
.app
addin
mtouch
•Resolve
•Package
•Embed	
  mono
•Deploy
?
Simulator vs Emulator
• Speed Over Compatibility
• Apple Simulator Tradeoffs
Simpler, less restrictive environment
• Xamarin Simulator Tradeoffs
Just In Time (JIT) compiler
Minimize files copying (symlinks)
Shared application launcher
Simulator : What to Do?
best
default 7
2
19
6 Build Time
Deploy Time
• Build
Avoid optimizing PNG files
• Deploy
Keep the simulator running
Simulator : What to Avoid?
best
worse 14
2
27
6 Build Time
Deploy Time
• Build
Enabling the linker
Disabling the shared launcher -­‐-­‐nofastsim
• Deploy
Up to 12 seconds to cold start
Simulator : Extra Tips
• Prefer Build over Rebuild
• Avoid copying files
Access them from a single location
The sandbox is not enforced
• Use -­‐time	
  -­‐time to measure your changes
-­‐time	
  -­‐time
Building for iOS Devices
•Resolve
•Global	
  Op8miza8ons
•AOT	
  Compila8on
•Na8ve	
  Compila8on
•Na8ve	
  Linking
•Copy	
  files
•Op8mize	
  PNG
•En8tlements
•Code	
  sign
•IPA
•Symbols	
  (DWARF)
•Stripping	
  (symbols)
•Stripping	
  (IL)
•Packaging
•Deployment
.dll
C#
.exe
+ =
? .app
Building for iOS Devices
addin mtouch
•	
  Resolve
•	
  Managed	
  Linking
•	
  AOT	
  Compila8on
•	
  Na8ve	
  Compila8on
•	
  Na8ve	
  Linking
•	
  Symbols	
  (DWARF)
•	
  Copy	
  files
•	
  Op8mize	
  PNG
•	
  Provisioning
•	
  En8tlements
•	
  Code	
  sign
•	
  IPA
•	
  Stripping
•	
  Registrar
•	
  IL	
  Removal
•	
  Packaging
•	
  Deploy	
  apps
•	
  Install	
  apps
.dll
C#
.exe
+ =
.app
Devices : Build Configurations
• Debug : Keep it quick
• Release : Focus on performance
LLVM Optimizing Compiler
Optimize PNG files
• Ad-Hoc / AppStore : No tweaks!
Build & Deploy Symbiosis
• Deployment time is a function of the app size
• Application size versus build time?
• Link SDK is default for devices
Devices : What to Do?
best
default 16
14
49
16 Build Time
Deploy Time
• Build
Avoid optimizing PNG files (debug)
• Consider
Linking all assemblies --linkall
Disabling the symbols creation --dsym=false
Devices : What to Avoid?
best
worse 37
14
169
16 Build Time
Deploy Time
• FAT binaries (debug)
• Disabling the linker --nolink
• Disabling stripping
Symbols --nosymbolstrip
IL (release) --nostrip
Devices : Extra Tips
• Prefer Build over Rebuild
AOT’ed assemblies (object files) are cached
• Avoid deploying large static files (debug)
Use UIFileSharingEnabled (Info.plist)
• Use -­‐time	
  -­‐time to measure your changes
-­‐time	
  -­‐time -­‐dsym=false
Beyond Build Tips
It’s a Matter of Time and Size
Don’t Link
Link SDK
Link All 9
10
20
21
23
89
Build Time Deploy Time
48.6 MB
11.5 MB
10.9 MB
Field	
  Service	
  Sample	
  Applica8on*
*	
  Release	
  build,	
  LLVM,	
  ARMv7
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Static Analysis Limitations
...
using	
  FieldService.Utilities;
#if	
  __iOS__
using	
  MonoTouch.Foundation;	
  
#elif	
  __ANDROID__
using	
  Android.Runtime;
#endif
namespace	
  FieldService.Data	
  {
	
  	
  	
  	
  ///	
  <summary>An	
  assignment	
  is	
  the	
  "thing"	
  or	
  "job"	
  the	
  user	
  is	
  going...
#if	
  !MOBILE
	
  	
  	
  	
  [Preserve	
  (AllMembers	
  =	
  true)]
#endif
	
  	
  	
  	
  public	
  class	
  Assignment	
  {
	
  	
  	
  	
  	
  	
  	
  	
  ...
	
  	
  	
  	
  }
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Static Analysis Limitations
<!-­‐-­‐	
  add	
  `-­‐-­‐xml=field.service.xml`	
  to	
  your	
  project	
  options	
  -­‐-­‐>
<linker>
	
  	
  	
  	
  <assembly	
  fullname="FieldServiceiOS">
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Assignment"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.AssignmentHistory"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.AssignmentItem"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Document"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Expense"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.ExpensePhoto"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Preserve"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Labor"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Photo"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.Signature"	
  />
	
  	
  	
  	
  	
  	
  	
  	
  <type	
  fullname="FieldService.Data.TimeEntry"	
  />
	
  	
  	
  	
  </assembly>
</linker>
Partially Linking Applications
• Link All and skip some assemblies
No source required
e.g. -­‐-­‐linkall	
  -­‐-­‐linkskip=FieldServiceiOS
• Link SDK and use [LinkerSafe] attribute
Source code required
Objective-C Bindings
• Cocos2d’s Jumpy saves 409 KB using
[assembly:LinkerSafe]
• Less [Export] means faster registration
SmartLink
• New option [LinkWith	
  (SmartLink=true)]
and -­‐-­‐registrar=static
• Helps the native linker
DropBox’s Sync samples drops by 325KB
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
[Export	
  ("sizeToFit")]
void	
  SizeToFit	
  ();
[Export	
  ("sizeToFit")]
[CompilerGenerated]
public	
  virtual	
  void	
  SizeToFit	
  ()
{
	
  	
  	
  	
  global::MonoTouch.UIKit.UIApplication.EnsureUIThread	
  ();
	
  	
  	
  	
  if	
  (IsDirectBinding)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.void_objc_msgSend	
  (this.Handle,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Selector.GetHandle	
  ("sizeToFit"));
	
  	
  	
  	
  }	
  else	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.void_objc_msgSendSuper	
  (this.SuperHandle,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Selector.GetHandle	
  ("sizeToFit"));
	
  	
  	
  	
  }
}
Automatic Bindings Optimizations
[Export	
  ("sizeToFit")]
void	
  SizeToFit	
  ();
[Export	
  ("sizeToFit")]
[CompilerGenerated]
public	
  virtual	
  void	
  SizeToFit	
  ()
{
	
  	
  	
  	
  global::MonoTouch.UIKit.UIApplication.EnsureUIThread	
  ();
	
  	
  	
  	
  if	
  (IsDirectBinding)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.void_objc_msgSend	
  (this.Handle,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Selector.GetHandle	
  ("sizeToFit"));
	
  	
  	
  	
  }	
  else	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.void_objc_msgSendSuper	
  (this.SuperHandle,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Selector.GetHandle	
  ("sizeToFit"));
	
  	
  	
  	
  }
}
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
System.Drawing.SizeF	
  ret;
if	
  (IsDirectBinding)	
  {
	
  	
  	
  	
  if	
  (Runtime.Arch	
  ==	
  Arch.DEVICE)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  	
  Messaging.SizeF_objc_msgSend_stret	
  (out	
  ret,	
  this.Handle,	
  ...
	
  	
  	
  	
  }	
  else	
  {
	
   	
   	
   	
   	
   ret	
  =	
  Messaging.SizeF_objc_msgSend	
  (this.Handle,	
  ...
	
  	
  	
  	
  }
}	
  else	
  {
	
  	
  	
  	
  if	
  (Runtime.Arch	
  ==	
  Arch.DEVICE)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.SizeF_objc_msgSendSuper_stret	
  (out	
  ret,	
  ...
	
  	
  	
  	
  }	
  else	
  {
	
  	
  	
  	
  	
  	
  	
  	
  ret	
  =	
  Messaging.SizeF_objc_msgSendSuper	
  (this.SuperHandle,	
  ...
	
  	
  	
  	
  }
}
return	
  ret;
Automatic Bindings Optimizations
System.Drawing.SizeF	
  ret;
if	
  (IsDirectBinding)	
  {
	
  	
  	
  	
  if	
  (Runtime.Arch	
  ==	
  Arch.DEVICE)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  	
  Messaging.SizeF_objc_msgSend_stret	
  (out	
  ret,	
  this.Handle,	
  ...
	
  	
  	
  	
  }	
  else	
  {
	
   	
   	
   	
   	
   ret	
  =	
  Messaging.SizeF_objc_msgSend	
  (this.Handle,	
  ...
	
  	
  	
  	
  }
}	
  else	
  {
	
  	
  	
  	
  if	
  (Runtime.Arch	
  ==	
  Arch.DEVICE)	
  {
	
  	
  	
  	
  	
  	
  	
  	
  Messaging.SizeF_objc_msgSendSuper_stret	
  (out	
  ret,	
  ...
	
  	
  	
  	
  }	
  else	
  {
	
  	
  	
  	
  	
  	
  	
  	
  ret	
  =	
  Messaging.SizeF_objc_msgSendSuper	
  (this.SuperHandle,	
  ...
	
  	
  	
  	
  }
}
return	
  ret;
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
Automatic Bindings Optimizations
object	
  __mt_RootViewController_var;
[CompilerGenerated]
public	
  virtual	
  UIViewController	
  RootViewController	
  {
	
   	
   [Export	
  ("rootViewController",	
  ArgumentSemantic.Retain)]
	
   	
   get	
  {
	
   	
   	
   	
   global::MonoTouch.UIKit.UIApplication.EnsureUIThread	
  ();
	
   	
   	
   	
   UIViewController	
  ret;
	
   	
   	
   	
   if	
  (IsDirectBinding)	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSend	
  ...);	
  
	
   	
   	
   	
   }	
  else	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSendSuper	
  ...);
	
   	
   	
   	
   }
	
   	
   	
   	
   if	
  (!IsNewRefcountEnabled	
  ())
	
   	
   	
   	
   	
   __mt_RootViewController_var	
  =	
  ret;
	
  	
  	
  	
  	
  	
  return	
  ret;
	
  	
  	
  }
...
object	
  __mt_RootViewController_var;
[CompilerGenerated]
public	
  virtual	
  UIViewController	
  RootViewController	
  {
	
   	
   [Export	
  ("rootViewController",	
  ArgumentSemantic.Retain)]
	
   	
   get	
  {
	
   	
   	
   	
   global::MonoTouch.UIKit.UIApplication.EnsureUIThread	
  ();
	
   	
   	
   	
   UIViewController	
  ret;
	
   	
   	
   	
   if	
  (IsDirectBinding)	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSend	
  ...);	
  
	
   	
   	
   	
   }	
  else	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSendSuper	
  ...);
	
   	
   	
   	
   }
	
   	
   	
   	
   if	
  (!IsNewRefcountEnabled	
  ())
	
   	
   	
   	
   	
   __mt_RootViewController_var	
  =	
  ret;
	
  	
  	
  	
  	
  	
  return	
  ret;
	
  	
  	
  }
...
object	
  __mt_RootViewController_var;
[CompilerGenerated]
public	
  virtual	
  UIViewController	
  RootViewController	
  {
	
   	
   [Export	
  ("rootViewController",	
  ArgumentSemantic.Retain)]
	
   	
   get	
  {
	
   	
   	
   	
   global::MonoTouch.UIKit.UIApplication.EnsureUIThread	
  ();
	
   	
   	
   	
   UIViewController	
  ret;
	
   	
   	
   	
   if	
  (IsDirectBinding)	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSend	
  ...);	
  
	
   	
   	
   	
   }	
  else	
  {
	
   	
   	
   	
   	
   ret	
  =	
  (UIViewController)	
  Runtime.GetNSObject	
  (...	
  msgSendSuper	
  ...);
	
   	
   	
   	
   }
	
   	
   	
   	
   if	
  (!IsNewRefcountEnabled	
  ())
	
   	
   	
   	
   	
   __mt_RootViewController_var	
  =	
  ret;
	
  	
  	
  	
  	
  	
  return	
  ret;
	
  	
  	
  }
...
Quicker builds
Smaller apps
Faster apps
Q&A
THANK YOU
related links @ http://bit.ly/ios-build

More Related Content

What's hot

PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
PyCon US 2012 - Web Server Bottlenecks and Performance TuningPyCon US 2012 - Web Server Bottlenecks and Performance Tuning
PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
Graham Dumpleton
 

What's hot (20)

PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
PyCon US 2012 - Web Server Bottlenecks and Performance TuningPyCon US 2012 - Web Server Bottlenecks and Performance Tuning
PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
 
Distributed automation selcamp2016
Distributed automation selcamp2016Distributed automation selcamp2016
Distributed automation selcamp2016
 
Managing Puppet using MCollective
Managing Puppet using MCollectiveManaging Puppet using MCollective
Managing Puppet using MCollective
 
Building Docker images with Puppet
Building Docker images with PuppetBuilding Docker images with Puppet
Building Docker images with Puppet
 
Weird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack NeutronWeird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack Neutron
 
SaltConf14 - Eric johnson, Google - Orchestrating Google Compute Engine with ...
SaltConf14 - Eric johnson, Google - Orchestrating Google Compute Engine with ...SaltConf14 - Eric johnson, Google - Orchestrating Google Compute Engine with ...
SaltConf14 - Eric johnson, Google - Orchestrating Google Compute Engine with ...
 
Advanced VCL: how to use restart
Advanced VCL: how to use restartAdvanced VCL: how to use restart
Advanced VCL: how to use restart
 
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
Deploying VMware vCloud Hybrid Service with Puppet - PuppetConf 2013
 
Divolte Collector - meetup presentation
Divolte Collector - meetup presentationDivolte Collector - meetup presentation
Divolte Collector - meetup presentation
 
Prototyping online ML with Divolte Collector
Prototyping online ML with Divolte CollectorPrototyping online ML with Divolte Collector
Prototyping online ML with Divolte Collector
 
Divolte collector overview
Divolte collector overviewDivolte collector overview
Divolte collector overview
 
Puppet Camp London Fall 2015 - Service Discovery and Puppet
Puppet Camp London Fall 2015 - Service Discovery and PuppetPuppet Camp London Fall 2015 - Service Discovery and Puppet
Puppet Camp London Fall 2015 - Service Discovery and Puppet
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECS
 
vBACD - Introduction to Opscode Chef - 2/29
vBACD - Introduction to Opscode Chef - 2/29vBACD - Introduction to Opscode Chef - 2/29
vBACD - Introduction to Opscode Chef - 2/29
 
Infrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to TerraformInfrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to Terraform
 
OpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvmOpenShift4 Installation by UPI on kvm
OpenShift4 Installation by UPI on kvm
 
Webinar: Agile Network Deployment
Webinar: Agile Network DeploymentWebinar: Agile Network Deployment
Webinar: Agile Network Deployment
 
How NOT to write in Node.js
How NOT to write in Node.jsHow NOT to write in Node.js
How NOT to write in Node.js
 
Ansible best practices
Ansible best practicesAnsible best practices
Ansible best practices
 

Viewers also liked

Viewers also liked (15)

Модульное приложение на Xamarin. От идеи до реализации.
Модульное приложение на Xamarin. От идеи до реализации.Модульное приложение на Xamarin. От идеи до реализации.
Модульное приложение на Xamarin. От идеи до реализации.
 
Holy Sutura.1-4.Mini.Series.html.doc.docx
Holy Sutura.1-4.Mini.Series.html.doc.docx Holy Sutura.1-4.Mini.Series.html.doc.docx
Holy Sutura.1-4.Mini.Series.html.doc.docx
 
Relatos tan duros como necesarios de escuchar
Relatos tan duros como necesarios de escucharRelatos tan duros como necesarios de escuchar
Relatos tan duros como necesarios de escuchar
 
Decreto lei n.º 396 2007, de 31 de dezembro-cnq
Decreto lei n.º 396 2007, de 31 de dezembro-cnqDecreto lei n.º 396 2007, de 31 de dezembro-cnq
Decreto lei n.º 396 2007, de 31 de dezembro-cnq
 
Hematologia minimanual cto
Hematologia   minimanual ctoHematologia   minimanual cto
Hematologia minimanual cto
 
Urīnpūšļa rekonstruktīvā-ķirurģija
Urīnpūšļa rekonstruktīvā-ķirurģijaUrīnpūšļa rekonstruktīvā-ķirurģija
Urīnpūšļa rekonstruktīvā-ķirurģija
 
Neiroendokrīni aizkuņģa dziedzera audzēji - insulinomas, gastrinomas
Neiroendokrīni aizkuņģa dziedzera audzēji - insulinomas, gastrinomasNeiroendokrīni aizkuņģa dziedzera audzēji - insulinomas, gastrinomas
Neiroendokrīni aizkuņģa dziedzera audzēji - insulinomas, gastrinomas
 
Amoura's sura.1 4.mini.series.html.doc
Amoura's sura.1 4.mini.series.html.docAmoura's sura.1 4.mini.series.html.doc
Amoura's sura.1 4.mini.series.html.doc
 
VAMPIRES
VAMPIRESVAMPIRES
VAMPIRES
 
Materiales reciclados
Materiales recicladosMateriales reciclados
Materiales reciclados
 
MyCrowdCompany - @Work
MyCrowdCompany - @Work MyCrowdCompany - @Work
MyCrowdCompany - @Work
 
Introduction to knime
Introduction to knimeIntroduction to knime
Introduction to knime
 
Secuencias temporales
Secuencias temporales Secuencias temporales
Secuencias temporales
 
Reinforcing AML systems with graph technologies.
Reinforcing AML systems with graph technologies.Reinforcing AML systems with graph technologies.
Reinforcing AML systems with graph technologies.
 
El enfoque de sistemas ha ido evolucionando con el tiempo
El enfoque de sistemas ha ido evolucionando con el tiempoEl enfoque de sistemas ha ido evolucionando con el tiempo
El enfoque de sistemas ha ido evolucionando con el tiempo
 

Similar to Advanced iOS Build Mechanics, Sebastien Pouliot

High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
Niti Chotkaew
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
Julien Lecomte
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - Introduction
Plain Concepts
 

Similar to Advanced iOS Build Mechanics, Sebastien Pouliot (20)

Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
 
Threads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOSThreads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOS
 
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
Lessons Learned Running InfluxDB Cloud and Other Cloud Services at Scale by T...
 
(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
El camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - IntroductionEl camino a las Cloud Native Apps - Introduction
El camino a las Cloud Native Apps - Introduction
 
Node azure
Node azureNode azure
Node azure
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
Lessons Learned: Running InfluxDB Cloud and Other Cloud Services at Scale | T...
 
NHibernate Configuration Patterns
NHibernate Configuration PatternsNHibernate Configuration Patterns
NHibernate Configuration Patterns
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecture
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 

More from Xamarin

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

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 

Advanced iOS Build Mechanics, Sebastien Pouliot

  • 1. Sébastien Pouliot So!ware Developer Xamarin sebastien@xamarin.com Advanced iOS build mechanics Improving performance and reducing executable size
  • 2. Why Should You Care? Quicker Builds Smaller Applications Faster Applications
  • 4. Best Default Worse 14 7 2 27 19 6 How Much Time? Field Service Sample Build Time (Debug) Deploy Time Best Default Worse 37 16 14 169 49 16 Simulator Devices
  • 5. Building for the iOS Simulator .dll C# .exe + = .app addin mtouch •Resolve •Package •Embed  mono •Deploy ?
  • 6. Simulator vs Emulator • Speed Over Compatibility • Apple Simulator Tradeoffs Simpler, less restrictive environment • Xamarin Simulator Tradeoffs Just In Time (JIT) compiler Minimize files copying (symlinks) Shared application launcher
  • 7. Simulator : What to Do? best default 7 2 19 6 Build Time Deploy Time • Build Avoid optimizing PNG files • Deploy Keep the simulator running
  • 8. Simulator : What to Avoid? best worse 14 2 27 6 Build Time Deploy Time • Build Enabling the linker Disabling the shared launcher -­‐-­‐nofastsim • Deploy Up to 12 seconds to cold start
  • 9. Simulator : Extra Tips • Prefer Build over Rebuild • Avoid copying files Access them from a single location The sandbox is not enforced • Use -­‐time  -­‐time to measure your changes
  • 11. Building for iOS Devices •Resolve •Global  Op8miza8ons •AOT  Compila8on •Na8ve  Compila8on •Na8ve  Linking •Copy  files •Op8mize  PNG •En8tlements •Code  sign •IPA •Symbols  (DWARF) •Stripping  (symbols) •Stripping  (IL) •Packaging •Deployment .dll C# .exe + = ? .app
  • 12. Building for iOS Devices addin mtouch •  Resolve •  Managed  Linking •  AOT  Compila8on •  Na8ve  Compila8on •  Na8ve  Linking •  Symbols  (DWARF) •  Copy  files •  Op8mize  PNG •  Provisioning •  En8tlements •  Code  sign •  IPA •  Stripping •  Registrar •  IL  Removal •  Packaging •  Deploy  apps •  Install  apps .dll C# .exe + = .app
  • 13. Devices : Build Configurations • Debug : Keep it quick • Release : Focus on performance LLVM Optimizing Compiler Optimize PNG files • Ad-Hoc / AppStore : No tweaks!
  • 14. Build & Deploy Symbiosis • Deployment time is a function of the app size • Application size versus build time? • Link SDK is default for devices
  • 15. Devices : What to Do? best default 16 14 49 16 Build Time Deploy Time • Build Avoid optimizing PNG files (debug) • Consider Linking all assemblies --linkall Disabling the symbols creation --dsym=false
  • 16. Devices : What to Avoid? best worse 37 14 169 16 Build Time Deploy Time • FAT binaries (debug) • Disabling the linker --nolink • Disabling stripping Symbols --nosymbolstrip IL (release) --nostrip
  • 17. Devices : Extra Tips • Prefer Build over Rebuild AOT’ed assemblies (object files) are cached • Avoid deploying large static files (debug) Use UIFileSharingEnabled (Info.plist) • Use -­‐time  -­‐time to measure your changes
  • 19.
  • 21. It’s a Matter of Time and Size Don’t Link Link SDK Link All 9 10 20 21 23 89 Build Time Deploy Time 48.6 MB 11.5 MB 10.9 MB Field  Service  Sample  Applica8on* *  Release  build,  LLVM,  ARMv7
  • 22. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Static Analysis Limitations ... using  FieldService.Utilities; #if  __iOS__ using  MonoTouch.Foundation;   #elif  __ANDROID__ using  Android.Runtime; #endif namespace  FieldService.Data  {        ///  <summary>An  assignment  is  the  "thing"  or  "job"  the  user  is  going... #if  !MOBILE        [Preserve  (AllMembers  =  true)] #endif        public  class  Assignment  {                ...        }
  • 23. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Static Analysis Limitations <!-­‐-­‐  add  `-­‐-­‐xml=field.service.xml`  to  your  project  options  -­‐-­‐> <linker>        <assembly  fullname="FieldServiceiOS">                <type  fullname="FieldService.Data.Assignment"  />                <type  fullname="FieldService.Data.AssignmentHistory"  />                <type  fullname="FieldService.Data.AssignmentItem"  />                <type  fullname="FieldService.Data.Document"  />                <type  fullname="FieldService.Data.Expense"  />                <type  fullname="FieldService.Data.ExpensePhoto"  />                <type  fullname="FieldService.Data.Preserve"  />                <type  fullname="FieldService.Data.Labor"  />                <type  fullname="FieldService.Data.Photo"  />                <type  fullname="FieldService.Data.Signature"  />                <type  fullname="FieldService.Data.TimeEntry"  />        </assembly> </linker>
  • 24. Partially Linking Applications • Link All and skip some assemblies No source required e.g. -­‐-­‐linkall  -­‐-­‐linkskip=FieldServiceiOS • Link SDK and use [LinkerSafe] attribute Source code required
  • 25. Objective-C Bindings • Cocos2d’s Jumpy saves 409 KB using [assembly:LinkerSafe] • Less [Export] means faster registration
  • 26. SmartLink • New option [LinkWith  (SmartLink=true)] and -­‐-­‐registrar=static • Helps the native linker DropBox’s Sync samples drops by 325KB
  • 27. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 [Export  ("sizeToFit")] void  SizeToFit  (); [Export  ("sizeToFit")] [CompilerGenerated] public  virtual  void  SizeToFit  () {        global::MonoTouch.UIKit.UIApplication.EnsureUIThread  ();        if  (IsDirectBinding)  {                Messaging.void_objc_msgSend  (this.Handle,                          Selector.GetHandle  ("sizeToFit"));        }  else  {                Messaging.void_objc_msgSendSuper  (this.SuperHandle,                          Selector.GetHandle  ("sizeToFit"));        } } Automatic Bindings Optimizations [Export  ("sizeToFit")] void  SizeToFit  (); [Export  ("sizeToFit")] [CompilerGenerated] public  virtual  void  SizeToFit  () {        global::MonoTouch.UIKit.UIApplication.EnsureUIThread  ();        if  (IsDirectBinding)  {                Messaging.void_objc_msgSend  (this.Handle,                          Selector.GetHandle  ("sizeToFit"));        }  else  {                Messaging.void_objc_msgSendSuper  (this.SuperHandle,                          Selector.GetHandle  ("sizeToFit"));        } }
  • 28. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 System.Drawing.SizeF  ret; if  (IsDirectBinding)  {        if  (Runtime.Arch  ==  Arch.DEVICE)  {                  Messaging.SizeF_objc_msgSend_stret  (out  ret,  this.Handle,  ...        }  else  {           ret  =  Messaging.SizeF_objc_msgSend  (this.Handle,  ...        } }  else  {        if  (Runtime.Arch  ==  Arch.DEVICE)  {                Messaging.SizeF_objc_msgSendSuper_stret  (out  ret,  ...        }  else  {                ret  =  Messaging.SizeF_objc_msgSendSuper  (this.SuperHandle,  ...        } } return  ret; Automatic Bindings Optimizations System.Drawing.SizeF  ret; if  (IsDirectBinding)  {        if  (Runtime.Arch  ==  Arch.DEVICE)  {                  Messaging.SizeF_objc_msgSend_stret  (out  ret,  this.Handle,  ...        }  else  {           ret  =  Messaging.SizeF_objc_msgSend  (this.Handle,  ...        } }  else  {        if  (Runtime.Arch  ==  Arch.DEVICE)  {                Messaging.SizeF_objc_msgSendSuper_stret  (out  ret,  ...        }  else  {                ret  =  Messaging.SizeF_objc_msgSendSuper  (this.SuperHandle,  ...        } } return  ret;
  • 29. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Automatic Bindings Optimizations object  __mt_RootViewController_var; [CompilerGenerated] public  virtual  UIViewController  RootViewController  {     [Export  ("rootViewController",  ArgumentSemantic.Retain)]     get  {         global::MonoTouch.UIKit.UIApplication.EnsureUIThread  ();         UIViewController  ret;         if  (IsDirectBinding)  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSend  ...);           }  else  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSendSuper  ...);         }         if  (!IsNewRefcountEnabled  ())           __mt_RootViewController_var  =  ret;            return  ret;      } ... object  __mt_RootViewController_var; [CompilerGenerated] public  virtual  UIViewController  RootViewController  {     [Export  ("rootViewController",  ArgumentSemantic.Retain)]     get  {         global::MonoTouch.UIKit.UIApplication.EnsureUIThread  ();         UIViewController  ret;         if  (IsDirectBinding)  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSend  ...);           }  else  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSendSuper  ...);         }         if  (!IsNewRefcountEnabled  ())           __mt_RootViewController_var  =  ret;            return  ret;      } ... object  __mt_RootViewController_var; [CompilerGenerated] public  virtual  UIViewController  RootViewController  {     [Export  ("rootViewController",  ArgumentSemantic.Retain)]     get  {         global::MonoTouch.UIKit.UIApplication.EnsureUIThread  ();         UIViewController  ret;         if  (IsDirectBinding)  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSend  ...);           }  else  {           ret  =  (UIViewController)  Runtime.GetNSObject  (...  msgSendSuper  ...);         }         if  (!IsNewRefcountEnabled  ())           __mt_RootViewController_var  =  ret;            return  ret;      } ...
  • 31. Q&A
  • 32. THANK YOU related links @ http://bit.ly/ios-build