1

I am trying to build an app for MacOS in Swift to log some information about running applications. Some of the information which I would like to get are related to the corresponding processes (user, etc.), but it doesn't seem that I can get them from NSRunningApplication. So I was wondering is there any way to get ProcessInfos for NSRunningApplications? Unfortunately I couldn't find anything in Apple Developer Documentation.

enezhadian
  • 946
  • 6
  • 9

1 Answers1

2

You need to get the PID from NSRunningApplication's processIdentifier property, and then you can use sysctl to get information from the PID. See this answer:

https://stackoverflow.com/a/20169895/7258538

It's in C, but it should give you the basic idea.

Charles Srstka
  • 16,665
  • 3
  • 34
  • 60