Forum Xamarin.iOS

Extremely slow builds

DаnDаn USMember ✭✭

Hi,

I have gotten VS2019 up and running and working finally with the Macbook paired. Both the Windows PC and Macbook are reasonably capable machines but I am concerned before suggesting Xamarin for a project because of build times.

Using the single view app template, the I cannot get build and run (in debug) down to less than 21 seconds, even with just the shell app the template creates.

I have switched on device specific builds which shaved off maybe a second or 2 but no big change. Even a tiny code change results in a 21 to 24 second build and run time.

Equivalent native template project in Xcode and Swift will build, deploy and be running in around 3 seconds.

Is this typical and you guys just put up with it or can I get this to a reasonable speed?

Obviously, it will get slower as the project gets bigger and this is my concern.

Thanks!

Best Answer

Answers

  • DаnDаn USMember ✭✭

    Further to this I tried the "Acquaint" example app from github.

    After allowing it to initially build and run which took a while, then running it several times with no code changes I got it down to 6 seconds from hitting F5 to app running. This is still way slower than a native Xcode app but still acceptable.

    But one tiny insignificant code change (adding an unused local variable in a method) build time shot up to a whopping 1 minute 30 seconds from hitting F5 to the app being on-screen.

    Testing with iPhone 8 if that makes any difference.

    Obviously waiting 1 minute 30 seconds or more every time you want to run your app is going to erode away any gains made from some shared code.

    I would love to hear how people working with it every day get on. Or am I doing something wrong with it?

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi @Dan , This document explains the various optimizations that are applied at build time for Xamarin.iOS and Xamarin.Mac apps. You can have a look at that : https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/optimizations

    And there is a Linker Beavior : https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=macos#linker-behavior , Don't Link should be the fast way to build your project .

  • DаnDаn USMember ✭✭
    edited May 1

    Thanks for that, interesting information.

    I tried the "Don't Link" and did several tests. I found it could shave about 8 or 9 seconds off the build time.

    This takes it down to about 1 minute 21 seconds on average (using the same Acquaint example app).

    So moving in the right direction but obviously something is very wrong.

    @JuniorJiang Can you advise what build time you'd expect for an app like Acquaint. From code change to running on physical device?

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai
    edited May 4

    Hi @Dan , Generally speaking, the shorter the start-up time, the better, generally within 3 seconds is acceptable. You can watch this Apple video. The 2.5 second start-up time in the video is not what we expected.

  • DаnDаn USMember ✭✭

    Hi @JuniorJiang

    Thanks for your answer I will have a look at the video shortly as it's rather long.

    From hitting "F5" on a small code change in Visual Studio to the app running on the attached iPhone in 3 seconds sounds great and much more acceptable, but I'm still at well over 1 minute for it to build, deploy and actually launch.

    Since this is a brand new install of Visual Studio 2019 on Windows 10 on an SSD based machine, talking to a fairly new Macbook running dual-core I7 with 16GB of RAM I'm at a loss of what to try next.

    The Mac is running Catalina beta but I can find no references to slow builds being caused by that.

    Any ideas what I might try next to solve it?

  • JohnHJohnH GBMember ✭✭✭✭✭

    As a test you might want to try VS for Mac, if the speed there is comparable to the video then it might be down to your network. I use VS for Mac at home, and VS for Windows in the office. Our office wifi is blindingly quick so the comms between my windows laptop and my MBP gives me pretty good build times, but nothing will beat building directly on the Mac.

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi @Dan ,In fact, the statistics in the video are the startup time of the App, but this is not the entire build time. There is no certain reference standard for the build time of the application temporarily. Because when the project references more and more libraries or third-party code, it will inevitably increase the build time.

  • DаnDаn USMember ✭✭

    Definitely worth a try. I was hoping to use the PC for development and the Mac just as a teathered machine.

    But waiting 1 minute 30 seconds for a build on Windows vs 3 seconds directly on a Mac is a no-brainer!

    I will try the VS for Mac and see if that then works at the proper speed...

  • DаnDаn USMember ✭✭

    Hi JuniorJiang thanks for your reply.

    I appreciate that bringing in additional dependencies and libraries can increase build time. At the moment I'm only using small test apps and examples.

    We have several sizeable commercial iOS apps built in Swift/Xcode and for a small code change there, build-deploy-launch is a few seconds.

    I appreciate Xamarin has additional steps internally, so I could understand it taking a little longer of course.

    I will try VS on the Mac directly...

  • DаnDаn USMember ✭✭

    @JohnH, @JuniorJiang I've done some testing now with interesting results.

    Same project (Acquaint), VS on Mac, tiny code change to one class (adding unused variable), timing the build-deploy-launch cycle.

    On the Mac it takes 34 seconds on average. So still very slow but not as bad as Windows paired to a Mac.

    Existing much larger native projects we have in Xcode will typically take 3 or 4 seconds for a build-deploy-launch after a small code change (i.e. not a full rebuild) on this same Mac and iPhone.

    @JohnH what sort of delay are you typically seeing on your projects?

    Any idea what could be causing it?

  • DаnDаn USMember ✭✭

    As an update to this, I've tried the "Don't Link" option on the Mac.

    It actually seems to make the problem worse, adding a few more seconds to the build... Curious as on the PC it made it a few seconds quicker!

  • JohnHJohnH GBMember ✭✭✭✭✭

    @Dan what architectures are you building for? When building for your own device for debug purposes you only need to set for 1 architecture, the one for the device.

    I mostly build for simulators when debugging which is seconds for small changes, will get you build times for debug devices shortly.

  • DаnDаn USMember ✭✭

    Hi @JohnH

    I've been experimenting with this. The architecture setting does shave a second or 2 off the build time very roughly.

    But if I used the Simulated iPhone 8, builds are not nearly as slow. I managed to get it down to 16 seconds which is perhaps passable. But of course only if we are using a simulator which we tend not to do in my team.

    So we'd have to use Macs instead of PCs and simulators instead of physical devices just to get a reasonable build-deploy-launch time...

    I'm thinking, this is gonna be a hard sell to the team!

  • JohnHJohnH GBMember ✭✭✭✭✭

    Can you try the remote simulator from Windows?

  • JohnHJohnH GBMember ✭✭✭✭✭

    Timings on building a medium/large XF solution on 16" MBP 2.4Ghz 8 core i9, 64gig, targeting iPhone XS physical device from Visual Studio for Mac:
    67 seconds for build on a cleaned solution
    24 seconds to build with a minor change

    Simulator build:
    39 seconds to build on a cleaned solution
    19 seconds to build with a minor change

    I tried again with a newer, smaller project I have been working on:

    Device build:
    57 seconds to build on a cleaned solution
    16 seconds to build with a minor change

    Simulator build:
    12 seconds for build on a cleaned solution
    4 seconds to build with a minor change

    These are build times only and don't include deployment to device and start of debug session.

  • DаnDаn USMember ✭✭

    Hi @JohnH

    Thanks so much for that, really helpful.

    I have tried the Windows Simulator as you suggested. This is not as slow as remote device but still pretty slow for a minor code change.

    The build times alone are useful, but in reality the developer will not just build and will want to run the app, so I've been taking that into account.

    The build-deploy-launch time for Windows running simulator is 38 seconds on average. So not as bad as remote device but still rather poor.

    I'm beginning to feel this is turning into a bit of a damp squib. It's one thing to put forward time saved by some shared code within the projects but to lose it to build times is deflating.

Sign In or Register to comment.