https://kotlinlang.org logo
#touchlab-tools
Title
# touchlab-tools
j

Jacob Rhoda

11/22/2023, 4:47 PM
Regarding SKIE, I am seeing that my
@ShouldRefineInSwift
annotations are just causing those fields to disappear in my headers. Is there a way to work around this?
f

Filip Dolník

11/22/2023, 4:56 PM
Hi! I’m not sure I understand the problem correctly. Do you have some example?
j

Jacob Rhoda

11/22/2023, 5:00 PM
Yeah, so I enable SKIE and run it on my project (latest version). I have a class that looks like this,
Copy code
@OptIn(ExperimentalObjCRefinement::class)
actual abstract class ViewModelContainerHost<STATE: Any, SIDE_EFFECT: Any>
    : ContainerHost<STATE, SIDE_EFFECT> {
    @HiddenFromObjC
    public actual val viewModelScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

    @ShouldRefineInSwift
    val stateValue
        get() = container.stateValueNative
    @ShouldRefineInSwift
    val stateFlowNative
        get() = container.stateFlowNative
    @ShouldRefineInSwift
    val sideEffectFlow
        get() = container.sideEffectFlowNative
}
I am not yet using SKIE’s Flow translation — incrementally adopting it. This produces a header that looks like this…
Copy code
__attribute__((swift_name("ViewModelContainerHost")))
@interface TMSViewModelContainerHost<STATE, SIDE_EFFECT> : TMSBase <TMSContainerHost>
@property (readonly) TMSKotlinUnit *(^(^sideEffectFlow)(TMSKotlinUnit *(^)(SIDE_EFFECT, TMSKotlinUnit *(^)(void), TMSKotlinUnit *), TMSKotlinUnit *(^)(NSError * _Nullable, TMSKotlinUnit *), TMSKotlinUnit *(^)(NSError *, TMSKotlinUnit *)))(void) __attribute__((swift_private));
@property (readonly) TMSKotlinUnit *(^(^stateFlowNative)(TMSKotlinUnit *(^)(STATE, TMSKotlinUnit *(^)(void), TMSKotlinUnit *), TMSKotlinUnit *(^)(NSError * _Nullable, TMSKotlinUnit *), TMSKotlinUnit *(^)(NSError *, TMSKotlinUnit *)))(void) __attribute__((swift_private));
@property (readonly) STATE stateValue __attribute__((swift_private));
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@end
Which is adding the
swift_private
attribute to those properties. When you try to access them from Swift code, Xcode gives this error:
However, neither the prefix
__
nor the non-prefixed name works.
This was working before I adopted SKIE
f

Filip Dolník

11/22/2023, 5:17 PM
That looks like a bug in SKIE. I don’t think there is a workaround, but it should be an easy fix on our end. So I think I’ll be able to bundle that into the next release which is scheduled early next week.
👍 1
j

Jacob Rhoda

11/22/2023, 5:18 PM
Thanks! Need me to open an issue on Github?
f

Filip Dolník

11/22/2023, 5:19 PM
In this case it’s not needed since I’ll fix it right away.
🙌 2
2 Views