Can't Print Document Directory and find UserDefaults plist

Chapter 8: Saving Settings.
I’m trying to print the document directory by adding .onAppear modifier but nothing is printed on the console.

import SwiftUI

@main
struct HIITFitApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
            .onAppear {
                print(FileManager.default.urls(for: .documentDirectory, in: .userDomainMask))
            }
    }
  }

print-doc-directory

  1. Are you running the app on a device or a simulator? Previews won’t print to the debug console.

  2. At the bottom right of Xcode, is your Filter clear?

  3. The debug console is split into two. Are you showing the right half? This is controlled by the two little icons at the bottom right of Xcode.

Option 3 solved my problem. The right area was hidden. :pray:

1 Like