Reputation: 2392
Is it possible to create a system-wide runtime library that makes available a certain set of runtime classes available to all system running processes? The classes should be available in the sense that calling NSClassFromString
for the class name from any Cocoa process will return a valid class.
Note: I can't load the library using NSBundle
since I don't have access to some of the processes' code. To be more specific, I am trying to have some classes available to Apple's "Interface Builder Cocoa Touch Tool" process. For full details on why I need this, please refer to this post.
Upvotes: 0
Views: 116
Reputation: 29886
In a word, no.
In a few more words: I see two vectors to make this happen: force every process to dyld your framework somehow, or patch an existing system library that every Cocoa process will load to contain your classes. Neither of these solutions are going to be useful for anything other than "just on your machine."
If you want a "just on your machine" solution, then an easier one would be to write a script that induces GDB/LLDB to attach to the process, causes your library to be loaded, and then detaches. That will be much easier than either of the hypothetical approaches above. Such a process might look like this:
your-machine:~ you$ lldb
(lldb) attach Finder
Process 331 stopped
Executable module set to "/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder".
Architecture set to: x86_64-apple-macosx.
(lldb) expr (char)[[NSBundle bundleWithPath:@"/Path/To/Your/Framework.framework"] load]
(char) $0 = '\x01'
(lldb) detach
Detaching from process 331
Process 331 detached
(lldb) quit
your-machine:~ you$
As you must already know, the Xcode plug-in interface is not public, so you are already in unsupported, likely-to-change-out-from-under-you territory here.
Upvotes: 1