xpc

Communicate with another app using XPC

不羁的心 提交于 2019-12-17 22:16:53
问题 I have a windowed app, and to add some functionality I need another app which launches at login and sync data to server if available. I have tried with NSDistributionNotification but its practically useless in a sandboxed app. I looked up XPC and hoped it will work but I just dont know how to get it to work with the helper. So far I have done this using XPC. Main App NSXPCInterface *remoteInterface = [NSXPCInterface interfaceWithProtocol:@protocol(AddProtocol)]; NSXPCConnection *xpcConnection

Using Sockets with NSXPCConnection

99封情书 提交于 2019-12-13 04:46:43
问题 Running into an issue when using sockets with an NSXPCConnection. Basically, there is a main process and a helper process running, established via NSXPCConnection. That helper process needs to act as a server and listen to a particular port (say 111), which receives outside connections. The helper process opens a listening socket using the TCPServer helper class (wrapper around CFSocket ) which is provided by Apple. Code found here: https://code.google.com/p/iphone-remotepad/source/browse

NSWorkspace runningApplications doesn't return my XPC mach service

我只是一个虾纸丫 提交于 2019-12-11 01:36:50
问题 NSArray *activeApps = [[NSWorkspace sharedWorkspace] runningApplications]; Returns running applications and agents, but i cannot see my running XPC mach service (although it is running and visible in activity monitor processes) even when i look up the PID in activity monitor id res = [NSRunningApplication runningApplicationWithProcessIdentifier:223]; i get res nil, although with other processes this works well 回答1: The NSRunningApplication documentation states: Only user applications are

EXC_BAD_INSTRUCTION when sending message to XPC Service

余生长醉 提交于 2019-12-11 00:42:57
问题 I'm trying to use an XPC Service for inter-process communication. I've added an XPC service target to my project, and then when I try doing a xpc_connection_send_message I get EXC_BAD_INSTRUCTION . As far as I can tell, I am correctly initializing and starting the connection. serviceConnection = xpc_connection_create("com.foo.bar.MyService", dispatch_get_main_queue()); xpc_connection_set_event_handler(serviceConnection, ^(xpc_object_t event) { xpc_type_t type = xpc_get_type(event); if (type =

Communicating over XPC with an app and launch daemon running as root

家住魔仙堡 提交于 2019-12-08 00:01:52
问题 Is it possible to communicate with a launch daemon running as root and an application over XPC? When my daemon is running as my user I can communicate with it fine, when run as root it stops receiving my messages. Is this intended security inside Mac OS X? I need to use low level xpc (for running on Lion as well). I know I can create a priviliged and signed helper tool that is running as root for my app. Will I be able to communicate with it with another process as well over XPC or sockets?

XPC Between two cocoa applications in workspace, the NSXPCConnection is immediately being invalidated

牧云@^-^@ 提交于 2019-12-05 02:07:42
问题 I have two Cocoa Applications, one is going to be the sender and another the receiver in this XPC relationship. In the applicationDidFinishLaunching in the sender, I first open the second receiver application NSError* error = nil; NSURL* url = [[NSBundle mainBundle] bundleURL]; url = [url URLByAppendingPathComponent:@"Contents" isDirectory:YES]; url = [url URLByAppendingPathComponent:@"MacOS" isDirectory:YES]; url = [url URLByAppendingPathComponent:@"TestXPCHelper.app" isDirectory:YES]; [

Is possible to use Mac OS X XPC like IPC to exchange messages between processes? How?

浪尽此生 提交于 2019-12-03 01:12:33
问题 According to Apple, the new XPC Services API, introduced in Lion, provides a lightweight mechanism for basic interprocess communication integrated with Grand Central Dispatch (GCD) and launchd. It seems possible to use this API as a kind of IPC, like the POSIX IPC, however, I cannot find how to do it. I am trying to communicate two processes using the XPC API so I can pass messages between them but I always get a "XPC connection invalid" error in the server side. I don't want an XPC Service,

Is possible to use Mac OS X XPC like IPC to exchange messages between processes? How?

烂漫一生 提交于 2019-12-02 14:43:41
According to Apple, the new XPC Services API, introduced in Lion, provides a lightweight mechanism for basic interprocess communication integrated with Grand Central Dispatch (GCD) and launchd. It seems possible to use this API as a kind of IPC, like the POSIX IPC, however, I cannot find how to do it. I am trying to communicate two processes using the XPC API so I can pass messages between them but I always get a "XPC connection invalid" error in the server side. I don't want an XPC Service, I just want to exchange messages using a client-server architecture. I am using two BSD-like processes,

OS X - Truly 'On Demand' Privileged Helper Tool

前提是你 提交于 2019-12-02 12:43:33
问题 My application needs to write files to restricted places on the filesystem. To do so, I use a helper tool that is run as root. Everything is working correctly, following this example, my helper tool is correctly installed and run. I use this solution to be able to "wake" the helper tool, otherwise it isn't launched more than one time after initial load. The helper tool is waiting for messages to come from the main application, and executes them correctly. I also have a kind of message that

SMLoginItemSetEnabled sometimes silently fails to launch sandboxed UI helper

青春壹個敷衍的年華 提交于 2019-11-30 09:00:20
I have an app that is sandboxed, and includes a helper that presents some UI (as a full-screen window, but could be a status item or similar too). This works... most of the time. But sometimes it doesn't; it just silently fails to start the helper. Since the helper has UI, I use SMLoginItemSetEnabled to load it, then NSXPCConnection to communicate with it. But sometimes SMLoginItemSetEnabled fails to launch it, while still returning YES. This seems to be due to an old build of the app somewhere on the machine; that seems to confuse the login mechanism. Deleting the old app fixes it, but I can