Code signing 3rd-party binaries and dylibs with hardened runtime

I'm building an application which bundles several CLI tools and present a GUI for them. 2 of the CLI tools are standalone executables. I've been able to successfully bundle, codesign, and notarize these tools and include them in a "Copy Files" step and placing them in the "Executables" destination.

I'm now attempting to package the remaining CLI tools. They are a mix of executables, dylibs, and configurations files. I've been able to get them working in development by including them in a "Copy Files" step and placing them in the "Resources" destination.

Problems arise when trying to create an Archive for my app to distribute directly. The notarization process complains about the remaining CLI tools not being built with "hardened runtime" enabled. I get around this by signing the tool executables. This allows the app to be notarized successfully. However, when these executables are used, I'm presented with errors like:

Code Block
stat() failed with errno=1 file system relative paths not allowed in hardened programs


I assume this is an issue with the tool's included dylibs not being codesigned as well. After codesigning the dylibs, I receive errors about missing symbols inside the dylibs:

Code Block dyld: Symbol not found: __nw_endpoint_alternative_unknown
  Referenced from: /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
  Expected in: /Users/david/Library/Developer/Xcode/DerivedData/Valet_Lite-defzwmegdslzcagdhpvowwklbsky/Build/Products/Debug/Valet Lite.app/Contents/Resources/php/php-8.0.3/bin/../dylibs/libnetwork.dylib
 in /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork


I've done many hours of researching and debugging and just can't seem to find the right incantation to successfully codesign and notarize my application for distribution. I'm hoping there's just something foundational I'm missing in this whole process that can be rectified easily. Any help is appreciated!
For my general advice on this front see my Signing a Mac Product For Distribution.

As to what’s happening in your specific case, I suspect that:
  1. Your file system relative paths not allowed in hardened programs error is caused by a file-system relative load command in your command-line tools or their libraries.

  2. Your attempts to fix that has broken something fundamental.

My advice is that you back out your current fix for the initial error and see if you can fix it properly. This most likely involves turning all of the library references within your tools into rpath relative ones.

It’s hard to be more specific than that without looking at your project in detail, something that I just don’t have time for here on DevForums. If you’d like one-on-one help with this, open a DTS tech support incident and we can pick things up in that context.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Code signing 3rd-party binaries and dylibs with hardened runtime
 
 
Q