XPC Connection with Network Extension fails after upgrade

Hi Team,

I have a Network Extension application and UI frontend for it. The UI frontend talks to the Network Extension using XPC, as provided by NEMachServiceName.

On M2 machine, The application and XPC connection works fine on clean installation. But, when the application is upgraded, the XPC connection keeps failing.

Upgrade steps:

  1. PreInstall script kills the running processes, both UI and Network Extension
  2. Let installation continue
  3. PostInstall script to launch the application after installation complete.

Following code is successful to the point of resume from UI application

NSXPCInterface *exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(IPCUIObject)];
    newConnection.exportedInterface = exportedInterface;
    newConnection.exportedObject = delegate;

    NSXPCInterface *remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(IPCExtObject)];
    newConnection.remoteObjectInterface = remoteObjectInterface;

    self.currentConnection = newConnection;
    [newConnection resume];

But it fails to get the object

id<IPCExtObject> providerProxy = [self.currentConnection remoteObjectProxyWithErrorHandler:^(NSError *registerError) {
    
    }];

Please note, this only fails for M2. For M1, this exact code is running fine. Additionally, if I uninstall the application by dropping it in Trash and then installing the newer version, then too, the application works fine.

Replies

I’ve seen this before… but where?

Oh, here it is.

Share and Enjoy

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

Thank you!

The accepted solution in the thread referenced above is, using pre-install script. " disable network filter stop network system extension "

What are the commands to perform these in preinstall script. As of now, these are the operations we perform in preinstall:

  1. Unload the application from launchctl (launchctl asuser $GSUID /bin/launchctl unload $AGENT_PLIST_PATH)
  2. rm -rf /Library/LaunchAgents/com.myapp.plist
  3. We kill both UI and Extension process in preinstall using pkill