Thank you very much for your message.
"Embedding nonstandard code structures in a bundle."
Yes, I read this and tried to adapt it to my case.
You are trying to ship the grasp app.
At least I would like to distribute it as a notarized bundle since users find the current Terminal app too difficult to install and use.
To make my previous post shorter I did not mention the full structure of the final bundle since this is not necessary to get and track the bug (see later).
Grasp4Mac.app
Contents
MacOS
grasp4Mac <- calls Grasp4Mac.sh
Ressource
Grasp4Mac.sh <- check Matlab_runtime and calls run_grasp.sh
----------------------- provided by a colleague and generated by scripts -------------
Grasp
run_grasp.sh <- set variables such as DYLD_LIBRARY_PATH and launches grasp.app
grasp.app
MacOS
prelaunch <-- the main
grasp <-- which calls the MatLab_Runtime libraries
applauncher <-- auxiliary
--------------------------------------------------------------------------------------
The MatLab_Runtime (5 Gb) is external to the bundle and located at /Applications/MATLAB/MATLAB_Runtime/v911
Signing both the embedded bundle (grasp.app) and the bundle (Grasp4Mac.app) is not a problem
Notarizing it is not a problem
Thus I concentrated my efforts on grasp.app launched via run_grasp.sh. It exhibits the same error if SIP is enabled (notarized Grasp4Mac bundle) or if I unset DYLD_LIBRARY_PATH and launches ./run_grasp.sh
In Contents/Info.plist, what value have you set for CFBundleExecutable?
prelaunch
DYLD_LIBRARY_PATH is intended for users running programs from a shell
run_grasp.sh sets DYLD_LIBRARY_PATH and launches grasp.app
I see no indication from your post that you rewrote your library references to be rpath relative.
The MatLAB libraries are already using @rpath. Here an example:
The lib called by "grasp" i.e. the parent of a long list of dependencies.
/bin/maci64/libmwlaunchermain.dylib:
@rpath/libmwlaunchermain.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwi18n.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwfoundation_filesystem.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwctfdatainterfaces.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwctfpackage.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwmcli18nutil.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwmclmcrrt.9.11.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwopccore.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwopcmodel.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwopczippackage.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwfoundation_log.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
@rpath/libmwcpp11compat.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libmwboost_log.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.20.117)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.255.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/runtime/maci64/libmwmclmcrrt.9.11.dylib:
@rpath/libmwmclmcrrt.9.11.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
Note that is calls /bin/mac164/libmwmclmcrrt.9.11.dylib which was already loaded by /bin/maci64/libmwlaunchermain.dylib
Both /bin/mac164 and /bin/maci64 are amongst the RPATHs
May be I should write a script to explore the >3000 MatLab libs and search for something strange. Okay but what shall I search, that's the question!
Could it be that one of the MathLab's libraries checks that DYLD_LIBRARY_PATH is set and that SIP doe not "ignore it" but erase or hide it?
In that case what could be the workaround ?
All the best
Alain