Can somebody explain "KoinIOSKt.doInitKoinIos()" t...
# touchlab-tools
t
Can somebody explain "KoinIOSKt.doInitKoinIos()" to me? I'm trying to understand the implicit logic that resolves doInitKoinIos to the function initKoinIos. Where is KoinIOSKt defined?
r
Swift/Obj-C treat functions whose name starts with
init
as initializers, so the Kotlin compiler automatically adds a
do
on the front of the function name. Arguably we should rename that function so it’s less confusing.
KoinIosKt
is a prefix/namespace that is implicitly added to top-level functions in the file
KoinIos.kt
. This is similar to the syntax you get with Java interop for top-level functions.
t
Thanks for the explanation. I had searched for both "KoinIosKt" and "doInitKoinIos" in the project and didn't find anything. When searching on Google, I was surprised to see that even Google didn't have any results. I don't remember the last time I saw that. :-)
h
Thank you for the explanation, Russell. I also searched for this on Google and didn’t find anything. It would be helpful to include this detail in the official documentation (Interoperability with Swift/Objective-C). BTW, I noticed that Obj-C attaches special meaning to functions whose name begins with
alloc
,
new
,
copy
,
mutableCopy
as well as
init
(Advanced Memory Management Programming Guide). It appears that the Kotlin compiler automatically adds the prefix
do
to such function names. Can somebody knowledgeable confirm this?