I struggle with this strange problem: I want to p...
# compose-ios
s
I struggle with this strange problem: I want to parameterize my ComposeUIViewController with the reference to my AppStore, which is an interface implemented by my DefaultAppStore - part of the redux pattern known from kmm-production-sample. I can create an instance of the AppStore in my main PhotosApp.swift (using a bunch of parameters). The instance in Swift code is of Type "AppStore" - if I look into it, it's called "SharedAppStore". I assume it's prefixed "Shared" because my module has this name. Now I got a new module called "compose" where I got this code in iosMain:
Copy code
import androidx.compose.ui.window.ComposeUIViewController
import com.ashampoo.photos.compose.ImageLoader
import com.ashampoo.photos.compose.ui.ContentView
import com.ashampoo.photos.shared.state.AppStore

fun MainViewController(
    store: AppStore,
    imageLoader: ImageLoader,
    supportId: String
) = ComposeUIViewController {
    ContentView(
        store = store,
        imageLoader = imageLoader,
        supportId = supportId,
        skiaGraphicsApi = null
    )
}
On Swift side it demands an "SharedAppStore" instance, which is incompatible with the "AppStore" created by the constructor. Does this happen because I have two different XCFrameworks? ("compose" depends on "shared") Is there any way around it or do I have to merge my modules "shared" (non-ui-code) with "compose" (ui-code)?
1
👍 1
l
XCFrameworks produced by Kotlin tend to not work well together (and produce separate runtime/separate classes). You should generally use an umbrella module that produces one single XCFramework.
It looks like your compose module already depends on shared, so you could export the shared module from the compose one and import the single compose module in Swift.
s
Ok, thank you 🙏🏻