Re: Including resources with a shared library
Re: Including resources with a shared library
- Subject: Re: Including resources with a shared library
- From: Chris Espinosa <email@hidden>
- Date: Mon, 31 May 2004 08:13:14 -0700
On May 31, 2004, at 6:24 AM, Brian Greenstone wrote:
> I'm building a plug-in for Maya 6, and I've switched from CFM on
> CodeWarrior to Mach-o with Xcode. One major problem that's come up is
> that Xcode won't let me include old style Resources (.rsrc) in the
> file it outputs. It lets me include the .rsrc file in the project,
> and it never spits out any errors or warnings, but the final file has
> no resource fork.
>
> I'd also like to update this old plug-in to use .nib's instead of
> .rsrc's, but I haven't found any way to make a package out of a shared
> lib, so what's the recommended way to include nib resources in a
> shared lib with Xcode?
In a bundlized Mach-O executable, Resource Manager resources should be
in a data-fork resource file in the Resources folder of your package,
rather than in the resource fork of the executable. (Mach-O
executables shouldn't have a data fork, as several Mach-O processing
tools, like reprebind, will strip them.)
You get a choice of how to handle your resource file, depending on
which Build Phase it belongs to. (Open up your target using the b#
turndown on the target to see the build phases). If your .rsrc file is
in the Resources build phase, it'll be copied verbatim into the
Resources folder, and you'll need to use Resource Manager calls to open
it. If it's in the ResourceManager Resources build phase, it'll be
merged into your <bundlename>.rsrc resource file, and will be opened
automatically when your bundle is loaded. (Note that if your bundle is
localized, these will be in the English.lproj folder, and you may have
parallel resource files for other languages)
Your target may not have a ResourceManager Resources build phase; you
can add one by selecting the target and choosing New Build Phase b#
ResourceManager Resources from the Project menu. Then drag your
resource file under it.
To merge your resource file into the bundleName.rsrc file, Xcode uses
the /Developer/Tools/ResMerger tool. Unfortunately this tool does
poorly at handling mixed-fork resource files, so it helps if all your
resource files are all in the same fork (preferably the data fork)
before merging. Moving a resource file from the resource fork to the
data fork can be done easily at the command line with standard unix
commands:
cp foo.rsrc/..namedfork/rsrc bar.rsrc; rm foo.rsrc; mv bar.rsrc foo.rsrc
Having your resources in the data fork also means your bundle can be
stored on non-HFS file systems, moved with Unix and Windows file and
network utilities (such as ftp), etc. without requiring special
handling.
The Xcode documentation mentions these points
(http://developer.apple.com/documentation/DeveloperTools/Conceptual/
Build_System/Build_Phases/Build_Phases.html) but is a little sparse on
the details.
Chris Espinosa
Apple
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.