-
Notifications
You must be signed in to change notification settings - Fork 564
Objective-C Framework interop headers may contain incorrect code #1447
Comments
Currently this issue is to be workarounded by renaming Kotlin declarations, and we have plans to provide annotation to change Objective-C/Swift name. After that automatic mangling will be disabled at all being considered as bad practice. |
I'm personally not against disabling automatic mangling – since we have So now I'm more concerned about first part of the issue – module names. It's a common practice to have a name for published artifact with dashes, and it's very strange to annotate some buildscript files. |
For a workaround on module name issue please see #1396 (comment) |
@SvyatoslavScherbina, is there any plans to support
|
Has there been an update on this issue, currently having this issue. These lines of code are being converted in the framework header from this
to this
Which causes an |
No. It is still required to use the name that don't clash with any platform keywords. Just like when calling Kotlin from Java. |
Does #2747 helps with all problems here? |
I just tried the code in the first comment and had no issues. However, I found another name which gives an error, a class Example {
val DEBUG = ""
} generates this ObjectiveC code: @interface GreetingExample : KotlinBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@property (readonly) NSString *DEBUG __attribute__((swift_name("DEBUG")));
@end; |
I can confirm that I do not have problems with public sealed class SomeKind {
public object ENUM: SomeKind()
public val enum = ENUM
public val double = ENUM
} but have problems when I add |
I guess one issue is enough. |
According migration to YouTrack, closing this issue in favour of https://youtrack.jetbrains.com/issue/KT-33092. Please continue any discussions there. |
I've compiled some Kotlin code to use it as a framework for ios application in swift. Some code in Framework header was not valid objective C code:
I've used a pair of klibs, one of them is named
http-client-native-ios
and it contains class calledHttpMethod
. In produced header, it was declared asclass KSFHttp-client-nativeHttpMethod
– dashes were not removed, and it became invalid identifier.In kotlinx.serialization, I have a
enum class KSerialClassDesc
and one of its members isENUM
. Member name was translated directly into objective C and broke compilation. I've experimented with some Objective C reserved keywords:became
Seems that no keywords except
class_
are escaped, and there are a lot of errors.The text was updated successfully, but these errors were encountered: