A library that add control flow functionality to SwitUI, using the power of @functionBuilder and ViewBuilder.
When you get the following error message, check this library:
❗Closure containing control flow statement cannot be used with function builder 'ViewBuilder'
List(dogs.identified(by: \.name)){ dog inSwitchValue(dog){CaseIs(Animal.self){ value inText(value.species)}CaseIs(Dog.self){ value inText(value.breed)}}}structDogDetailView:View{@ObjectBindingvarviewModel:DogDetailViewModelvarbody:someView{IfLet(viewModel.dog){ item inVStack{Text(item.name).color(.white).padding()Text(item.description).color(.white).lineLimit(nil).padding()Spacer()}}.onAppear{self.viewModel.load()}}}- iOS 13+ / macOS 10.15+ / tvOS 13+, watchOS 6+
- Xcode 11+
- Swift 5.1+
- File > Swift Packages > Add Package Dependency...
- Choose Project you want to add ControlFlowUI
- Paste repository URL https://github.com/Karumi/ControlFlowUI
- Rules > Branch: Master
dependencies:[.package(url:"https://github.com/Karumi/ControlFlowUI.git",.branch("master"))]