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: Nelson Santos <email@hidden>
- Date: Sun, 11 Mar 2007 11:47:17 -0400
Well everybody,
I finally got it working to my satisfaction. Apparently, it is a
requirement to have the framework project compile into the same build
directory, otherwise the Copy Files build phase cannot find the
framework bundle to copy into the app bundle's Frameworks directory.
However, I am still not crazy about hardcoding the framework project
to build into the same build directory as the app project. If in the
future, I decide to create another app project that embeds the same
framework, I'll have to update the install directory of the framework
project again to point to the new app. And then change it back to
point to the first app if I need to make a change there. ...Unless
I point the build directory of all three projects to the same place.
Is this the right way to setup these projects??
Nelson
On Mar 11, 2007, at 10:45 AM, Nelson Santos wrote:
Hi Chris,
Thanks for the response. Am I literally supposed to put
"@executable_path/../frameworks" into the installation path build
setting? With that value in there, after building my Cocoa app, two
folders are created on my hard disk's root folder. One called
"@executable_path", and another one called "Frameworks" with my
framework built in there.
I was able to locate the Apple document "Framework Programming
Guide" ("Creating A Framework" page). I am using this document and
your email to try to set up my build settings but I'm not getting
very far.
One thing the document tells me to do (that I am trying to avoid
doing) is setting up my framework to build into the same folder as my
app. I don't want to hardcode my framework to build into the folder
of one app. I want it to either built into its own directory, or set
a relative path to the app I am building at the time so that it's
more flexible. I wouldn't think that a framework MUST be built in
the same directory as the app build directory for me to get a
framework embedded in my app bundle. Am I wrong in thinking that?
Nelson
On Mar 11, 2007, at 1:47 AM, Chris Hanson wrote:
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
** ACCEPT: CRM114 PASS osb unique microgroom Matcher **CLASSIFY
fails; success probability: 0.5000 pR: 0.0000
Best match to file #0 (nonspam.css) prob: 0.5000 pR: 0.0000 Total
features in input file: 4928
#0 (nonspam.css): features: 1, hits: 0, prob: 5.00e-01, pR: 0.00#1
(spam.css): features: 1, hits: 0, prob: 5.00e-01, pR: 0.00
_______________________________________________
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
_______________________________________________
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