My App No Longer Prompts for Mic or Screen Recording Permissions

I am a beginning Swift developer who inherited a macOS app that does screen and microphone recording.

At one point this app would prompt a new user to grant Microphone and Screen Recording permissions as soon as those activities were initiated. I received reports that a new version that I built was not prompting for microphone permissions. I did some testing on my own system and now am having those same issues where audio and screen recording activities do not prompt for screen recording.

I have tried various combinations of the tccutil command to reset individual and all existing permissions. I've rebooted numerous times and even cleared SMC but nothing seems to help.

Here is a snippet of code that I am using to start audio recording:

Code Block          
let settings = [
          AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
          AVSampleRateKey: 16000,
          AVNumberOfChannelsKey: 1,
          AVEncoderAudioQualityKey: AVAudioQuality.min.rawValue
        ]
         
        _recorder = try AVAudioRecorder(url: url, settings: settings)
_recorder?.record()


And here is the code used to take a screen shot of a window:

Code Block
   static func generate(forWindow window: [String: AnyObject], mask windowMask: Bool) -> (image: CGImage?, window: CGRect)? {
    let windowId = (window[kCGWindowNumber as String] as! NSNumber).int32Value
    let rect = windowRect(forWindow: window)
     
    let option = windowMask ? CGWindowListOption(arrayLiteral: .optionIncludingWindow) : CGWindowListOption(arrayLiteral: [.optionIncludingWindow, .optionOnScreenAboveWindow])
    var image = CGWindowListCreateImage(rect, option, CGWindowID(windowId), .nominalResolution)
     
    if image != nil {
      image = resize(image!)
    }
     
    return (image, rect)
  }


I am building with Xcode 12.3 and using Swift 4 -- I am not able to upgrade to Swift 5 at this point -- and am using Catalina 10.15.7.

As mentioned, I am new to Swift development and have exhausted all of my options. Is there any additional information that I can provide to help get this resolved?

Have you removed the app from the Mac and reloaded ?
Yes, I have done that multiple times. I have even attempted to re-use the prior, working build but it still does not prompt.

So, I am aware that this could be an issue specifically with my machine however, others have reported similar issues. I just don't have analytics for those individuals.

I am hoping there is a way in code to explicitly trigger the prompt so that it is not left up to chance.
My App No Longer Prompts for Mic or Screen Recording Permissions
 
 
Q