You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xcnew links Xcode internal dynamic frameworks like IDEFoundation.framework and DVTFoundation.framework.
To find these frameworks, xcnew also set its runpath to $DEVELOPER_DIR/../{Frameworks,SharedFrameworks,PlugIns} where $DEVELOPER_DIR points the current Xcode at link time.
Thus if the path to Xcode is changed, xcnew consistently fails to link necessary frameworks.
Of course runpath can be updated with install_name_tool so it doesn't a big problem for experts.
However, I think I should not assume all users are familiar with such a deep knowledge.
This problem can be avoided if xcnew doesn't rely on runpath but loads those frameworks in other way.
There's two options I think:
A. Implement a custom linker and set its path to LC_LOAD_DYLINKER (ref: https://stackoverflow.com/q/10028639/6918498)
B. Implement a wrapper to set DYLD_FRAMEWORK_PATH and so on before running the main program and
dynamically load classes in IDEFoundation and DVTFoundation.
https://github.com/octoml/macho-dyld seems to be a good example of the option A but it looks too difficult for me to implement the full set API of dyld (macho-dyld says it lacks some important features like loading with install name).
So the option B may be better.
Actually it cannot be done because dyld works before the main entry point runs.
The steps to achieve the goal would be:
Locate Xcode.app bundle from the current user's $DEVELOPER_DIR at runtime
For retrieving $DEVELOPER_DIR value, xcselect.h has nice API
Analyze Xcode's mach-o binary to get the correct runpaths (LC_RPATH) and embeded environment variables (LC_DYLD_ENVIRONMENT)
Set DYLD_FRAMEWORK_PATH or so to the running environment
To enable the environment update, exec the current process again
Run the main program
The text was updated successfully, but these errors were encountered:
manicmaniac
changed the title
dyld failed after Xcode.app is moved
dyld fails after Xcode.app is moved
Aug 12, 2022
xcnew links Xcode internal dynamic frameworks like IDEFoundation.framework and DVTFoundation.framework.
To find these frameworks, xcnew also set its runpath to
$DEVELOPER_DIR/../{Frameworks,SharedFrameworks,PlugIns}
where$DEVELOPER_DIR
points the current Xcode at link time.Thus if the path to Xcode is changed, xcnew consistently fails to link necessary frameworks.
Of course runpath can be updated with
install_name_tool
so it doesn't a big problem for experts.However, I think I should not assume all users are familiar with such a deep knowledge.
This problem can be avoided if xcnew doesn't rely on runpath but loads those frameworks in other way.
There's two options I think:
A. Implement a custom linker and set its path to
LC_LOAD_DYLINKER
(ref: https://stackoverflow.com/q/10028639/6918498)B. Implement a wrapper to set
DYLD_FRAMEWORK_PATH
and so on before running the main program anddynamically load classes in IDEFoundation and DVTFoundation.
https://github.com/octoml/macho-dyld seems to be a good example of the option A but it looks too difficult for me to implement the full set API of dyld (macho-dyld says it lacks some important features like loading with install name).
So the option B may be better.
Actually it cannot be done because dyld works before the main entry point runs.
The steps to achieve the goal would be:
LC_RPATH
) and embeded environment variables (LC_DYLD_ENVIRONMENT
)DYLD_FRAMEWORK_PATH
or so to the running environmentexec
the current process againThe text was updated successfully, but these errors were encountered: