Building the Latest CPTestApp in the CorePlot Project

CorePlot.jpg

Well... I'm stumped. I had been working on a few things for the unit testing framework yesterday, and today I wanted to look at this problem that had been reported on the Google Code site. Basically, there's a build problem, and I wanted to track it down.

First thing: build the code and reproduce the issue. It builds fine - I can't see the error, but when I run it within Xcode, I get the following on the Console:

    [Session started at 2009-02-20 12:05:37 -0600.]
    dyld: Library not loaded: @loader_path/../Frameworks/CorePlot.framework/Versions/
        A/CorePlot
    Referenced from: /Users/drbob/Developer/core-plot/examples/CPTestApp/build/Debug/
        CPTestApp.app/Contents/MacOS/CPTestApp
    Reason: image not found

  The Debugger has exited due to signal 5 (SIGTRAP).The Debugger has exited due to
      signal 5 (SIGTRAP).

OK, this should be easy - it's got to be that the CorePlot.framework isn't properly in the project and that's what's missing. So I looked into that. But it's there. Just where it should be. Then I dug into the built CPTestApp.app wrapper and right where it's supposed to be is the framework! I'm stumped.

I looked at the project settings... nothing popped out at me. I cleared the Xcode project file and reloaded it from the repo... no difference. I even did what I thought should have been done and added in the CorePlot.framework to the Linked Frameworks 'folder' in the project, and still nothing.

I'm blown away! So I finally shot an email to the mailing list and we'll see if we can't find out what's up. I'm really stumped. It used to work!

UPDATE: HA! I got it figured out. First, the path for the library is encoded into the Framework - not in the app using the framework. OK, now that I knew that, I started looking at the CorePlot Framework build parameters. I noticed the one that I was looking for in the Deployment section:

Target 201CCorePlot201D Info

Originally, the Installation Directory was set to:

  @loader_path/../Frameworks

and that was what was being set in the dynamic library, and compiled into the app's executable. What I needed to change was the path to:

  @loader_path/../Resources/Frameworks

and then it was able to find the framework and run.

OK, this wasn't obvious in the least. I Googled this guy and came up with nothing other than the fact that the name was in the shared library - which I had remembered as soon as I was reading the post. So, at least now, I can see the error, and hopefully get a handle on it.

UPDATE: Drew commented that he had changed the @loader_path to @executable_path a while back, but that there may have been issues in the merge that was done to get the testing code working. So I emailed back that he's free to change it back and I'll just pick up the right version in the next 'svn update'. Sounds good to me. Glad to see I wasn't totally missing it.

[2/21] UPDATE: Barry pointed out that @loader_path is the right value - but the project was not configured to copy the framework into the right location. So he fixed that. It builds fine now.