The following code worked fine in Mojave .
let options = CGWindowListOption(arrayLiteral: CGWindowListOption.excludeDesktopElements, CGWindowListOption.optionOnScreenOnly, CGWindowListOption.optionOnScreenAboveWindow)
let windowList = CGWindowListCopyWindowInfo(options, kCGNullWindowID) as NSArray? as? [[String: AnyObject]]
for entry in windowList!
{ let name = (entry[kCGWindowName as String] != nil) ? entry[kCGWindowName as String] as! String : ""
...
In Catalina
entry[kCGWindowName as String]
always is nil
In SO: Detecting screen recording settings on macOS Catalina I read, that is´t required to enable the "screen recording API" an how to detect, if it's enabled.
Unfortunately I do not find out, how to enable the "screen recording API".
As mentioned in SO: macOS Catalina screen recording permission I switched on Automatic Code Signing.
In the System Preferences I see no "+" to add an App, to grant "screen recording".
How can the API Permission for Screen Recording be granted?