Re: How to make an app launch on login?

2016-04-20 Thread Jens Alfke
FYI, I just filed a bug report complaining about the lack of a reasonable 
native API for this. rdar://25834170 .

—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: How to make an app launch on login?

2016-04-20 Thread Alex Zavatone
I use a super useful and nice little tool for iOS called SimulatorManager that 
has the option to make it an item that is launched at startup.

It probably contains the code you need.

It is here:

https://github.com/tue-savvy/SimulatorManager

Hope this helps.

Alex Zavatone


On Apr 19, 2016, at 5:01 PM, Jens Alfke wrote:

> One of my companies’ apps has a “Launch at login” pref, which no longer works 
> in OS X 10.11. I’m not surprised, since the existing code implements this by 
> writing into loginwindow’s user defaults :-p
> 
> I’m trying to find the currently supported API for this. The “Adding Login 
> Items” page says:
>> There are two ways to add a login item: using the Service Management 
>> framework, and using a shared file list.
>> Login items installed using the Service Management framework are not visible 
>> in System Preferences and can only be removed by the application that 
>> installed them.
>> Login items installed using a shared file list are visible in System 
>> Preferences; users have direct control over them. 
> 
> I’d definitely prefer the latter, since it seems like a bad idea to have the 
> app not show up in the user’s login-item list in the Accounts system pref.
> 
> I found LSSharedFileList.h, but everything in there is marked deprecated. :(
> 
> What are my options?
> 
> —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/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: How to make an app launch on login?

2016-04-20 Thread sqwarqDev

| On Apr 20, 2016, at 05:00 PM, sqwarqDev  wrote:
| If your app is sandboxed you'll need to call it via NSUserAppleScriptTask

Correction: NSUserScriptTask

https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserScriptTask_Class/index.html#//apple_ref/occ/cl/NSUserScriptTask


Best

Phil
@sqwarq
http://sqwarq.com

On Apr 20, 2016, at 04:48 PM, dangerwillrobinsondan...@gmail.com wrote:

I believe the correct answer is LaunchAgent plist, XPC helper LaunchAgent or instruct users to manually add it in system preferences or provide a script they can manually run once. 



Sent from my iPhone

On Apr 20, 2016, at 6:01 PM, sqwarqDev  wrote:

If you’re willing (or able: beware sandboxing issues) to call either osascript 
or NSAppleScript, you can do this via a bit of AppleScript magic:


tell application "Finder" to set aPath to POSIX path of (application file id 
”com.yourBundleID.yourApp" as string)

tell application "System Events”
make new login item at end of login items with properties {path:aPath, hidden:false, 
kind:\"Application\", name:”Your App Name”}
end tell



Best

Phil
@sqwarq
___

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/dangerwillrobinsondanger%40gmail.com

This email sent to dangerwillrobinsondan...@gmail.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/sqwarqdev%40icloud.com

This email sent to sqwarq...@icloud.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: How to make an app launch on login?

2016-04-20 Thread sqwarqDev

Not quite sure what "correct" means there, but I use the AppleScript approach 
in a couple of my apps and it works without issue. Doesn't require elevated privileges, 
and it's tied to a checkbox user preference which gets saved in StandardUserDefaults.

If your app is sandboxed you'll need to call it via NSUserAppleScriptTask, see:

https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserAppleScriptTask_Class/index.html#//apple_ref/doc/uid/TP40012267-CH1-SW2

Best

Phil
@sqwarq
http://sqwarq.com

On Apr 20, 2016, at 04:48 PM, dangerwillrobinsondan...@gmail.com wrote:

I believe the correct answer is LaunchAgent plist, XPC helper LaunchAgent or instruct users to manually add it in system preferences or provide a script they can manually run once. 



Sent from my iPhone

On Apr 20, 2016, at 6:01 PM, sqwarqDev  wrote:

If you’re willing (or able: beware sandboxing issues) to call either osascript 
or NSAppleScript, you can do this via a bit of AppleScript magic:


tell application "Finder" to set aPath to POSIX path of (application file id 
”com.yourBundleID.yourApp" as string)

tell application "System Events”
make new login item at end of login items with properties {path:aPath, hidden:false, 
kind:\"Application\", name:”Your App Name”}
end tell



Best

Phil
@sqwarq
___

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/dangerwillrobinsondanger%40gmail.com

This email sent to dangerwillrobinsondan...@gmail.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: How to make an app launch on login?

2016-04-20 Thread dangerwillrobinsondanger
I believe the correct answer is LaunchAgent plist, XPC helper LaunchAgent or 
instruct users to manually add it in system preferences or provide a script 
they can manually run once. 


Sent from my iPhone

> On Apr 20, 2016, at 6:01 PM, sqwarqDev  wrote:
> 
> If you’re willing (or able: beware sandboxing issues) to call either 
> osascript or NSAppleScript, you can do this via a bit of AppleScript magic:
> 
> 
> tell application "Finder" to set aPath to POSIX path of (application file id 
> ”com.yourBundleID.yourApp" as string)
> 
> tell application "System Events” 
> make new login item at end of login items with properties {path:aPath, 
> hidden:false, kind:\"Application\", name:”Your App Name”}
> end tell
> 
> 
> 
> Best
> 
> Phil
> @sqwarq
> ___
> 
> 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/dangerwillrobinsondanger%40gmail.com
> 
> This email sent to dangerwillrobinsondan...@gmail.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: How to make an app launch on login?

2016-04-20 Thread sqwarqDev

If you’re willing (or able: beware sandboxing issues) to call either osascript 
or NSAppleScript, you can do this via a bit of AppleScript magic:


tell application "Finder" to set aPath to POSIX path of (application file id 
”com.yourBundleID.yourApp" as string)

tell application "System Events” 
make new login item at end of login items with properties {path:aPath, hidden:false, 
kind:\"Application\", name:”Your App Name”}
end tell



Best

Phil
@sqwarq
___

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: How to make an app launch on login?

2016-04-19 Thread Jens Alfke

> On Apr 19, 2016, at 2:43 PM, Jeff Szuhay  wrote:
> 
> The preferred way seems to be through the use of launchd

I don’t think so. I’ve worked with launchd before — it provides very low-level 
functionality for starting background processes, and there’s no visible UI for 
configuring it. Not at all the same thing as launching apps at login.

—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: How to make an app launch on login?

2016-04-19 Thread Jeff Szuhay
Again, I jumped the gun.

The preferred way seems to be through the use of launchd
 
>?



>>> On Apr 19, 2016, at 2:01 PM, Jens Alfke  wrote:
>>> 
>>> One of my companies’ apps has a “Launch at login” pref, which no longer 
>>> works in OS X 10.11. I’m not surprised, since the existing code implements 
>>> this by writing into loginwindow’s user defaults :-p

___

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: How to make an app launch on login?

2016-04-19 Thread Jens Alfke

> On Apr 19, 2016, at 2:35 PM, Jeff Szuhay  wrote:
> 
> I spoke too soon; yes, all of this is marked as “available but deprecated on 
> 10.11”. 

Yeah, interesting that Apple added LSSharedFileListItemCopyResolveURL in 10.10 
and then deprecated it in 10.11. Oops!

I guess I’ll use this API anyway since it’s the best thing I can find. Thanks!

—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: How to make an app launch on login?

2016-04-19 Thread Jeff Szuhay
I spoke too soon; yes, all of this is marked as “available but deprecated on 
10.11”. 

I would hope that Apple would provide sample code to show the preferred new way 
to do this.


> On Apr 19, 2016, at 2:29 PM, Jeff Szuhay  wrote:
> 
> There was some discussion of this on stack overflow but one of the APIs there 
> is deprecated: LSSharedFileListItemResolve.
> It’s 3rd parameter takes a pointer to a CFURLRef and that is now deprecated.
> 
> Instead, use LSSharedFileListItemCopyResolveURL; basically the return value 
> from this is what you want.
> 
> Deprecated:
>   if( LSSharedFileListItemResolve( itemRef , 0 , (CFURLRef*)  , 
> NULL ) == NoErr )
> 
> Accepted:
>   thePath = LSSharedFileListItemCopyResolveURL( itemRef, 0 , NULL)
>   if( thePath ) 
> 
> It looks to me like this was done to have a single API for both Swift and 
> Obj-C for less maintenance (makes sense).
> 
> 
>> On Apr 19, 2016, at 2:01 PM, Jens Alfke  wrote:
>> 
>> One of my companies’ apps has a “Launch at login” pref, which no longer 
>> works in OS X 10.11. I’m not surprised, since the existing code implements 
>> this by writing into loginwindow’s user defaults :-p
>> 
>> I’m trying to find the currently supported API for this. The “Adding Login 
>> Items” page says:
>>> There are two ways to add a login item: using the Service Management 
>>> framework, and using a shared file list.
>>> Login items installed using the Service Management framework are not 
>>> visible in System Preferences and can only be removed by the application 
>>> that installed them.
>>> Login items installed using a shared file list are visible in System 
>>> Preferences; users have direct control over them. 
>> 
>> I’d definitely prefer the latter, since it seems like a bad idea to have the 
>> app not show up in the user’s login-item list in the Accounts system pref.
>> 
>> I found LSSharedFileList.h, but everything in there is marked deprecated. :(
>> 
>> What are my options?
>> 
>> —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: How to make an app launch on login?

2016-04-19 Thread Jeff Szuhay
There was some discussion of this on stack overflow but one of the APIs there 
is deprecated: LSSharedFileListItemResolve.
It’s 3rd parameter takes a pointer to a CFURLRef and that is now deprecated.

Instead, use LSSharedFileListItemCopyResolveURL; basically the return value 
from this is what you want.

Deprecated:
if( LSSharedFileListItemResolve( itemRef , 0 , (CFURLRef*)  , 
NULL ) == NoErr )

Accepted:
thePath = LSSharedFileListItemCopyResolveURL( itemRef, 0 , NULL)
if( thePath ) 

It looks to me like this was done to have a single API for both Swift and Obj-C 
for less maintenance (makes sense).


> On Apr 19, 2016, at 2:01 PM, Jens Alfke  wrote:
> 
> One of my companies’ apps has a “Launch at login” pref, which no longer works 
> in OS X 10.11. I’m not surprised, since the existing code implements this by 
> writing into loginwindow’s user defaults :-p
> 
> I’m trying to find the currently supported API for this. The “Adding Login 
> Items” page says:
>> There are two ways to add a login item: using the Service Management 
>> framework, and using a shared file list.
>> Login items installed using the Service Management framework are not visible 
>> in System Preferences and can only be removed by the application that 
>> installed them.
>> Login items installed using a shared file list are visible in System 
>> Preferences; users have direct control over them. 
> 
> I’d definitely prefer the latter, since it seems like a bad idea to have the 
> app not show up in the user’s login-item list in the Accounts system pref.
> 
> I found LSSharedFileList.h, but everything in there is marked deprecated. :(
> 
> What are my options?
> 
> —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/jeff%40szuhay.org
> 
> This email sent to j...@szuhay.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