WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Need help with day 42 challenge 3 Moonshot project.

Forums > 100 Days of SwiftUI

As Paul said in the tip I made separate views for Grid and List, but got these errors with the Group

Referencing instance method 'navigationTitle' on 'Group' requires that 'EmptyCommands' conform to 'View'

Closure containing control flow statement cannot be used with result builder 'CommandsBuilder'

import SwiftUI

struct ContentView: View {
    @State private var showingGrid = true

    let astronauts: [String: Astronaut] = Bundle.main.decode("astronauts.json")
    let missions: [Mission] = Bundle.main.decode("missions.json")

    let columns = [
        GridItem(.adaptive(minimum: 150))

    var body: some View {
        NavigationView {
            Group {
                if showingGrid {
                    GridLayout(astronauts: astronauts, missions: missions)
                } else {
                    ListLayout(astronauts: astronauts, missions: missions)
            .toolbar {
                Button("Toggle") {


I tried your ContentView and it worked fine for me.

You could try cleaning your build folder, just in case it is become messy and confused Xcode. In the menu bar, under Product select Clean Build Folder. Alternatively use Shift + Command + K


I changed Group to VStack then back to Group and it worked 😅 Also did what you told. Thanks for the reply.


Hacking with Swift is sponsored by Emerge

SPONSORED Optimize your app’s startup time, binary size, and overall performance using Emerge’s advanced app optimization and monitoring tools. Reliably measure app size, speed up your app's startup time with Emerge's Launch Booster, and much more. Emerge is actively used by many of the top mobile development teams in the world.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.