Cannot access current path from NavigationPath — need breadcrumb trail like Files app

I’m building an app similar to the Files app, where users navigate through folders using a NavigationStack with a bound NavigationPath. I need to display the current path — meaning a breadcrumb-like UI that shows the folder hierarchy the user has drilled down into.

However, I’m running into a big limitation: We can’t access the current values inside NavigationPath. It doesn’t conform to Sequence, and there’s no documented way to extract the typed path elements to construct a path string like Documents / MyFolder / Subfolder.

To work around this, I tried maintaining a separate [FileItem] array alongside NavigationPath, and that works well in iOS 17+ and iOS 18. But when I test on iOS 16, and navigate to another detail view in my NavigationSplitView, the app crashes. I searched around and found others hit this issue too — switching back to NavigationPath fixes the crash, but now I’m back to square one: I can’t figure out the current folder path from the stack.

So my questions are: • Is there any supported way to access the current typed values from NavigationPath in a safe and supported way? • Or is there another Apple-recommended approach for this kind of breadcrumb behavior in apps using NavigationStack?

Would really appreciate insight from Apple or anyone who’s solved this cleanly, especially with iOS 16 compatibility in mind.

Thanks!

I think your best bet here is to use a homogenous collection type that accepts a standard type, like an array or a custom data type as your path.


struct ContentView: View {
    @State private var navigationManager = NavigationManager()

    var body: some View {
        NavigationStack(path: $navigationManager.path) {
            List {
                NavigationLink("Home", value: Path.Home(.path1))
                NavigationLink("Settings", value: Path.Settings)
            }
            .navigationDestination(for: Path.self) { path in
                Text("\(path)")
            }
        }
    }
}


enum Path: Hashable {
    case Home(Home)
    case Settings
    case Pages
}

enum Home {
    case path1
    case path2
    case path3
}


@Observable
class NavigationManager {
    var path: [Path] = [] {
        willSet {
            print("will set to \(newValue)")
        }
        
        didSet {
            print("didSet to \(path)")
        }
    }
}

Cannot access current path from NavigationPath — need breadcrumb trail like Files app
 
 
Q