I've been trying to get to the bottom of this name...
# touchlab-tools
b
I've been trying to get to the bottom of this name collision issue with no luck. Can anyone shed some light on what can possibly be configured incorrectly that is causing this?
> Task :shared:linkDebugFrameworkIosSimulatorArm64
w: 'var IntelyShared.Ktor_httpHttpStatusCode.description' was renamed to 'var IntelyShared.Ktor_httpHttpStatusCode.description_' because of a name collision with an another declaration 'func IntelyShared.KotlinBase.description() -> Swift.String'. Consider resolving the conflict either by changing the name in Kotlin, or via the @ObjCName annotation. You can also suppress this warning using the 'SuppressSkieWarning.NameCollision' configuration. However using renamed declarations from Swift is not recommended because their name will change if the conflict is resolved.
(at public final val description: kotlin.String defined in io.ktor.http.HttpStatusCode from module <io.ktor:ktor-http>)
d
toString()
gets translated to
description
on the iOS side but
HttpStatusCode
has a field named
description
too which needs to then be renamed to
description_
There's nothing configured incorrectly on your side, this exact name collision happens often.
b
@dorche thanks, but I’m curious about other open source Kmp projects that I cloned and built trying to replicate this issue that use SKIE and Ktor and I noticed no name collision warnings and there was not configuration to suppress the name collision
d
Do you have an example? Is HTTPStatusCode actually exported to objc in these projects?
b
@dorche thanks for bringing this up because I looked at what was being exported between mine compared to the other projects and found that my project was exporting it to objc and the others were not. I modified the visibility of some Kotlin declarations which solved this name collision issue. Thanks again
🙌 1
b
@Bijan Cronin would you mind sharing how you figured out which declarations needed visibility modifications. I'm also running into an issue where Ktor is being exported, and I can't figure out how/why.
b
are you getting the same name collision warning or do you just see ktor in the binaries generated?
b
Well, I was getting the same name collision. But I also have another issue with SKIE. I'm using it's "DefaultArgsInterop" feature, and occassionally my ios app build starts failing with all these Ktor errors. I can fix it by disabling that feature, adding default args to every function call relying on them, doing a build, then reenable the feature and remove all the default args. But that is obviously a huge pain. I shouldn't get that error at all though because Ktor shouldn't be exposed to my ios app. But I can't figure how/where it's getting exported.
b
Do you mind sharing any code like you build.gradle and examples of Kotlin code using ktor?
s
@Bradleycorn maybe you have some
public
class that takes input of
HttpClient
or
Engine
or something from ktor in the constructor. If you're
export(ThatModule)
then ktor would be exposed. You want to find all the public class and methods in all exported modules and see if you've
ktor
reference either in constructor, or any method param or return value etc.
maybe use strict explicit api mode that will force you to add
public
keyword in all the classes that you really intend to make public and then it would be easier to find where
ktor
is accidentally getting exposed
Copy code
kotlin {
    explicitApi = ExplicitApiMode.Strict
}
If you're building a library then I would highly suggest to keep this strict mode enable so you've better control over what to make
public
instead of everything is public by default in Kotlin
b
Thanks @shaktiman_droid, I'll look into that. I have checked what I'm exposing previously, and haven't found anything. But I will double check. I'll try the explicit mode as well, that should help track things down.
👍🏽 1
b
I marked everything internal that should not be exposed through the api
s
@Bijan Cronin that's mental overhead to remember everytime, that's where the explict strict api mode helps as it would not let you compile the code without a keyword. you need to explicit add
private/internal/public
b
Copy code
internal actual fun platformModule() =
    module {
        single<HttpClientEngine> { Darwin.create() }
    }
@shaktiman_droid yeah I think that approach make is the best
@Bradleycorn when I marked the platformModule() internal I believe that was the main culprit of the ktor name collision I was having