Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#1178 closed defect (notabug)

problems loading bundle: can't determine class name

Reported by: informatimago Owned by:
Priority: normal Milestone:
Component: IDE Version: trunk
Keywords: Cc:

Description

When run:

(require :objc-support)
(require :cocoa)

we get this error:

problems loading bundle: can't determine class name
   [Condition of type SIMPLE-ERROR]

Restarts:

Backtrace:
  0: (gui::init-cocoa-ide)
  1: ((:internal gui::cocoa-startup gui::start-cocoa-ide))

We don't get it if we run only (require :cocoa).

The situation occurs when we load libraries that use only objc-support without using cocoa.

Change History (3)

comment:1 Changed 6 years ago by gb

  • Resolution set to notabug
  • Status changed from new to closed

The application's NSBundle object (actually, the equivalent CFBundle) can only be initialized once; the path to the bundle is determined by

  1. The value of the environment variable CFBundlePath (IIRC).
  2. The path of the current executable, e.g., for an executable file at ".../Foo.app/Contents/MacOS/foo", the bundle's path is ".../Foo.app/".

If the environment variable isn't set and the executable isn't located in a bundle directory, an empty CFBundle object is created, and that happens when some library is opened, and the library in question is opened when the Cocoa libraries are opened, and opening the Cocoa libraries is one of the things that (REQUIRE "OBJC-SUPPORT") does.

(REQUIRE "COCOA") does something like:

  1. Create a temporary bundle, populate it with an Info.plist and other files, and set the environment variable to refer to the temporary bundle.
  2. (REQUIRE "OBJC-SUPPORT")
  3. load other files and initialize the IDE. That can't work if the application bundle is empty.

It's indeed useful to run some non-GUI Cocoa code from a non-bundled application, but the way that CFBundle is initialized makes it non-trivial to change your mind and try to become a bundled application. ("non-trivial" may be "impossible". I don't know or care; if what you're talking about made any sense to anyone but you, I might care more than I do.)

comment:2 Changed 6 years ago by informatimago

I assume this would make sense for somebody else too.

So far I didn't think about it, and just required :cocoa in com.informatimago.objcl.

But Leo Liu's question about :objc-support made me realize that objcl doesn't depend on cocoa, but only on objc-support. So I changed the require in this library.

Now the thing is that when we use asdf to load the application, quicklisp loads the libraries such as objcl before loading the files of the application. So there's a (require :objc-support) that gets evaluated before the (require :cocoa) in the application sources.

Similarly, setting the environment variable in the application sources would come too late.

For now, I've reverted to (require :cocoa) in the library, but one may think this problem will occur again, if people write libraries depending only on Objective-C support, to be used in applications depending on Cocoa.

Last edited 6 years ago by informatimago (previous) (diff)

comment:3 Changed 6 years ago by gb

Please tell Apple that they should change reality (the implementation of CFBundle) to meet your understanding of it. Please waste lots of time doing this, and don't waste any more of mine.

Note: See TracTickets for help on using tickets.