Re: XPCService not getting launched from app
Re: XPCService not getting launched from app
- Subject: Re: XPCService not getting launched from app
- From: "email@hidden" <email@hidden>
- Date: Fri, 10 Oct 2014 19:04:27 +0000
Try these : 1. Bundle identifier for xpc service target be subdomain of main bundle identifier 2. Use bundle id of xpc target while initialising xpc connection 3. Add copy files build phase to copy service to contents/xpcservices 4. In main target add target dependency on xpc target
------Original message------
From: Devarshi Kulshreshtha <email@hidden>
To: "Cocoa-dev" <email@hidden>
Date: Friday, October 10, 2014 11:23:07 AM GMT+0530
Subject: XPCService not getting launched from app
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
_______________________________________________
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