XPCService not getting launched from app
XPCService not getting launched from app
- Subject: XPCService not getting launched from app
- From: Devarshi Kulshreshtha <email@hidden>
- Date: Fri, 10 Oct 2014 11:23:07 +0530
I am trying a simple sample app on XPCServices, in which I am
following below steps:
Step 1: Created a sample project and added target - XPCServices with
name - HelperProcess to it. When the target is created XCode
automatically generates below files:
1. HelperProcessProtocol.h
2. HelperProcess.h
3. HelperProcess.m
4. main.m
Step 2: In main.m added a log statement within implementation of
ServiceDelegate:
- (BOOL)listener:(NSXPCListener *)listener
shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts,
and resumes a new incoming NSXPCConnection.
NSLog(@"Log which is never displayed :(");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(HelperProcessProtocol)];
// Next, set the object that the connection exports. All
messages sent on the connection to this service will be sent to the
exported object to handle. The connection retains the exported object.
HelperProcess *exportedObject = [HelperProcess new];
newConnection.exportedObject = exportedObject;
// Resuming the connection allows the system to deliver more
incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you
have accepted this connection. If you want to reject the connection
for some reason, call -invalidate on the connection and return NO.
return YES;
}
Step 3: In AppDelegate added below code in applicationDidFinishLaunching:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
_connectionToService = [[NSXPCConnection alloc]
initWithServiceName:@"HelperProcess"];
_connectionToService.remoteObjectInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(HelperProcessProtocol)];
[_connectionToService resume];
}
Problem is -
When I launch the app, neither the log added in
listener:shouldAcceptNewConnection: is displayed nor the helper
process appears in Activity Monitor :(
Here is the code: https://github.com/Daemon-Devarshi/XPCShootOut
Note: I am trying this on XCode 6.0
Is there any additional setup which I need to do to make it working?
Please suggest.
--
Thanks,
Devarshi
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden