Re: Framework project config & accessing resources in the framework bundle.
Re: Framework project config & accessing resources in the framework bundle.
- Subject: Re: Framework project config & accessing resources in the framework bundle.
- From: Chris Hanson <email@hidden>
- Date: Sat, 10 Mar 2007 22:47:40 -0800
On Mar 10, 2007, at 6:33 AM, Nelson Santos wrote:
The only successful way that I've managed to do it is with the
following code from within my Cocoa project:
NSBundle *bundle = [NSBundle bundleForClass:[MyFrameworkClass
class]];
NSString *path = [bundle
pathForResource:@"AFileInTheFrameworkBundle" ofType:@"plist"];
This is correct. You need to explicitly specify that you're loading
resources from your framework bundle, rather than from (say) the
result of +[NSBundle mainBundle]. That will always be whatever has
linked against your framework.
This works fine, but upon examining the resulting bundle path and
the resource path, I noticed that they point to the framework bundle
located in my user library frameworks directory. I don't want
that. I want it to fetch the resource from the framework folder
found inside the cocoa application bundle that I am building. My
understanding of the search tree is that a framework is first
searched for within the App bundle (and it is indeed there). But
it's not doing that.
This is incorrect. A framework is searched for in the location that
is specified in the framework binary itself. Mac OS X has
considerably less "look for a library in this set of default search
paths" behavior than, say, the traditional Mac OS did.
You should set the installation path of your framework to
"@executable_path/../frameworks". This will ensure that the
application using your framework actually looks for it inside its
embedded Frameworks directory.
You can probably use Google search to find step-by-step tutorials on
embedding Cocoa frameworks in applications.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden