Passing arguments to System Extension from the App Delegate

Hello,

I am creating a system extension and bundling it in an app.
I have had success building the app and requesting activation of the extension from my application delegate (Swift). My question is that I need to somehow pass additional arguments from the app delegate that requests activation of the extension to the main function of my system extension. Specifically, I am trying to pass the username of the user that ran the application. Is there a way to pass additional arguments from the delegate to the extension?

I cannot get the current user from within the system extension because the extension runs as root, always. So the fetching the current user will return root.



Relevent code from my app delegate that requests activation:
Code Block
func applicationDidFinishLaunching(_ aNotification: Notification) {
   
    let ID = "com...."
    let req = OSSystemExtensionRequest
.activationRequest(forExtensionWithIdentifier: ID,
queue: DispatchQueue.main).
request.delegate = self
   
/*some how pass arguments to extension*/
OSSystemExtensionManager
.shared.extensionManager.submitRequest(req)
}




C/C++ code to start my System Extension:

Code Block
int main(int argc, const char* argv[]){
    //start.....extension
//Need to receive arguments here
dispatch_main();
}


Answered by DTS Engineer in 612888022

Is there a way to pass additional arguments from the delegate to the extension?

The usual way of doing this is over XPC.

What sort of sysex are you building?

Share and Enjoy

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

WWDC runs Mon, 22 Jun through to Fri, 26 Jun. During that time all of DTS will be busy with conference duties.
Accepted Answer

Is there a way to pass additional arguments from the delegate to the extension?

The usual way of doing this is over XPC.

What sort of sysex are you building?

Share and Enjoy

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

WWDC runs Mon, 22 Jun through to Fri, 26 Jun. During that time all of DTS will be busy with conference duties.
Passing arguments to System Extension from the App Delegate
 
 
Q