Professional Web Applications Themes

Including framework in screensaver bundle. - Mac Programming

I'm going crazy trying to include a framework in my screensaver (.saver) bundle. executable_path works with (.app) bundles but I'm not so sure of (.saver) bundles... I did all of the following steps successfully: (1) Checked the framework (AGRegex.framework) used an install path of executable_path/../Frameworks (2) Included the framework in my project. (3) Created the copy build phase to copy the framework into the bundle. (4) Compiles fine. (5) The framework is included in the bundle at RandomWeb.saver/Contents/Frameworks/AGRegex.framework Now when I run the Screensaver, in the terminal, via SaverLab, or System preferences I get an error. On the Terminal I ...

  1. #1

    Default Including framework in screensaver bundle.

    I'm going crazy trying to include a framework in my screensaver (.saver)
    bundle. executable_path works with (.app) bundles but I'm not so sure
    of (.saver) bundles...

    I did all of the following steps successfully:

    (1) Checked the framework (AGRegex.framework) used an install path of
    executable_path/../Frameworks

    (2) Included the framework in my project.

    (3) Created the copy build phase to copy the framework into the bundle.

    (4) Compiles fine.

    (5) The framework is included in the bundle at
    RandomWeb.saver/Contents/Frameworks/AGRegex.framework

    Now when I run the Screensaver, in the terminal, via SaverLab, or System
    preferences I get an error.

    On the Terminal I ran the command:

    /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine
    -module RandomWeb -foreground

    2004-07-07 18:47:30.697 ScreenSaverEngine[1292] *** -[NSBundle load]:
    Error loading code /Users/g4b3/Library/Screen
    Savers/RandomWeb.saver/Contents/MacOS/RandomWeb for bundle
    /Users/g4b3/Library/Screen Savers/RandomWeb.saver, error code 0 (link
    edit error code 0, error number 2 (dyld:
    /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine
    can't open library:
    executable_path/../Frameworks/AGRegex.framework/Versions/A/AGRegex (No
    such file or directory, errno = 2)


    Do you think its looking for the framework in the ScreenSaverEngine.app?
    How do I tell it to use the .saver bundle...


    Thanks for any help,
    Gabe (or send to edu)
    Gabriel Guest

  2. #2

    Default Re: Including framework in screensaver bundle.

    In article <net>,
    Gabriel Handford <edu> wrote:
     

    [...]
     

    Yes
     

    I don't think you can do that. I believe you'll have to load the framework
    manually with CFBundle.

    hth

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  3. #3

    Default Re: Including framework in screensaver bundle.

    Miro Jurisic wrote:
     
    >
    >
    > [...]
    >

    >
    >
    > Yes
    >

    >
    >
    > I don't think you can do that. I believe you'll have to load the framework
    > manually with CFBundle.
    >
    > hth
    >
    > meeroh
    >[/ref]

    Thanks for the reply, I'm trying to figure out when and how to load the framework manually. Do I
    have to use CFBundle? I was trying the following code:

    NSString *path = [NSBundle pathForResource: "AGRegex" ofType: "framework" inDirectory: "Frameworks"];
    NSLog("Resource path: %", path);
    NSBundle *bundle = [NSBundle bundleWithPath:path];
    [bundle load];

    But that code never gets executed because I get the original "ScreenSaverEngine can't open library"
    before anything happens.. How do I "bootstrap" it? Is this the wrong approach?

    -gabe
    Gabriel Guest

  4. #4

    Default Re: Including framework in screensaver bundle.

    Gabriel Handford wrote:
     
    >>
    >>
    >>
    >> [...]
    >>
    >> 
    >>
    >>
    >>
    >> Yes
    >>
    >> 
    >>
    >>
    >>
    >> I don't think you can do that. I believe you'll have to load the
    >> framework manually with CFBundle.
    >>
    >> hth
    >>
    >> meeroh
    >>[/ref]
    >
    > Thanks for the reply, I'm trying to figure out when and how to load the
    > framework manually. Do I have to use CFBundle? I was trying the
    > following code:
    >
    > NSString *path = [NSBundle pathForResource: "AGRegex" ofType:
    > "framework" inDirectory: "Frameworks"];
    > NSLog("Resource path: %", path);
    > NSBundle *bundle = [NSBundle bundleWithPath:path];
    > [bundle load];
    >
    > But that code never gets executed because I get the original
    > "ScreenSaverEngine can't open library" before anything happens.. How do
    > I "bootstrap" it? Is this the wrong approach?
    >
    > -gabe[/ref]

    If I comment out all the code using the framework and recompile (but still have the framework in the
    ..saver bundle), the following code works (and loads the class):

    NSBundle *myBundle = [NSBundle bundleForClass: [self class]];
    NSString *s = [NSString stringWithFormat:"%/AGRegex.framework", [myBundle privateFrameworksPath]];
    NSBundle *bundle = [NSBundle bundleWithPath:s];
    [bundle load];

    Class regexClass = [bundle classNamed:"AGRegex"];
    id booyah = [[regexClass alloc] initWithPattern:"http://|/"];
    NSLog("Class: %, instance: %", regexClass, booyah);


    I suppose I can just load the classes manually at runtime? It seems like such a hack though...

    Note that: [NSBundle bundleForClass: [self class]]; gives me the .saver bundle
    [NSBundle mainBundle] gives me the ScreenSaver.app bundle.

    Which leads me back to the original problem... I need to tell the ScreenSaverEngine.app to load the
    framework from the .saver bundle.

    -gabe
    Gabriel Guest

  5. #5

    Default Re: Including framework in screensaver bundle.

    On Thu, 8 Jul 2004, Gabriel Handford wrote:
     

    It's not much of a hack. Objective-C explicitly supports runtime lookup of
    classes, and the technique you're using is even a recommended method by
    Apple to allow a program to use WebKit without requiring it to be present.
    This approach looks pretty good to me.

    On a totally different note, you should be using
    -stringByAppendingPathComponent instead of that crazy -stringWithFormat:
    call to build paths.
    Michael Guest

Similar Threads

  1. Bundle::CPAN: File lacking bundle definition
    By Jim Keenan in forum PERL Modules
    Replies: 0
    Last Post: April 1st, 02:23 PM
  2. framework referencing framework?
    By Mike in forum Mac Programming
    Replies: 3
    Last Post: January 26th, 04:56 PM
  3. Including help info in plug-in bundle
    By Eric in forum Mac Programming
    Replies: 0
    Last Post: October 22nd, 02:16 AM
  4. Bundle::DBI
    By Laura Liotus in forum PERL Modules
    Replies: 0
    Last Post: August 26th, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139