Re: Talking to other apps - again

2014-08-06 Thread Roland King

 
 I'm surprised IPC still sucks so badly. I haven't used XPC, but I thought it 
 was a general-purpose solution for messaging between apps, not just for 
 communicating with your app's own helper processes.
 

I was just doing some reading about it actually to see what it’s all about. If 
you get down to the xpc manpages (after all there’s a C-API down there 
somewhere) it is a generic IPC solution with the one caveat that you can’t 
register a dynamic listener, seems that only launchd is allowed to do that, for 
security reasons (and you can tell if something was started from 
/Library/LaunchDaemons or not). 

So basically you can talk to services listed in the LaunchAgents/Daemons list 
or you can connect to services in your own bundle which will be started for 
you. 

The proposed way to have two apps talk to each other is have them each register 
with such a running XPC service, under I guess some well-known name. Then app B 
queries the XPC service for app A’s XPC service it just registered and talks to 
it that way. 

What I don’t quite get about that is what kind XPC service you need? I would 
expect that if you bundled it inside each app, even under the exact same name 
and UUID and bundle ID etc, then XPC is going to launch a per-app version of 
the service, which would be useless, unless there’s a way to tell XPC please 
just make one and share it in some way which is secure. Otherwise you need to 
install a real one in LaunchAgents so it’s per-user. That then means I guess 
that anyone could technically talk to it and start shouting at your app and it 
would be a pain to install it too. 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Gerriet M. Denkmann

On 6 Aug 2014, at 12:30, Roland King r...@rols.org wrote:

 What happened to the suggestions of using a domain socket or a directory both 
 apps can read to do this? 

One thing at a time. This might be Step 3 or 4.
First I have to investigate Step 1 (maybe a dead end) and Step 2.

Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Gerriet M. Denkmann

On 6 Aug 2014, at 12:30, Roland King r...@rols.org wrote:

 
 On 6 Aug 2014, at 1:06 pm, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 Step 1: Use XPC.
 
 Is there some other way to make this work? Or should I just forget about XPC?
 
 
 I’d forget about XPC, it’s not for sending data between two primary apps, 
 it’s for offloading tasks to helper apps. 

Yes, I finally did come to the same conclusion.

 
 NSXPCListener can get an NSXPCListenerEndpoint, which is an endpoint object 
 that may be sent over an existing connection.
 And NSXPCConnection has initWithListenerEndpoint: which Initializes an 
 NSXPCConnection object to connect to an NSXPCListener object in another 
 process, identified by an NSXPCListenerEndpoint object.
 Might this be a way to make it work (no idea how to get the 
 NSXPCListenerEndpoint from B to A yet).
 The documentation for NSXPCListenerEndpoint is somewhat terse. But it does 
 NSSecureCoding.
 
 In order to get the endpoint from B to A you need a connection, so you have a 
 chicken and egg problem.

I thought: take the endpoint of B, archive it, put it on a pasteboard and let A 
read it. (Not for real, just for testing).
But I got told:This class may only be encoded by an NSXPCCoder. 
This was the final straw.

So: no more about XPC.

Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Gerriet M. Denkmann

On 6 Aug 2014, at 12:46, Jens Alfke j...@mooseyard.com wrote:

 
 On Aug 5, 2014, at 10:06 PM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 Scripting Bridge SBObject has a sendEvent:id:parameters:. Not sure I want to 
 use this.
 
 It seems like your best bet, actually.
 
You are right. I just gave up on using raw Apple Events.

 The typical route is that you implement scriptability in the target app, 
 including the terminology file that describes what commands and objects it 
 handles,

App B got an sdef already. B, by the way, is NOT document based.

Apple Script Editor can do:

tell application B
get version
end tell

Now the app delegate, called BeDelegate, has a property 
@property (readonly)  NSString *babbel;
implemented as:
- (NSString *)babbel { return @Bibbel; }

But how to write an apple script to get this magic Bibbel-string? And how to 
write the sdef to make this possible?
And what else does my BeDelegate has to implement?

You see, I am absolutely clueless.

Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Alex Zavatone
AppleScript can be a royal PITA with the syntax differences.  You might want to 
read up on ASOC, AppleScript Objective-C.  Shane Stanley has written a load on 
that (books too) and there is an ASOC dev mailing list that he frequents.

Mailing list:
ASObjC applescriptobjc-...@lists.apple.com

URL:
http://www.macosxautomation.com/applescript/apps/


By the way, if you do want to check out XPC, there is a good tutorial on 
objc.io here:

http://www.objc.io/issue-14/xpc.html

Good luck,
Alex Zavatone



On Aug 6, 2014, at 10:41 AM, Gerriet M. Denkmann wrote:

 
 On 6 Aug 2014, at 12:46, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Aug 5, 2014, at 10:06 PM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 Scripting Bridge SBObject has a sendEvent:id:parameters:. Not sure I want 
 to use this.
 
 It seems like your best bet, actually.
 
 You are right. I just gave up on using raw Apple Events.
 
 The typical route is that you implement scriptability in the target app, 
 including the terminology file that describes what commands and objects it 
 handles,
 
 App B got an sdef already. B, by the way, is NOT document based.
 
 Apple Script Editor can do:
 
 tell application B
   get version
 end tell
 
 Now the app delegate, called BeDelegate, has a property 
   @property (readonly)  NSString *babbel;
 implemented as:
   - (NSString *)babbel { return @Bibbel; }
 
 But how to write an apple script to get this magic Bibbel-string? And how to 
 write the sdef to make this possible?
 And what else does my BeDelegate has to implement?
 
 You see, I am absolutely clueless.
 
 Kind regards,
 
 Gerriet.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
 
 This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Gerriet M. Denkmann

On 6 Aug 2014, at 22:05, Alex Zavatone z...@mac.com wrote:

 By the way, if you do want to check out XPC, there is a good tutorial on 
 objc.io here:
 
 http://www.objc.io/issue-14/xpc.html

Very interesting. Thanks for the link!

A quote: 
Let’s say we have two apps, and we would like them to be able to communicate 
with each other over XPC. Each app doesn’t know what the other app is. But they 
both know about a (shared) launch agent.

Both apps can connect to the launch agent. App A creates a so-called anonymous 
listener that it listens on, and sends a so-called endpoint to that anonymous 
listener over XPC to the launch agent. App B then retrieves that endpoint over 
XPC from the launch agent. At this point, App B can connect directly to the 
anonymous listener, i.e. App A.

So XPC can be used for two apps to talk after all. It only is rather more 
complicated than I thought.

Kind regards,

Gerriet.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Roland King
Which is what I outlined some hours ago in a post on this thread. 

 On 6 Aug 2014, at 11:43 pm, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 
 On 6 Aug 2014, at 22:05, Alex Zavatone z...@mac.com wrote:
 
 By the way, if you do want to check out XPC, there is a good tutorial on 
 objc.io here:
 
 http://www.objc.io/issue-14/xpc.html
 
 Very interesting. Thanks for the link!
 
 A quote: 
 Let’s say we have two apps, and we would like them to be able to communicate 
 with each other over XPC. Each app doesn’t know what the other app is. But 
 they both know about a (shared) launch agent.
 
 Both apps can connect to the launch agent. App A creates a so-called 
 anonymous listener that it listens on, and sends a so-called endpoint to that 
 anonymous listener over XPC to the launch agent. App B then retrieves that 
 endpoint over XPC from the launch agent. At this point, App B can connect 
 directly to the anonymous listener, i.e. App A.
 
 So XPC can be used for two apps to talk after all. It only is rather more 
 complicated than I thought.
 
 Kind regards,
 
 Gerriet.
 
 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-06 Thread Shane Stanley
On 7 Aug 2014, at 12:41 am, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:

 Apple Script Editor can do:
 
 tell application B
   get version
 end tell

And so can your app. Add AppleScriptObjC.framework to your target, and add this 
to main.m:

[[NSBundle mainBundle] loadAppleScriptObjectiveCScripts];

Add a new file (choose Empty) to the project, call it SomeName.applescript, and 
in it add:

script SomeName
property parent : class NSObject

on appVersion()
 tell application B
  set theVers to version
 end tell
 return theVers
end appVersion

end script

Now add an informal protocol to your calling class that includes:

- (NSString *)appVersion

And you can call it something like:

NSString *version = [NSClassFromString(@SomeName) appVersion];

There are a few things to watch: you should only pass objects, and the bridge 
only converts NSStrings/text, NSNumbers/reals/integers, NSArrays/lists and 
NSDictionaries/records. And if you pass variables to the script, it needs to 
coerce them to their AppleScript equivalents.

For one or two commands, ScriptingBridge might be easier. But for more complex 
stuff, ASObjC avoids the whole hassle of building and maintaining the app 
header file, and can do some stuff more efficiently than SBApplication et al 
can.


-- 
Shane Stanley sstan...@myriad-com.com.au
www.macosxautomation.com/applescript/apps/


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-05 Thread Roland King

 On 6 Aug 2014, at 1:06 pm, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 Step 1: Use XPC.
 
 Is there some other way to make this work? Or should I just forget about XPC?
 

I’d forget about XPC, it’s not for sending data between two primary apps, it’s 
for offloading tasks to helper apps. 

 NSXPCListener can get an NSXPCListenerEndpoint, which is an endpoint object 
 that may be sent over an existing connection.
 And NSXPCConnection has initWithListenerEndpoint: which Initializes an 
 NSXPCConnection object to connect to an NSXPCListener object in another 
 process, identified by an NSXPCListenerEndpoint object.
 Might this be a way to make it work (no idea how to get the 
 NSXPCListenerEndpoint from B to A yet).
 The documentation for NSXPCListenerEndpoint is somewhat terse. But it does 
 NSSecureCoding.

In order to get the endpoint from B to A you need a connection, so you have a 
chicken and egg problem. There’s some discussion I’ve seen about creating a 
helper service which exists just to pass the connection from one app to the 
other but the last time I read that discussion it seemed fraught with pain. 


 
 
 Step 2: Use Apple Events.
 

Know nothing about Apple Events. 

What happened to the suggestions of using a domain socket or a directory both 
apps can read to do this? 

 
 
 Gerriet.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
 
 This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps - again

2014-08-05 Thread Jens Alfke

 On Aug 5, 2014, at 10:06 PM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 Scripting Bridge SBObject has a sendEvent:id:parameters:. Not sure I want to 
 use this.

It seems like your best bet, actually.

The typical route is that you implement scriptability in the target app, 
including the terminology file that describes what commands and objects it 
handles, and then you can have the scripting bridge tool generate a header for 
that app, which declares a subclass of SBApplication that has methods 
corresponding to the app's scriptable commands. But under the hood, those 
methods just turn into calls to sendEvent:id:parameters.

I'm surprised IPC still sucks so badly. I haven't used XPC, but I thought it 
was a general-purpose solution for messaging between apps, not just for 
communicating with your app's own helper processes.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Jerry Krinock

On 2014 Aug 03, at 23:54, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:

 NSPerformService (which also has the feel of not being well-loved), XPC, or 
 what else?

Yes.  Start by looking at XPC.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Pax
Why would you not use NSNotificationCenter for this?  

On 4 Aug 2014, at 15:51, Jerry Krinock je...@ieee.org wrote:

 
 On 2014 Aug 03, at 23:54, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 NSPerformService (which also has the feel of not being well-loved), XPC, or 
 what else?
 
 Yes.  Start by looking at XPC.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/45rpmlists%40googlemail.com
 
 This email sent to 45rpmli...@googlemail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Kyle Sluder
On Aug 4, 2014, at 7:55 AM, Pax 45rpmli...@googlemail.com wrote:
 
 Why would you not use NSNotificationCenter for this?  

Because that doesn’t do IPC.

And NSDistributedNotificationCenter is severely restricted in sandboxed apps.

--Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Jens Alfke

 On Aug 3, 2014, at 11:54 PM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 My app wants to talk to some app-friend. Like sending a string and getting 
 another string back. Or something slightly more complicated.

AppleEvents is the traditional mechanism for inter-app messaging.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Kevin Meaney
When you say app-friend, what do you mean? Another application? An XPC service? 
Some other kind of service?

If your App is sandboxed and the service is not an xpc service embedded in your 
application then I think your pretty much out of luck.

Kevin

On 4 Aug 2014, at 07:54, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:

 My app wants to talk to some app-friend. Like sending a string and getting 
 another string back. Or something slightly more complicated.
 
 In the good old days I would have used Distributed Objects, but this seems to 
 be no longer the fashion. Xcode 6 does not provide any documentation about 
 this (or I can't find it).
 
 So, what to do?
 NSPerformService (which also has the feel of not being well-loved), XPC, or 
 what else?
 
 Gerriet.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/ktam%40yvs.eu.com
 
 This email sent to k...@yvs.eu.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Gerriet M. Denkmann

On 4 Aug 2014, at 22:57, Kevin Meaney k...@yvs.eu.com wrote:

 When you say app-friend, what do you mean? Another application? An XPC 
 service? Some other kind of service?

I mean two apps, which are both written (and thus can be modified) by me.
I really should have mentioned this in my original post. Sorry about this.

 
 If your App is sandboxed and the service is not an xpc service embedded in 
 your application then I think your pretty much out of luck.
 
 Kevin
 
 On 4 Aug 2014, at 07:54, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 My app wants to talk to some app-friend. Like sending a string and getting 
 another string back. Or something slightly more complicated.
 
 In the good old days I would have used Distributed Objects, but this seems 
 to be no longer the fashion. Xcode 6 does not provide any documentation 
 about this (or I can't find it).
 
 So, what to do?
 NSPerformService (which also has the feel of not being well-loved), XPC, or 
 what else?
 
 Gerriet.
 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Scott Ribe
On Aug 4, 2014, at 11:23 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:

 I mean two apps, which are both written (and thus can be modified) by me.
 I really should have mentioned this in my original post. Sorry about this.

Showing my age here, but as an old UNIX troll, and assuming the apps are not 
sandboxed, I'd just use domain sockets.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man4/unix.4.html

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Uli Kusterer
On 04 Aug 2014, at 08:54, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 My app wants to talk to some app-friend. Like sending a string and getting 
 another string back. Or something slightly more complicated.

 I don't think there's a good way to do this if you're sandboxed. But as a 
last-ditch-workaround you could look into abusing NSUserDefaults if it's simple 
communication of tiny bobs of data. You can have a domain that is shared by two 
apps from the same manufacturer.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Scott Ribe
On Aug 4, 2014, at 11:47 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:

 You can have a domain that is shared by two apps from the same manufacturer.

Careful, I've had lots of problems with that--changes to defaults not being 
saved when you synch, and so forth.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Jens Alfke

 On Aug 4, 2014, at 10:41 AM, Scott Ribe scott_r...@elevated-dev.com wrote:
 
 Showing my age here, but as an old UNIX troll, and assuming the apps are not 
 sandboxed, I'd just use domain sockets.
 
 https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man4/unix.4.html

I have done this, and it’s surprisingly painful. I’d never do it again.

_Using_ the sockets is pretty easy (assuming you enjoy implementing framing 
protocols). The hard part is that you have to have a pseudo-file, located in 
the filesystem, to represent a Unix-domain socket. So you have to find a hidden 
place to create this ‘file’ with a randomly-chosen name (unless you don’t care 
about DoS attacks), give it the proper permissions, somehow transmit knowledge 
of that location to the other app, and clean it up when you’re done.

Doing this instead of using XPC or AppleEvents is like carving your own wheel 
out of stone instead of just going to a store and buying one.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Alex Zavatone
If you want to go down the sockets path, there are clear examples on using 
NSStream, sockets and Bonjour to send info between apps that are on the same 
Mac.  Check out the PictureSharing sample and other NSStream samples that are 
included in the Xcode help.

All I had to do to get this to work was to change the name of the folder that 
specified the pictures transmitted and pictures directory on lines 163 and 173 
in ServerAppDelegate.m file.

The project is a 2 app workspace that sends a picture from one app to another 
on the same Mac.

It might be overkill, but it does the trick.

Hope this helps,
Alex Zavatone

On Aug 4, 2014, at 1:41 PM, Scott Ribe wrote:

 On Aug 4, 2014, at 11:23 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 I mean two apps, which are both written (and thus can be modified) by me.
 I really should have mentioned this in my original post. Sorry about this.
 
 Showing my age here, but as an old UNIX troll, and assuming the apps are not 
 sandboxed, I'd just use domain sockets.
 
 https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man4/unix.4.html
 
 -- 
 Scott Ribe
 scott_r...@elevated-dev.com
 http://www.elevated-dev.com/
 (303) 722-0567 voice
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
 
 This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Jens Alfke

 On Aug 4, 2014, at 11:02 AM, Alex Zavatone z...@mac.com wrote:
 
 If you want to go down the sockets path, there are clear examples on using 
 NSStream, sockets and Bonjour to send info between apps that are on the same 
 Mac.  Check out the PictureSharing sample and other NSStream samples that are 
 included in the Xcode help.

If you do this you’ve created a networked app, whether you need that 
functionality or not. With that come lots of extra security concerns — do you 
want anyone in the world to be able to anonymously send you pictures? Are you 
100% certain your stream code is robust against bad data and won’t crash or 
overwrite memory or allow access to arbitrary local files? Also, by using 
Bonjour you’re now actively advertising your app’s presence to the LAN you’re 
on, making it very easy for anyone nearby to find and connect to.

You can mitigate this by binding your listener socket to only the loopback 
interface (127.0.0.1) which will prevent external connections. Of course you’re 
still advertising a service to the LAN that no one else can connect to, which 
seems pointless, but I don’t think there’s any way to restrict Bonjour services 
to localhost.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Uli Kusterer
On 04.08.2014, at 19:51, Scott Ribe scott_r...@elevated-dev.com wrote:
 On Aug 4, 2014, at 11:47 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 You can have a domain that is shared by two apps from the same manufacturer.
 
 Careful, I've had lots of problems with that--changes to defaults not being 
 saved when you synch, and so forth.

 What OS version was that with? It's definitely not easy in the old Prefs 
mechanism, but it should have improved a lot with the new prefs in 10.9 (or was 
it already in 10.8?) Well, basically there's now a central prefs server, so 
those caching issues should be less of a problem.

 That said, I've so far been lucky enough to not have to ship IAC in sandboxed 
apps, so I defer to anyone who has a more recent and deeper experience.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Scott Ribe
On Aug 4, 2014, at 2:23 PM, Uli Kusterer witness.of.teacht...@gmx.net wrote:

 What OS version was that with? It's definitely not easy in the old Prefs 
 mechanism, but it should have improved a lot with the new prefs in 10.9 (or 
 was it already in 10.8?) Well, basically there's now a central prefs server, 
 so those caching issues should be less of a problem.

10.6? 10.7? It was unreliable enough that I gave up long ago, before 10.8  
10.9. So it may very well work just fine if you don't need to support older OS 
versions.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Kyle Sluder
On Mon, Aug 4, 2014, at 03:23 PM, Uli Kusterer wrote:
 On 04.08.2014, at 19:51, Scott Ribe scott_r...@elevated-dev.com wrote:
  On Aug 4, 2014, at 11:47 AM, Uli Kusterer witness.of.teacht...@gmx.net 
  wrote:
  
  You can have a domain that is shared by two apps from the same 
  manufacturer.
  
  Careful, I've had lots of problems with that--changes to defaults not being 
  saved when you synch, and so forth.
 
  What OS version was that with? It's definitely not easy in the old Prefs
  mechanism, but it should have improved a lot with the new prefs in 10.9
  (or was it already in 10.8?) Well, basically there's now a central prefs
  server, so those caching issues should be less of a problem.

Please don't do this. David might have a heart attack if he has to
maintain compatibility with more apps that do this kind of stuff.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Kyle Sluder
On Mon, Aug 4, 2014, at 04:17 PM, Uli Kusterer wrote:
  Well, what other communication mechanisms are there for talking between
  sandboxed apps ... ? I *did* call it a last-ditch thing.

XPC and Apple Events (as long as your sdef uses access groups).

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Kevin Meaney

On 4 Aug 2014, at 22:49, Kyle Sluder k...@ksluder.com wrote:

 On Mon, Aug 4, 2014, at 04:17 PM, Uli Kusterer wrote:
 Well, what other communication mechanisms are there for talking between
 sandboxed apps ... ? I *did* call it a last-ditch thing.
 
 XPC and Apple Events (as long as your sdef uses access groups).

There has been some discussion on the xpc forum in Core OS on devforums about 
inter application communication. I new I'd seen it somewhere.

https://devforums.apple.com/community/mac/coreos/xpc

The thread Can I use NSXPCConnection between two desktop apps? I think is 
most relevant as there is some discussion of different options.

Kevin



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Talking to other apps

2014-08-04 Thread Roland King

 On 4 Aug 2014, at 2:54 pm, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 My app wants to talk to some app-friend. Like sending a string and getting 
 another string back. Or something slightly more complicated.
 
 In the good old days I would have used Distributed Objects, but this seems to 
 be no longer the fashion. Xcode 6 does not provide any documentation about 
 this (or I can't find it).
 
 So, what to do?
 NSPerformService (which also has the feel of not being well-loved), XPC, or 
 what else?
 
 Gerriet.


It’s odd how it’s easier to get two public apps to talk to each other than it 
is to get two private ones to. 

I’d put them in the same app group (presuming they are sandboxed) and then 
either use a domain socket or set up a simple dropbox in the shared directory 
and use a long-running NSFilePresenter to listen for changes and 
NSFileCoordination to read/write files to it. I’ve used that rather simple 
method in a few places now and it’s been surprisingly successful. You just end 
up with a callback on a queue of your choice in your app, read the file and go 
on your way. 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com