running macOS UI based Application as root I'd like to open a specific macOS application which require root privileges (uid=0 or gid=0) in order to access specific files. However, when trying to run with sudo directly I get the following error: 

sudo /Applications/myApp.app/Contents/MacOS/myApp
Illegal instruction: 4


and if running it indirectly using open it gets the uid of current user and not root. 

any ideas who to do it ?
Security Risk

macOS is not designed to have general applications run as the root user. This would be viewed as a security risk by Apple's engineers.

XPC Services

Running a graphical application, and all the frameworks that requires, as root is not advisable. The surface area for security problems and mistakes is huge.

AuthorizationExecuteWithPrivileges is now deprecated. Instead, Apple promote XPC Services as a way dividing up sections of applications that require higher privileges.