Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use CGPreflightScreenCaptureAccess API for ScreenAuthStatus #19

Closed
wants to merge 6 commits into from

Conversation

quanglam2807
Copy link

Based on this: https://stackoverflow.com/a/65423834/5522263, Apple has an official API to get Screen Auth permission status: CGPreflightScreenCaptureAccess: https://developer.apple.com/documentation/coregraphics/3656523-cgpreflightscreencaptureaccess

I've tested this with Electron 11.1.1 + macOS 11 and it worked perfectly.

Copy link
Owner

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks - this is great. Lint and test CI are failing right now because of missing LDFLAGS - when we add CoreGraphics we also need to add that library to binding.gyp.

Once that's fixed up we can get this landed!

@quanglam2807
Copy link
Author

Thank you, @codebytere. I don't know what happens but CI keeps returning ../permissions.mm:168:9: error: use of undeclared identifier 'CGPreflightScreenCaptureAccess' while node-gyp` compiles successfully on my local environment.

@codebytere
Copy link
Owner

@quanglam2807 i'll take a closer look soon 🤔

@mmaietta
Copy link

mmaietta commented Mar 9, 2021

Any progress made on this?

I'm curious if the CI is running a different version of xcode or using command line tools instead.
Available software in macos node in github workflows:
https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11.0-Readme.md

Maybe the CI SDK version need to be synced with your dev environment @quanglam2807?
A potential way to force a different MacOS SDK via github workflow and to test this hypothesis:

env:
  DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer

Ref: https://www.jessesquires.com/blog/2020/01/06/selecting-an-xcode-version-on-github-ci/

@codebytere
Copy link
Owner

@quanglam2807 would you mind rebasing this? I can take it over and try @mmaietta's suggestion above if you'd like as well

@quanglam2807
Copy link
Author

Thank you for checking this, @codebytere @mmaietta

I managed to fix the problem partially by using newer SDK. But I don't know how to fix:

dyld: lazy symbol binding failed: Symbol not found: _CGPreflightScreenCaptureAccess
  Referenced from: /Users/runner/work/node-mac-permissions/node-mac-permissions/build/Release/permissions.node
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics

This is odd. If the API is supported in macOS 10.15+, then I suppose the symbol must be in the system's framework?

@codebytere
Copy link
Owner

@quanglam2807
Copy link
Author

It seems like the API is added in Bug Sur. So Apple provides wrong documentation?

I can modify the PR to only use the new API in macOS 11+ and retain the old code for older versions. Would that work?

@codebytere
Copy link
Owner

@quanglam2807 sounds great to me! Thanks for being patient with this PR - appreciated 🙇🏻‍♀️

@codebytere codebytere deleted the branch codebytere:master November 11, 2021 18:14
@codebytere codebytere closed this Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants