How do I run a Xcode Applicaton as root

Hello, Im trying to run this set of code as root

Button("Unlock FPS") {

                do {

                    let task = Process()

                    task.executableURL = URL(fileURLWithPath: "/Somewhere/Somewhere/Somewhere/rbxfpsunlocker")

But after hours of searching the internet I could not find anything, except on how to run the application as root in Debug mode. If anyone knows the answer please tell me.

Privilege escalation an macOS is tricky because:

  • There are simple insecure solutions

  • And relatively secure solutions that are super complex

  • But no simple and secure solutions.

To get you heading in the right direction I need to understand the scope of your product. Is this something you’re building for your own purposes? Or something you plan to deploy to a wide range of customers?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I plan to export the product to GitHub, giving it to people there.

OK. Given that, binary compatibility isn’t an issue, so I recommend that you shoot for something simple, and the simplest of all options is AuthorizationExecuteWithPrivileges.

IMPORTANT This was deprecated many moons ago and thus is not available to Swift. You’ll need to bounce over to Objective-C and call it from there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Do you have any examples of how you get Objectitive c on swift? Thanks for your help!

Do you have any examples of how you get [Objective-C] on swift?

Try this:

  1. Using Xcode, create a project from the macOS > App template and choose Swift as your language.

  2. Choose File > New > File and select Cocoa Class and click Next.

  3. Enter Bridge into the name field, set it to be an NSObject subclass, and choose Objective-C as the language. Then click Next and save the class.

  4. When you create the class, Xcode will ask you whether you want to create a bridging header. Agree to that.

  5. In the bridging header, add the following:

    #import "Bridge.h"
    
  6. In Bridge.h add the following:

    + (void)test;
    
  7. In Bridge.m, add the following:

    + (void)test {
        NSLog(@"Hello Cruel World!");
    }
    
  8. In a Swift file, add this code:

    Bridge.test()
    
  9. Run your app in a way that runs the code from step 8. It’ll print:

    2022-06-01 12:48:50.049578+0100 xxsm[29322:5790881] Hello Cruel World!
    

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I did every thing but when I put

+ (void)test {
    NSLog(@"Hello Cruel World!");
}

in it, it had this error

missing context for method declaration

In the .h file, method declarations must go between the @interface and @end lines. In the .m file, method definitions must go between the @implementation and @end lines.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I did all that, and it worked, but after I put

AuthorizationExecuteWithPrivileges

xcode gave this error: 'AuthorizationExecuteWithPrivileges' is deprecated: first deprecated in macOS 10.7, and this Expression result unused. Any way to fix this? Thanks for your help.

One advantage of working with Objective-C is that there’s a way to silence deprecation warnings [1]:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    
… your code here …

#pragma clang diagnostic pop

It says something about my job that I have a hot key to insert this (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] One day, Swift, one day!

How do I run a Xcode Applicaton as root
 
 
Q