2

I have such inits with ViewBuilders with TupleView

 // MARK: TupleView support
    public init<A: View, B: View>(@ViewBuilder content: () -> TupleView<(A, B)>) {

        let views = content().value

        self.childs = [AnyView(views.0), AnyView(views.1)]

    }

Code works great, but starting from new Xcode 11.3 update (iOS 13.3) this code stopped working, and constructor with TupleView is not executed.

Here is how I use MenuView with such initializer:

MenuView {

        DashboardView()
        .withTag(0)
        .tabBarItem {
            TabItemView(imageName: "Dashboard", title: "Home")          
        },


        ContactsView(companyId: self.getCompanyId())
        .withTag(1)
        .tabBarItem {
            TabItemView(imageName: "Contacts", title: "Contacts")
        }

}

But now it doesn't work this @ViewBuilder and do not I think call ViewBuilder.buildBlock() correctly and this argument is recognized as call to

public init<Content: View>(@ViewBuilder content: () -> Content>) { }

I found the workaround, but it is very ugly code and it is far away how we can use native TabView for instance.

 MenuView {

            ViewBuilder.buildBlock(
            DashboardView()
            .withTag(0)
            .tabBarItem {
                TabItemView(imageName: "Dashboard", title: "Home")          
            },


            ContactsView(companyId: self.getCompanyId())
            .withTag(1)
            .tabBarItem {
                TabItemView(imageName: "Contacts", title: "Contacts")
            }
  )
}
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
  • show your application examples please. – E.Coms Dec 20 '19 at 16:15
  • Ok I do this later. I found solution but it is far from ideal it is rather hack. But if I be in front of my macbook I provide more details and samples – Michał Ziobro Dec 20 '19 at 19:39
  • I've added more explanations and code examples. To the problem. I think that for some reasons ViewBuilder.buildBlock is not correctly executed implicitly and I need to do this explicitly. – Michał Ziobro Dec 22 '19 at 08:51

1 Answers1

0

When you use MenuView, you have to add a TupleView?

  MenuView {

         TupleView(( 
        DashboardView()
        .withTag(0)
        .tabBarItem {
            TabItemView(imageName: "Dashboard", title: "Home")          
        },


        ContactsView(companyId: self.getCompanyId())
        .withTag(1)
        .tabBarItem {
            TabItemView(imageName: "Contacts", title: "Contacts")
        }))

    }
E.Coms
  • 11,065
  • 2
  • 23
  • 35