The NSXPCConnection API provides an objective-c RPC mechanism built on top of xpc.
Questions tagged [nsxpcconnection]
55 questions
19
votes
1 answer
How to send a message from XPC helper app to main application?
I was successful in creating XPC service and communicating with XPC service by sending messages from main application. But what I want to know is, whether its possible to initiate a communication from XPC service to the main application. The Apple…

MjZac
- 3,476
- 1
- 17
- 28
15
votes
5 answers
Running multiple instances of the same XPC service (NSXPCConnection)
Is it possible to run multiple instances of the same XPC service using the XPC APIs found in Foundation.framework (NSXPCConnection, etc.)? The docs don't provide much insight on this matter.
EDIT: Did a quick test, and it seems like only one…

indragie
- 18,002
- 16
- 95
- 164
12
votes
3 answers
XPC not registering classes correctly for collection
I'm using XPC in one of my apps on 10.8. It's got the standard setup with protocols defined for exported interface and the remote interface. The problem I run into is with one of my methods on the exported interface.
I have a model class, lets just…

sudo rm -rf
- 29,408
- 19
- 102
- 161
11
votes
1 answer
What is the correct way to self-terminate a MacOS XPC service?
I've successfully followed the Daemons and Service Guide - Creating XPC Services tutorial, along with the SandboxedFetch sample code and have a working Client / Service setup that is using the new NSXPCConnection class.
What still isn't entirely…

kennyc
- 5,490
- 5
- 34
- 57
10
votes
1 answer
NSXPCConnection pass an object by proxy
The Daemons and Services Programming Guides tells that it is possible to return a proxy object through an open XPC connection, even as a reply block parameter.
Passing an Object By Proxy
Most of the time, it makes sense to copy objects and send…

Andrea Cremaschi
- 533
- 3
- 19
8
votes
1 answer
Is an XPC interruption handler called when launchd kills the process?
The documentation for the interruptionHandler block of NSXPCConnection states:
An interruption handler that is called if the remote process exits or crashes.
However, the Daemons and Services Programming Guide states:
XPC services are managed by…

indragie
- 18,002
- 16
- 95
- 164
7
votes
1 answer
Inter-App Communication for sandboxed swift app on macOS
I'm building a sandboxed macOS app with Swift, which contains a child app inside.
What I want to implement is:
Parent can launch multiple child apps
Parent send different content to each child app to show
Both parent and child app have their own…

Xiao Xiao
- 931
- 8
- 19
6
votes
1 answer
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…

Devarshi
- 16,440
- 13
- 72
- 125
5
votes
1 answer
NSXPCConnection debugging interruption/invalidation
I am on XCode 9, OSX not iOS, Objective-C.
I have an XPC Service to talk to other applications.
XPC Services are completely new to me. I've read documentation and articles i found - still i'd need some help.
// NSXPC Connection stored as…

Pat_Morita
- 3,355
- 3
- 25
- 36
5
votes
1 answer
NSXPCInterface constructor does not recognise protocol in Swift
I'm creating a XPC service in swift, and I created my protocol:
protocol MyProtocol {
func myFunc()
}
When I try to set the interface that the exported object implements (in my main.swift), by initialising a new object of NSXPCInterface with…

gbdavid
- 1,639
- 18
- 40
4
votes
3 answers
How do you make a Swift class available in an XPC service?
I'm attempting to rebuild Apple's XPC "lowerCase" sample code from Objective-C to Swift. I understand XPC will, but I'm relatively new to Swift and Objective-C interoperability.
When I use their exact sample code, which passes a String from the app…

kennyc
- 5,490
- 5
- 34
- 57
4
votes
1 answer
XPC and Exception handling
I have an LaunchAgent using HockeyApp for crash reporting. Now I noticed that uncaught exception where not reported by HockeyApp, like they would have been in a normal macOS app.
For example:
- (void)upperCaseString:(NSString *)aString…

catlan
- 25,100
- 8
- 67
- 78
4
votes
3 answers
Verify that a helper tool is installed
I'm writing a macOS app in Swift that needs a privileged helper tool -- wish the elevation wasn't necessary, but it looks like it is.
I found this excellent example application especially tailored for this scenario. I've managed to port its code to…

swineone
- 2,296
- 1
- 18
- 32
4
votes
1 answer
NSMachBootstrapServer is deprecated, how can NSXPCConnection be used to register a Mach Service?
I need to write a Mach Service that both my app and a system plugin can talk to, I use the NSMachPort API to create a new port, then register it with NSMachBootstrapServer:
- (void) run
{
NSMachPort *serverPort = (NSMachPort *)[NSMachPort…

alfwatt
- 2,010
- 2
- 18
- 29
4
votes
1 answer
Is it possible to use pyobjc with a privilved XPC helper tool and XPCInterface API?
I believe the answer to this question is "no", but I'm putting it out to the community just in case someone has been more successful than I have.
I have a privileged helper tool that a client Cocoa application uses with the NSXPCConnection and…

Corbell
- 1,283
- 8
- 15