Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"OS X at startup" code deprecation #8420

Closed
droark opened this issue Jul 28, 2016 · 8 comments
Closed

"OS X at startup" code deprecation #8420

droark opened this issue Jul 28, 2016 · 8 comments

Comments

@droark
Copy link
Contributor

droark commented Jul 28, 2016

Hello. I recently compiled 0.13rc1 on my Mac. It compiled but I came across several warnings such as the following.

qt/guiutil.cpp:810:67: warning: 'kLSSharedFileListSessionLoginItems' is deprecated: first deprecated in OS X 10.11 - Use a LaunchAgent, XPCService or the ServiceManagement APIs instead. [-Wdeprecated-declarations] LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);

It appears that the code used to start Core when logging into OS X is now obsolete and needs to be upgraded sooner or later. I haven't tried compiling on a 10.12 beta yet but I'm guessing it still compiles on 10.12.

Anyway, after doing some research, I found this post, which implies that Apple wants everybody to move over to the ServiceManagement framework. Said framework, according to this tutorial, seems to have the following steps.

  • Create a background helper app that resides within the main app structure.
  • The background app finds the main app at startup, calls the main app, and immediately terminates.
  • The main app uses some roundabout calls to signal to OS X whether or not the user wishes to have the main app start at login.

src/qt/guiutil.cpp has most of the code that needs to be updated, although it appears that src/qt/notificator.cpp also needs an update. I spent a few hours last night trying to wrap my head around how Core could be updated to handle the new method. I had some success but am not totally sure how to proceed. Here's what I have so far, which is probably incomplete.

  • Modify the Make system to create the helper app for Mac builds, and create it first. Due to the Mac-specific nature of the code, I'd imagine it'd just be a .h/.mm combo and perhaps some support files to assist with putting everything together.
  • Compile Core with the hooks for the helper app.
  • After the .app structure for Core has been built, move/copy the helper app inside Core.
  • Update Core .plist files and such as needed.
  • Update the cleanup code to delete any helper app copies.

The main problem I have is that, honestly, I'm not totally familiar with all the nuances of Apple's APIs. So, it's hard for me to figure out how certain things work. For example, the tutorial I linked used the Xcode GUI to do things, which I know would be frowned upon by Core devs. That's fine. I just don't know all the little things necessary to make OS X happy. The app signing nuances don't help either.

Would anybody like to lend a hand? I'm happy to work on this in my free time. I just need somebody who can provide some guidance and make sure I'm not going down a path that'll screw up things like app signing. I have a Core file guide here in case it helps. It covers the high level of what's going on with Core's files, including some of the Mac-specific stuff.

Thanks.

@jonasschnelli
Copy link
Contributor

I think as long as we build with 10.11 with compatibility against 10.7 this can't be updated to the new APIs.

@droark
Copy link
Contributor Author

droark commented Jul 28, 2016

Thanks. Would you happen to know the minimum version where my suggestion (or something similar) would work? I don't doubt you. I'm just, as I said, unfamiliar with the ins & outs of Apple's documentation (or lack thereof in some cases, apparently).

@jonasschnelli
Copy link
Contributor

I also don't know it for sure. But I guess if we access newer non-deprecated APIs, we would need to set the minimum compatible OSX version to 10.11 (which would leave out a lot of users).

@droark
Copy link
Contributor Author

droark commented Jul 28, 2016

Hmmm. I'm not so sure that 10.11 would be a minimum, although I could potentially see it requiring 10.9 or even 10.10, the latter of which did break quite a bit of stuff, and quietly too. I suppose I could contact the guy who made that tutorial and get his opinion.

EDIT: Heh. It helps to re-read blog posts and such once you actually know how to read them properly. :) This blog post and this helper app seem to confirm that 10.7 is a valid target. So, in theory, it should be possible to move forward.

Paging @lucasderraugh. Would you mind taking a moment to confirm that my suggestions would work at all, and preferably on 10.7+? Thanks.

@lucasderraugh
Copy link

lucasderraugh commented Jul 29, 2016

Accoring to SMLoginItem.h:

__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_NA)
XPC_EXPORT XPC_NONNULL1
Boolean
SMLoginItemSetEnabled(CFStringRef identifier, Boolean enabled);

This means that the API is available starting in OS 10.6.

@droark
Copy link
Contributor Author

droark commented Jul 29, 2016

@lucasderraugh - Thanks! Looks like we should be great shape here. I'll play with your tutorial and see if I can pick up on any nuances. It sounds like the app just needs to be in the right subdirectory. The main app's .plist file is presumably the only thing that might need to be updated in terms of metadata and whatnot.

@bg002h
Copy link

bg002h commented Jan 14, 2019

Removing the option might be the way to go. There are other ways to make the app open at login in the OS.

@fanquake
Copy link
Member

fanquake commented Feb 5, 2020

The code this issue references was removed in #17567. Going to close this.

@fanquake fanquake closed this as completed Feb 5, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants