How do I view global variables in the debugger window?

When I select the "all" option for which variables to show my global variables don't show up.

I've got a set of arrays that are used to store data that are globally available. But when I'm in a routine that uses them they don't show up in the debugging window.

There might be a bug because once they did show up but that was only once.

I know the variables exist and are in scope since the method uses them and works just fine.

Thanks for any help. I'm using Xcode 12.1

Replies

I did a basic test here and things are working for me. Here’s what I did:

  1. Using Xcode 12.5 and macOS 11.5.2, I created a new project from the macOS > Command Line Tool template.

  2. I changed main.swift to look like this:

    var a: [String] = ["Hello", "Cruel", "World!"]
    var b: [String] = ["Goodbye", "Cruel", "World!"]
    
    func main() {
        print(a[0])
    }
    
    main()
    
  3. I set a breakpoint on the print statement.

When I hit the breakpoint both a and b show up in the debugger, even with the popup set to Auto.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"