I wrote an SDK that is only comprised of static me...
# multiplatform
s
I wrote an SDK that is only comprised of static methods. At first I had those methods wrapped in objects like this:
Copy code
// File 'Name3.kt'
package name1.name2

object Name3 {
    fun Function1(): String {...}
}
After, I removed the "object" layer, thinking I would simplify client calls. However, when calling my Android/jvm SDK from a Java client, for instance, it looks awkward since Java doesn't support package-level functions. So it looks like this from the Java client:
Copy code
import name1.name2.Name3Kt;

void func() {
    String s = Name3Kt.Function1();
}
Based on that, shouldn't I revert to my 1st solution of having my static functions wrapped in an object, so the client call (in Java) would look like this instead?
Copy code
import name1.name2.Name3Kt; //SDK functions at package-level
import name1.name2.Name3;     //SDK functions at object-level

String s = Name3Kt.Function1(); //SDK functions at package-level
String s = Name3.Function1();     //SDK functions at object-level
d
Use
@file:JvmName("Name3")
👍 1
s
It works well for Android/Jvm clients, but it doesn't solve the "issue" for an iOS consumer. It still remains Name3Kt.function1(). 🙁 Is there a way similar to
@file:JvmName("Name3")
for iOS or should I go back to putting my functions in an
object
named "Name3"?
It looks like even with an
object
named "MyObject" for instance, a call from iOS (Swift for instance) would look like this: MyObject*Kt*.function()
I can't believe there's nothing similar to
@file:JvmName("CustomName")
for iOS. Now when documenting my SDK, I need 2 different APIs for Android and iOS: • Android: MyObjectName.someFunction() • iOS: MyObjectName*Kt*.someFunction() This is really annoying.