This has become much more common lately in Xcode 11 (Version 11.7). I'm stepping through code, but in one section po refuses to work and the variable display lists some variables as not available. These files are always in the proper target membership, so I attributed it to a threading issue since it often occurs in background threads.
Updated: after removing logging calls path is now accessible But in this case, I can po every variable in this func, except url created in the if statement. Specifically the line print(url) prints:
"this/is/my/path -- file:///"
but stopped at same line po url prints:
error: :3:1: error: use of unresolved identifier 'url'
while at same line po message prints:
"Player failed with error: Unknown.\nInternet: true, UserData: None\nURL: file://this/is/my/path"
final class MyVideoController: UIViewController {
var testPathForURL: String? = "file://this/is/my/path"
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// happens on main thread
test(error: nil)
}
}
extension MyVideoController {
private func test(error: NSError?) {
let errorString = error?.description ?? "Unknown"
let errorSummary = "Player failed with error: \(errorString)"
let userInfo = error?.userInfo.description ?? "None"
let message: String = "\(errorSummary).\nInternet: \(true), UserData: \(userInfo)\nURL: \(testPathForURL ?? "NONE")"
print(message)
let filePrefix = "file://"
if let fullPath = testPathForURL, fullPath.hasPrefix(filePrefix) {
// Delete cached video so problem won't occur again.
let path = String(fullPath.dropFirst(filePrefix.count))
print(path)
let url = URL(fileURLWithPath: path)
do {
print(url)
try FileManager.default.removeItem(at: url)
} catch {
print(error)
}
}
}
}
Update: Here's what happens when I stop on the try FileManager line and use alternatives to po:
(lldb) v url
(URL) url = <variable not available>
(lldb) e url
error: <EXPR>:3:1: error: use of unresolved identifier 'url'
url
^~~
(lldb) p url
error: <EXPR>:3:1: error: use of unresolved identifier 'url'
url
^~~
Also, I have cleaned and rebuilt, restarted Xcode, restarted my Mac, and reinstalled Xcode tools.
UPDATE
I recently built project with beta versions of Xcode 12 separately on this machine, but believe similar debugger incidents predated that.
One other possible symptom that I've been dealing with for a long while is that it occasionally takes a very long time (minutes) for debugger to load variable list when it stops at a breakpoint (6 core 2018 Mac mini with 32 Gb RAM). I thought that was only happening when debugging on my 5s test device, but it also is happening on simulator occasionally.