← Nesim Apps

Kotlin/Native and Swift: The 'Different Argument Labels' Error

By Nesim Razon, independent mobile developer · 2026-11-26

#iOS#Dev notes#Tools and calculators

Everything compiled on Android. Then the iOS build died with a Swift error about argument labels, and the label it complained about had an odd trailing underscore. This post explains what happened in three of our Kotlin Multiplatform apps, the exact condition that triggers it, the exact condition that does not, and the cheap way to avoid it for good.

The error that only shows up on a Mac

On the first iOS builds of a small utility app, the Kotlin side compiled without complaint and the Swift side did not. The build ran on a cloud Mac, so there was nothing to poke at locally. The message said that two things had different argument labels, and the method it pointed at was showInterstitial. Swift expected a label written onDone with a trailing underscore, while our Swift code had written it plainly, as onDone.

A trailing underscore in a label is the kind of detail you only notice when you stare at the log for a while. It turned out to be the whole story.

The setup that triggers it

Our shared code has an interface called Ads. Screens only know that interface. It has a method showInterstitial that takes a callback named onDone, and it returns nothing. On iOS there is a second interface, written in Kotlin and exported to Swift as a protocol, called IosNativeServices. The Swift app implements it, because ad and consent calls must happen in native Swift.

In the first version of that protocol we gave the native method the most natural name there was: showInterstitial, with the same onDone callback. But the native one returned a Boolean, true if an ad was ready and false if not, so the shared code could continue straight away when there was nothing to show. So two exported Kotlin types now carried a method with the same name and the same parameter, but a different return type.

The rule, as we have it documented

This is the part we want to be precise about, because we got it wrong at first. Our iOS notes say it plainly. If the two methods have the same name and the same signature, nothing happens. If the name is the same but the signature differs, Swift expects the label with the underscore and reports different argument labels.

We have both cases in real apps. In the age calculator, the BMI calculator and the earthquake app, the interface method returned nothing and the native method returned a Boolean. Those three failed. In our lucky-games app, both the interface and the native protocol declared the very same method, showInterstitial taking onDone and returning a Boolean. That one compiled fine and kept its original names.

How we first wrote it down, and the correction

Our first note after the failure was too broad: it said that a same-named method with a parameter in both types will break. It was a reasonable guess from three failures in a row, and we even taught our pre-build check to warn on any shared name.

Two days later, looking at the lucky-games app, which had been fine all along, we corrected the note. The failure needs a difference in the signature. The check was changed to compare the full signature, parameters and return type, and to warn only when the names match and the signatures do not. If you take one thing from this post, take that: the name alone is not the trigger.

What we do not claim

We did not read the compiler to prove why the underscore appears. What we observed is a pattern: same signature, fine; different signature, error. Our best reading is that Kotlin exports both methods to Swift under one shared Objective-C style name, and when their shapes disagree the generated Swift names stop lining up. That is an explanation, not a verified fact, and it may depend on the Kotlin version.

We also only tested the case where the difference is in the return type. We did not try a different parameter type or a different parameter count, so we cannot say how those behave. If you need a guarantee, the next section gives you one that does not depend on any of this.

The fix: give them different names

The fix is not clever. Rename the native method. The interface keeps showInterstitial. The native protocol now says showInterstitialAd. Nothing else changes in the logic: the Kotlin side of the iOS platform class implements the interface method and simply calls the native one, and if the native one says no ad is ready, it calls the callback itself so the player is not stuck.

In Swift the method became showInterstitialAd with onDone marked as escaping, returning true when it presented an ad. We applied the rename to the three affected apps. A newer game of ours, with a native method that returns nothing, used the distinct name from the start.

Why the native method returns a Boolean at all

It is fair to ask why we did not simply make both methods return nothing. The reason is the ad itself. Showing a full-screen ad on iPhone is asynchronous. The native code presents the ad and calls our callback only after the player closes it. If no ad is ready, there is nothing to close, so the callback would never fire and the player would wait forever.

So the native method answers a yes or no question first. True means an ad is on screen and the callback will come later. False means nothing was shown and the callback will not be called. The Kotlin side reads that answer and, on false, continues by itself. That small contract is useful, and it is the reason the two signatures differed in the first place.

What our pre-build check actually looks at

The check is a short Python script that runs before we upload anything to the cloud Mac. It reads the two Kotlin files, pulls out every function that has at least one named parameter, squeezes the whitespace in each signature, and compares the texts for names that appear in both files. A match with different text is reported as an error.

It is a text comparison, not a real parser, so it can miss odd formatting, and it ignores functions without parameters. For our small, regular files that has been enough. It has caught the mistake for us on a laptop in seconds, which is all we ever wanted from it.

Could we have matched the signatures instead?

In principle, yes: make the interface method return a Boolean too, and the two would be identical, like in the lucky-games app. We did not try that on the three failing apps. It would have changed a shared interface that many screens and an Android implementation depend on, just to satisfy a naming quirk on one platform.

Renaming one native method touched three small files and nothing that Android ever sees. For us that was the safer trade, and it holds even if your build behaves differently from ours.

A short checklist for your own project

A habit that avoids the whole class

The general lesson is cheap. Whenever a Kotlin interface that Swift will see, and another exported type, could both want a method with the same name, make the names different on purpose. Prefix or suffix them by role. The native side can say what it does at the platform level, an Ad suffix here, and the shared interface can keep its short name.

We also keep the signature check in our iOS pre-build script, so the mistake shows up on a Windows laptop in a second instead of in a cloud log twenty minutes later. A trailing underscore in an argument label is not something you want to discover that way.

Frequently asked questions

What does 'different argument labels' mean in a Kotlin Multiplatform iOS build?

Swift found two methods that it sees as one but whose labels disagree. In our apps the label came out as onDone with a trailing underscore, so the plain Swift version no longer matched.

Does a same-named method always break the build?

No. In our notes, a method with the same name and the same signature in two exported types compiled fine. The failures happened when the signatures differed, in our case the return type.

What is the simplest fix?

Give the native protocol method a different name, for example showInterstitialAd instead of showInterstitial, and update the Swift implementation to match.

Can I catch it before the iOS build?

Yes. A small script that lists the function names and signatures of both Kotlin files and warns when a name matches but the signature differs catches it on any machine.

More from the blog