Re: resources in App Bundles. Nearly there.
Re: resources in App Bundles. Nearly there.
- Subject: Re: resources in App Bundles. Nearly there.
- From: Steve Christensen <email@hidden>
- Date: Thu, 19 Jun 2008 14:24:06 -0700
On Jun 19, 2008, at 1:13 PM, Josh de Lioncourt wrote:
I need two very simple pieces of information that I've yet to be
able to discover. I suspect these will be simple questions to
veterans of XCode/Mac development, but if you could just provide
the answers to them, I'll be well on my way to getting these
projects done at last.
1. When using an install script, how does one reference files that
are included within the app bundle. Below is my current script,
which points to a file in the build directory of the project. I
want it to point to a file included in the app bundle instead. The
script is:
install_name_tool -change /usr/local/lib/libirrklang.dylib
@executable_path/libirrklang.dylib "$TARGET_BUILD_DIR/
libirrklang.dylib"
Try this:
# library is at .../foo.app/Contents/MacOS/libirrklang.dylib
install_name_tool -change /usr/local/lib/libirrklang.dylib
@executable_path/libirrklang.dylib "$BUILT_PRODUCTS_DIR/
$EXECUTABLE_FOLDER_PATH/libirrklang.dylib"
2. THe second question is related. I'd like to be able to
reference files that are also included in the app bundle from
within my code. I need a path to supply to the function, so am not
sure how to obtain the path to the innards of the bundle. Here's
an example:
engine->play2D("/users/joshdelioncourt/dev/ProofOfConcept/sound.wav");
This correctly works for files outside the bundle. How can I
provide a path to files included in the package?
For Cocoa:
// soundPath = ".../foo.app/Contents/Resources/sound.wav"
NSString* soundPath = [[NSBundle mainBundle] pathForResource:@"sound"
ofType:@"wav"];
// soundPath = ".../foo.app/Contents/Resources/Sounds/sound.wav"
NSString* soundPath = [[NSBundle mainBundle] pathForResource:@"sound"
ofType:@"wav" inDirectory:@"Sounds"];
For Carbon:
// soundURL = "file://.../foo.app/Contents/Resources/sound.wav"
CFURLRef soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
CFSTR(sound), CFSTR(wave), NULL);
// soundURL = "file://.../foo.app/Contents/Resources/Sounds/sound.wav"
CFURLRef soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
CFSTR(sound), CFSTR(wave), CFSTR(Sounds));
Attachment:
PGP.sig
Description: PGP signature
_______________________________________________
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