Thanks for your help! I've figured out what the main entrypoint needs to do for an app extension, here's the relevant Objective-C code:
// https://medium.com/@avaidyam/nsextension-pluginkit-a-brief-intro-2803be91a777
void NSExtensionMain() {
@autoreleasepool {
// Retrieve the default PKService instance
id pkService = [NSClassFromString(@"PKService") defaultService];
if (pkService) {
// Call the internal run method with arguments
// Note: This mimics the behavior described, but PKService's _defaultRun:arguments: is private API.
// In practice, use public APIs like NSXPCListener.resume() in your extension's principal class.
[pkService run];
} else {
// Fallback: Manually set up the NSXPCListener if PKService isn't available
NSXPCListener *listener = [NSXPCListener serviceListener];
// Set your delegate that conforms to NSXPCListenerDelegate
// Example: listener.delegate = [[YourExtensionDelegate alloc] init];
[listener resume];
}
}
}
The network extension starts up now and successfully connects (just dropping the packets right now but this should be enough to start from).
Topic:
App & System Services
SubTopic:
Networking
Tags: