• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
bundleWithIdentifier: failures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bundleWithIdentifier: failures


  • Subject: bundleWithIdentifier: failures
  • From: Ricky Sharp <email@hidden>
  • Date: Sat, 29 Dec 2007 08:30:21 -0600

I'm being floored by an issue where NSBundle's bundleWithIdentifier: is failing to load one of my frameworks.

I'm doing development with Xcode/IB 3.x (Mac OS X 10.5.1) and in order for my IB Plug-In to access images at both design-time and within the simulator, I created a framework containing those images.

This worked well for my first project (Drills). I would have a simple Cocoa framework installed to ~/Library/Frameworks

The image loading code that my UI framework uses (this code is ultimately called from within IB itself during design time and within the simulator):

+ (NSImage*)imageNamed_II:(NSString*)aName
{
    NSImage*   theImage = nil;

if ((aName != nil) && ([aName length] > 0))
{
theImage = [NSImage imageNamed:aName];

// If the image is not yet loaded, attempt to load it from our image frameworks

if (theImage == nil)
{
NSBundle* theImageBundle =
[NSBundle bundleWithIdentifier:@"com.instantinteractive.internal.images.drills"];


if (theImageBundle != nil)
{
NSString* theImagePath = [theImageBundle pathForImageResource:aName];


if ((theImagePath != nil) && ([theImagePath length] > 0))
{
theImage = [[[NSImage alloc] initWithContentsOfFile:theImagePath] autorelease];
[theImage setName:aName];
}
}
}
}


    return theImage;
}

I then extended this code to include a second "if (theImage == nil)" block which would attempt to load the second image bundle should the image not be found in the first.

But, bundleWithIdentifier is always returning nil. I've triple- checked the code, verified that my image framework has a unique name, NSPrincipal class set correctly, that its bundle identifier is correct, etc.

I even started from scratch and used a totally different bundle identifier. In all cases, bringing up System Profiler indeed finds the second image framework and displays info about it correctly. For example, names are correct and its location is also ~/Library/Frameworks

Console doesn't show me any failures. The name of the second framework also only contains English letters and has no spaces anywhere in its name or in its path).

Finally, I even logged out and rebooted a couple of times to ensure that the system wasn't holding on to any cached version (hmm...I wonder if I need to purge prefs anywhere). Still no luck. I even verified that my system has only one copy of the framework (in ~/ Library/Frameworks); i.e. I removed the copy that Xcode produced in my Projects folder.

Has anyone else had issues in loading frameworks? As a workaround, I'm going to just create a single image framework that will be shared amongst all my projects. Whether or not its one framework or many, my images need to all have unique names, so I won't have any issues putting them all into a single framework.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: bundleWithIdentifier: failures
      • From: Keith Duncan <email@hidden>
    • Re: bundleWithIdentifier: failures
      • From: glenn andreas <email@hidden>
  • Prev by Date: Insert text into NSTextView/NSTextStorage does not work
  • Next by Date: Re: bundleWithIdentifier: failures
  • Previous by thread: Re: Insert text into NSTextView/NSTextStorage does not work
  • Next by thread: Re: bundleWithIdentifier: failures
  • Index(es):
    • Date
    • Thread