Re: Where to install custom framework to support a plug-in architecture?
Re: Where to install custom framework to support a plug-in architecture?
- Subject: Re: Where to install custom framework to support a plug-in architecture?
- From: Chris Hanson <email@hidden>
- Date: Mon, 13 Feb 2012 11:25:34 -0800
You can (and should) put it in the app bundle itself.
Dynamic libraries (dylibs) on Darwin have an "Install Name" embedded into them. This Install Name is copied into anything that links the dylib, so it can be located at run time by the dynamic loader (dyld).
For system frameworks, this is the full path at which the framework lives - for example, the dylib inside Foundation.framework has its full path as its Install Name.
For app frameworks, though, you can build them with an Install Name that will cause them to be *searched for* at run time - one that starts with @rpath.
For your framework's target, add this build setting to cause its Install Name to have an @rpath prefix rather than the path from its INSTALL_PATH build setting:
DYLIB_INSTALL_NAME_BASE = @rpath
In your application, you need to add an additional build setting that tells dyld where to look up things that start with @rpath. This is what the Runpath Search Paths build setting is for. Here's a simple setting for your application:
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
This path will actually be built into your application binary, and will cause your application to search for anything that starts with @rpath in its embedded Frameworks directory.
How does this affect your plug-ins? Well, just like your application, your plug-ins when linking against your framework will copy its Install Name into them. Then when you go to load a plug-in, dyld will fix up its linkage, notice an Install Name that starts with @rpath, and then search for what matches that @rpath -- and it'll find your framework!
Why? Because dyld always looks for @rpath matches in the Runpath Search Paths of the executable for the running process -- which is your application! So you don't even need to specify any additional settings for your plug-ins, just link them against the framework.
-- Chris
On Feb 11, 2012, at 10:32 PM, Erik Stainsby wrote:
> I'm trying to set up a lightweight custom framework against which I can hang a plugin architecture ~ dynamic bundle loading.
>
> Where would you place such a framework ? I have been targeting ~/Library/Frameworks for the moment, but suspect there is a scheme which would allow this to all be contained with the Application Support context for my app or in the app bundle itself. But of course, the examples I can find all refer to XC3. I'm quite happy to read documentation if anyone can point me at something reasonably current.
>
> Clues gratefully appreciated.
> Erik
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden