"OS X at startup" code deprecation #8420

issue droark opened this issue on July 28, 2016
  1. droark commented at 7:39 PM on July 28, 2016: contributor

    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.

  2. jonasschnelli commented at 7:41 PM on July 28, 2016: 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.

  3. jonasschnelli added the label MacOSX on Jul 28, 2016
  4. jonasschnelli added the label GUI on Jul 28, 2016
  5. droark commented at 7:45 PM on July 28, 2016: contributor

    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).

  6. jonasschnelli commented at 7:47 PM on July 28, 2016: 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).

  7. droark commented at 7:50 PM on July 28, 2016: contributor

    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.

  8. lucasderraugh commented at 5:01 AM on July 29, 2016: none

    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.

  9. droark commented at 4:41 PM on July 29, 2016: contributor

    @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.

  10. bg002h commented at 2:55 PM on January 14, 2019: none

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

  11. fanquake commented at 3:23 AM on February 5, 2020: member

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

  12. fanquake closed this on Feb 5, 2020

  13. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me