{"id":6153,"date":"2013-07-29T12:22:26","date_gmt":"2013-07-29T16:22:26","guid":{"rendered":"http:\/\/blog.xamarin.com\/?p=6153"},"modified":"2013-07-29T12:22:26","modified_gmt":"2013-07-29T16:22:26","slug":"xamarin-ios-build-improvements","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/xamarin-ios-build-improvements\/","title":{"rendered":"Xamarin.iOS Build Improvements"},"content":{"rendered":"<p dir=\"ltr\">One of the biggest improvements in the <a href=\"\/major-upgrades-to-xamarin\u2019s-platform-async-is-here\/\" title=\"Xamarin release last week\">Xamarin release last week<\/a> is significantly faster build time for Xamarin.iOS apps. \u00a0We thoroughly analyzed the build process and identified several areas of improvement. \u00a0Here are the results.<\/p>\n<p dir=\"ltr\"><a href=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/a.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-6756\" alt=\"Build speed improvements in Xamarin.iOS\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/a.png\" width=\"595\" height=\"272\" \/><\/a><\/p>\n<p dir=\"ltr\">We tested these changes both with Hello World and a large application made up of 160,000 lines of code, and these are the results after making a one line change:<\/p>\n<ul>\n<li>\n<p dir=\"ltr\">Hello World, build, deploy and starts in 10 seconds (vs 15 seconds before)<\/p>\n<\/li>\n<li>\n<p dir=\"ltr\">Large solution, build, deploys and starts in 24 seconds (vs 75 seconds before).<\/p>\n<\/li>\n<\/ul>\n<p dir=\"ltr\">This is the result of a series of optimizations. This blog post explains those optimizations and what steps you need to take to enable this mode.<\/p>\n<p dir=\"ltr\"><strong>Build Caching<\/strong><\/p>\n<p dir=\"ltr\">We are now caching every partial build file, which makes it possible to only rebuild the parts of your project that has been modified.<b><b>\u00a0<\/b><\/b><\/p>\n<p dir=\"ltr\"><strong>Incremental Deployment<\/strong><b><b>\u00a0<\/b><\/b><\/p>\n<p dir=\"ltr\">Instead of uploading your entire application on every build to your device, only the modified bits of it are sent to the device. If you have many rarely modified resources in your app, we will not deploy those resources to the device every time the app is rebuilt, only the first time. The savings here are project dependent, but the minimum deploy time can now be as small as one second.<\/p>\n<p dir=\"ltr\"><a href=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/b.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-6757\" alt=\"Build Cache and Incremental Deployment\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/b.png\" width=\"595\" height=\"275\" \/><\/a><\/p>\n<p dir=\"ltr\"><strong>Incremental Builds<\/strong><\/p>\n<p dir=\"ltr\">Usually in iOS all the native code is contained within one file, the main executable. This means that no matter how small your change was, we would always rebuild, relink and end up with a new executable that must be uploaded.<\/p>\n<p dir=\"ltr\">For big projects with a lot of code this posed a problem &#8211; the size of the native executable caused deploy time to suffer significantly, even with the incremental deploys mentioned above.<\/p>\n<p dir=\"ltr\">So in the next version of Xamarin.iOS we\u2019re introducing incremental builds and deployments &#8211; this is a compilation mode where each assembly is compiled into a separate shared library. When this is enabled, a change in one assembly will only require the native code for that assembly to be uploaded, which will significantly reduce the amount of data that has to be deployed to a device for each build.<b><b>\u00a0<\/b><\/b><\/p>\n<p dir=\"ltr\"><b><b><a href=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/c.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-6758\" alt=\"Incremental Build\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/c.png\" width=\"594\" height=\"272\" \/><\/a>\u00a0<\/b><\/b><\/p>\n<p dir=\"ltr\">To use incremental builds effectively, you must:<\/p>\n<ul>\n<li>\n<p dir=\"ltr\">Enable incremental builds<\/p>\n<\/li>\n<li>\n<p dir=\"ltr\">Update your linker settings<\/p>\n<\/li>\n<\/ul>\n<p dir=\"ltr\">We discuss these next:<\/p>\n<p dir=\"ltr\"><strong>Enabling incremental build<\/strong>: This setting is not on by default, it has to be enabled first. This is because it is only possible to start the app using Xamarin Studio or Visual Studio when you use this feature. \u00a0If you try running it by tapping on it, it will crash. This means that you should not compile your apps with incremental builds when you want to demo your app.<\/p>\n<p dir=\"ltr\">The next version of Xamarin Studio or the Visual Studio plugin will include a UI to enable this, in the meantime it can be enabled by passing the \u201c&#8211;fastdev\u201d to the additional mtouch arguments in the project\u2019s iOS Build properties. Only set this for your iPhone targets, and not the AppStore targets.<\/p>\n<p dir=\"ltr\"><strong>Update Linker Settings<\/strong>: In previous versions of Xamarin.iOS we\u2019ve recommended you enable the managed linker (either set \u201cLinker behavior\u201d to \u201cLink all assemblies\u201d or \u201cLink SDK only\u201d in the project\u2019s iOS Build options) to get the best build times. The extra time it takes to execute the manager linker far outweighed the time gained by having less managed code to AOT-compile and then less native code to deploy to the device.<\/p>\n<p dir=\"ltr\">With this new build mode, it is best to avoid the linker during development, since this will ensure that your core assemblies remain the same, and reduce the amount of code that needs to be uploaded every time. So you should disable the managed linker, by setting your linker value for development to \u201cDon\u2019t link\u201d. The first build will be slower, but then rebuilds will be faster than with the managed linker enabled.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the biggest improvements in the Xamarin release last week is significantly faster build time for Xamarin.iOS apps. \u00a0We thoroughly analyzed the build process and identified several areas of improvement. \u00a0Here are the results. We tested these changes both with Hello World and a large application made up of 160,000 lines of code, and [&hellip;]<\/p>\n","protected":false},"author":1931,"featured_media":39167,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[6,4],"class_list":["post-6153","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-ios","tag-xamarin-platform"],"acf":[],"blog_post_summary":"<p>One of the biggest improvements in the Xamarin release last week is significantly faster build time for Xamarin.iOS apps. \u00a0We thoroughly analyzed the build process and identified several areas of improvement. \u00a0Here are the results. We tested these changes both with Hello World and a large application made up of 160,000 lines of code, and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/6153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/1931"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=6153"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/6153\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/39167"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=6153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=6153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=6153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}