Jacob Rhoda
11/22/2023, 4:47 PM@ShouldRefineInSwift
annotations are just causing those fields to disappear in my headers. Is there a way to work around this?Filip Dolník
11/22/2023, 4:56 PMJacob Rhoda
11/22/2023, 5:00 PM@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…
__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:Jacob Rhoda
11/22/2023, 5:01 PM__
nor the non-prefixed name works.Jacob Rhoda
11/22/2023, 5:03 PMFilip Dolník
11/22/2023, 5:17 PMJacob Rhoda
11/22/2023, 5:18 PMFilip Dolník
11/22/2023, 5:19 PM