Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

swift - 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 deleted and reinstalled the app numerous times and, 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:

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:

   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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...