Hi guys! I have a peculiar problem with CMP on iOS...
# compose-ios
v
Hi guys! I have a peculiar problem with CMP on iOS. I believe I am the first person in the history of CMP to try this. I am trying to implement Live Activities in an iOS app. I wrote a bunch of unnecessarily bad code to wire everything up from Swift (since no ObjC API exists for ActivityKit) and the time has come to implement the LA UI. I have created a ComposeUIViewController + UIViewControllerRepresentable for each part of my LA dynamic island widget. I have one for the banner, one for the trailing LA content and so on, in total 7 SwiftUI Compose wrappers. My Live Activity logic works correctly, but the only thing I see on a physical device instead of my banner is the first attachment. If I try to run a LA on an emulator with a dynamic island, nothing at all is being displayed despite the activity running as intended in the background. If I try to add a swiftui view instead of the compose view, it works, but I cannot do that as my entire app is already using compose multiplatform for all UI, compose resources for icons which I need to show and a lot of theming I haven't set up on the Swift side. I have 3 simple questions: What is this? Why does this happen? How can I fix this? Code:
Copy code
public fun ORLABannerVC(): UIViewController = ComposeUIViewController {
    AppTheme { ORLABanner() }
}

@Composable
internal fun ORLABanner(
    modifier: Modifier = Modifier,
) {
    Text("Banner")
}

// swift

struct ComposeView: UIViewControllerRepresentable {
    let factory: () -> UIViewController

    func makeUIViewController(context: Context) -> UIViewController {
        return factory()
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) { }
}


struct OngoingRitualLiveActivity: Widget {
    var body: some WidgetConfiguration {
        // Lock screen/banner UI
        ActivityConfiguration(for: OngoingRitualAttributes.self) { context in
            ComposeView { ORLAUI.shared.ORLABannerVC() }
        } dynamicIsland: { context in
            DynamicIsland {
                DynamicIslandExpandedRegion(.leading) {
                    ComposeView { ORLAUI.shared.ORLAExpandedLeadingRegionVC() }
                    Text("DIEL-SUI")
                }
       }
}