Hi folks, I'm working on a Compose Multiplatform p...
# multiplatform
w
Hi folks, I'm working on a Compose Multiplatform project that mixes native and compose UIs. I'm using a NativeViewFactory pattern where some views are defined in an interface and implemented in Swift, which is then injected. This is possible because the entrypoint of the app is Swift, where it can define an implementation and pass it into the Kotlin side. I'm running into a problem with testing, where I am testing Composables in a more isolated fashion, and more importantly, from a Kotlin entrypoint (in commonTest). It's a composeUiTest. At this point there is no injected NativeViewFactory, so the test can't proceed on iOS. Is there an existing pattern for testing Composables with Swift views embedded within? Seems like it would require a way to call Swift code before calling the composable. Or is there another method? Thanks!
I guess there's also an argument that I could/should mock the NativeViewFactory and test them separately (in Xcode, etc). But it really feels like I'm not that far from being able to do this in commonTest, which would be really nice to have.
hi @François - out of interest, do you think using spm4kpm to generate kotlin bindings for project swift code is a reasonable use-case? thanks!
f
Yes, I think yes, as your native is directly linked to the iOS SourceSet instead of using Interface/Implementation way. At least you need to start your test from the iOSMain SourceSet
thank you color 1