Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Combine classes with companion objects in Objective C frameworks? #1549

Closed
alastaircoote opened this issue Apr 30, 2018 · 3 comments
Closed

Comments

@alastaircoote
Copy link

I'm just testing out using Kotlin Native to create a cross-platform library, and so far it looks fantastic! One wrinkle, though: when I make an Objective C framework (for use on iOS) it exports MyClass just fine, but also outputs MyClassCompanionObject, with static functions attached.

I understand why that's happening, and in many ways it's the more correct interpretation of the Kotlin code, but it doesn't match any pattern used in Objective C or Swift. Is there any way to combine these two classes to provide static functions on the original class?

@olonho olonho self-assigned this May 13, 2018
@olonho
Copy link
Contributor

olonho commented May 13, 2018

What criteria would you suggest for putting methods out of companion to statics of the Objective-C class?

@damianw
Copy link

damianw commented May 15, 2018

I would suggest an opt-in mechanism, probably something like @JvmStatic but for Objective-C. object (free or companion) members annotated with e.g. @ObjCStatic would cause the compiler to emit a static bridge (on the enclosing class in the case of companion objects, otherwise on the actual object type).

@SvyatoslavScherbina
Copy link
Collaborator

According migration to YouTrack, closing this issue in favour of https://youtrack.jetbrains.com/issue/KT-44862. Please continue any discussions there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants