I am wondering why the iOS build time is taking fo...
# multiplatform
h
I am wondering why the iOS build time is taking fore ever! Do you have such a problem? I use Azure to build my Android and iOS apps. I have two stages for Android and iOS builds and each stage has a job to build the variants in parallel. The first attached image shows the time it takes for each job. The iOS builds are much slower than this, sometimes non-prod builds take up to 50 minutes 😢 When I look at the timestamps, the first culprit is:
Copy code
2025-10-07T14:34:46.8112980Z     /bin/sh -c /Users/runner/work/1/build/derived_data/Build/Intermediates.noindex/ArchiveIntermediates/AutoHawk_prod/IntermediateBuildFilesPath/iosApp.build/prod_Release-iphoneos/iosApp.build/Script-6663F42C2DCB6A61001A6D60.sh

2025-10-07T14:48:35.3474740Z Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
This alone takes 14 minutes to be done. The rest in the thread.
This image shows just one task takes 14 minutes
Then this one takes 5 minutes
Then this one adds 13 minutes
I don't see any other gaps after the xcode archive command.
t
Have you applied suggestions from this article: https://kotlinlang.org/docs/native-improving-compilation-time.html?
👀 1
h
Thanks for your prompt reply @tapchicoma
Let me see it.
I added Kotlin Native caching. It had a good effect on the prob build, about 30 minutes less, whereas I don't see a much improvements on non-release builds.
f
That’s something people sometimes talk here; build performance with Kotlin native. But yeah, in fact, Kotlin native take a lot of time for big project. I’m just curious about the common point on all these projects. (number of modules/number or size of the files/umbrella header size/...)
There are some tips for reducing the time or size of a release but I don’t think Kotlin native can be as fast as Swift language (which is also not a really fast 😃)
t
In general we are working on improving native build time but it is huge task and don't expect to see major improvements fast
f
@tapchicoma thanks for your hard work. I’m curious about the criteria who make a build so long general, if you have clue it will be great :).
e
Hi @Hesam, Could you provide a bit more insight what steps you followed to get the improvement you mentioned here?
I added Kotlin Native caching. It had a good effect on the prob build, about 30 minutes less, whereas I don't see a much improvements on non-release builds.
h
Thanks everyone for your messages. Hi @Emil Flach, Nothing so special. I just added a task to my build pipeline to implement the cache/restore functionality, according to the doc shared above. 1. I added these keys into the `variables`:
Copy code
- name: KOTLIN_NATIVE_PATH
    value: "$(HOME)/.konan"
  - name: KOTLIN_NATIVE_CACHE_KEY
    value: 'KN_251007 | "$(Agent.OS)" | **/build.gradle.kts, gradle/libs.versions.toml'
  - name: KOTLIN_NATIVE_RESTORE_KEYS
    value: |
      KN_251007 | $(Agent.OS)
      KN_251007
2. Added the following task to my build pipeline:
Copy code
- task: Cache@2
    displayName: 'Cache Kotlin/Native Compiler Outputs'
    inputs:
      path: $(KOTLIN_NATIVE_PATH)
      key: $(KOTLIN_NATIVE_CACHE_KEY)
      restoreKeys: $(KOTLIN_NATIVE_RESTORE_KEYS)
✅ 1
To me, the actual bottleneck is this task:
./gradlew kmpAutohawkembedAndSignAppleFrameworkForXcode
That comes from the first Xcode/Run Script.
✅ 1
e
Thanks for sharing, I'll pass these insights to the team!
thank you color 1