NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

MacOS SwiftUI Screenshot

Forums > macOS

I want my MacOS app to be able to take a screenshot of a selected area only, not the whole screen.

I know I can use the build in capabilities of MacOS "Shift+Command+4" and use Pauls code-> to detect the action, but I realy want the functionallity to be handle in app.

I've come accross this piece of code but can't get it to run as my knowledge of extensions is in its infancy:

I have alot to learn and any help would be appreciated.


This open-source library ( provides the API to capture entire screen, capture an area, and record screen. I think this might be useful to you.


Oh, great, thanks for the info! I am interested in developing antivirus for macOS that would focus on keeping software settings intact or flagging on an attempt to introduce changes. There are apps around that escalate privalages despite being what is called a 100% legit app e.g. There are apps that are rather ill-famed yet still are not recognized as culprits. Yahoo redirect generic virus is a good example. So I wonder if Swift is a good language to develop AV focusing on privilage escalation issues, in partticular, I wonder if DetectX Swift could be used as a stub Sorry, the question is a bit irrelevenat and obscure, I appreciate any follow-up.


Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.