I am writing a command-line tool for macOS that uses AuthorizationServices
to authorize the user and perform certain tasks as root. Unfortunately, using AuthorizationServices
with the binary created from command line via swift build
fails with an internal error -60008
. Yet, the same project works just fine when it is built with Xcode.
At first, I thought this is due to some code signing issues. So, I tried to sign it with a valid codesigning identity and com.apple.security.authorization
entitlement, but it did not fix the issue. I also checked the codesigning information of both binaries and there seems to be only minor differences:
Xcode build has no entitlements and has linker-signed
flag:
CodeDirectory v=20400 size=18814 flags=0x20002(adhoc,linker-signed) hashes=585+0 location=embedded
Swift build has entitlement, although it is basically empty, and has no linker-signed
flag:
CodeDirectory v=20400 size=18887 flags=0x2(adhoc) hashes=579+7 location=embedded
Are there any meaningful differences between the xcode builds and swift package manager builds? How can I fix the swift build such that the AuthorizationServices
works there as well?
Unfortunately, there are not many (if any) resources out there to guide me through this. So, I decided to ask here.
Here is the link to the project, in case you wanted to build it: GitHub - seinmon/scrub: Simple macOS cleaner
Thanks