erikberglund / SwiftPrivilegedHelper

Example application using a privileged helper tool with authentication in an unsandboxed application written in Swift
MIT License
180 stars 33 forks source link

Xcode 10.2 (distribution) builds don't work on <10.14.4 #12

Closed rob-patchett closed 5 years ago

rob-patchett commented 5 years ago

Hey @erikberglund, I managed to have everything working when building from Xcode 10.1, but it seems that 10.2 is messing something up with the helper (still using Swift 4.2). Basically running the privileged helper doesn't work on <10.14.4. The install of the helper appears to work fine, but never actually launches (according to activity monitor).

I've investigated the build's package contents and a big difference I found is that the helper executable is a fraction of the size (down from 6.6MB with Xcode 10.1 to 91kB with Xcode 10.2). It seems the build process must have changed in Xcode 10.2, but I haven't yet found the exact cause.

erikberglund commented 5 years ago

Hi, correct. That is because of the new Swift 5 included in 10.2 and the new included swift runtime in macOS 10.14.4.

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2

And here is a thread on the swift forums about this:

https://forums.swift.org/t/command-line-applications-crashes-with-xcode-10-2/22192/20?u=josh_wisenbaker

I haven't had the need to do this so I have not investigated what the best approach is. But Apple has made it so that you probably have to compile two different versions of the app depending on if the user is < 10.14.4 or >= 10.14.4

erikberglund commented 5 years ago

And here, where they (Apple) say that you now MUST install the runtime package on versions older than 10.14.4 if you want cli tools built with xcode 10.2 to work on those Macs.

https://forums.developer.apple.com/thread/115094

rob-patchett commented 5 years ago

Ah yes, thanks for the links. It doesn't really sound like there's a big appetite for Apple to resolve this issue. I can't see an ideal solution to this and it looks like it will most likely depend on an individual application's use case (in my case the helper isn't crucial to the core functionality, so perhaps I restrict the helper to versions of macOS that come with embedded Swift libraries).

Thanks for the help with this! I'll will close this issue since it doesn't really apply to this sample.

rob-patchett commented 5 years ago

I also came across this helpful solution for other types of apps that include a CLI tool: https://forums.developer.apple.com/thread/115020

Unfortunately it doesn't work for privileged helper tools, since the tool needs to be copied by SMJobBless.