Error: "dyld: Library not loaded" after code signing

I'm working on a MacOS desktop Electron app that is for distribution outside the app store using Developer ID. Before code signing, the app opened and was working well. But after code signing, I get the following error.

stderr:dyld: Library not loaded: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
Referenced from: /Users/home/Desktop/electron-start/dist/mac-arm64/electron1.app/Contents/Frameworks/R.framework/Versions/3.5/Resources/bin/exec/R
  Reason: image not found

Before code signing I think the file was looking for a path within the app

/Users/home/Desktop/electron-start/dist/mac-arm64/electron1.app/Contents/Frameworks/R.framework/Versions/3.5/Resources/bin/exec/R

But now I think the file is looking for a path outside

Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib

I used this entitlements file:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
	    <true/>
	    <key>com.apple.security.cs.disable-library-validation</key>
	    <true/>
	    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
	    <true/>

</dict>
</plist>

Can anyone please help me? I've looked at many places and willing to learn. Thanks for your time. I really appreciate it.

I used this entitlements file:

com.apple.security.cs.disable-library-validation

Do not disable library validation unless your process needs to load third-party code, for example, to support third-party plug-ins. I regularly see folks disable library validation in situations like this and it actively makes things worse.

However, that’s unlikely to be the cause of the specific problem you’re reporting here. As to what is causing that, it’s hard to say for sure without more info. Lets start with the basics: Is this R framework something that you control?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for reaching out!

Yes, R.framework contains the R statistical software package. With a node js backend I call R.exe file to run an R script I created. Before code signing the R.framework, it worked. But since code signing, the path to the R.exe file gets changed.

I also followed your very helpful manual steps to codesign inside out and placed R.framework under the Frameworks folder. The code signing and notarization is actually successful, but the app doesn't work.

Hmmm, node.js and R framework; that’s certainly a challenge. My advice here is that you open a DTS tech support incident so that I can allocate more time to helping you one-on-one.

Make sure you reference this DevForums thread when you open the TSI; that’ll ensure it gets routed to me promptly.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Error: "dyld: Library not loaded" after code signing
 
 
Q