Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chris Corbyn

macrumors newbie
Original poster
Jun 28, 2008
17
0
Melbourne, Australia
Hi,

I'm trying to create my first Cocoa framework. The way I'm doing this is with two projects: one for the framework itself; the other for a test app that implements the features of the framework.

So I'm using Xcode's cross-project reference feature to make the framework a dependency of the test application.

However, when I build the test app, it correctly builds the framework first but then complains that my framework's master header file cannot be found.

I must be missing something, but I've basically followed all the steps outlined here:

http://developer.apple.com/mac/libr...al/BPFrameworks/Tasks/CreatingFrameworks.html

I've:

  • Created the two projects: one as a framework, the other as a standard "bundle"
  • Specified @executable_path/../Frameworks as the Installation Directory for the framework, as shown in the image.
    framework-settings.png
  • Specified a Copy Files build phase the puts the headers in the framework's Headers directory (also shown in the image above).
  • Added the framework project to the test app project
  • Specified that the framework is a dependency of my test app
    testapp-dependency.png
  • Created a Copy Files build phase that copies the framework product to the Frameworks directory of my test app
    testapp-copy-framework.png
  • Added the framework to the link phase of the test app (shown in the image above)

However, when I build the test app I'm getting a build error due to the fact the header can't be found.

testapp-build-fail.png


The header is there and the framework was correctly copied:

Code:
chrisbook:CioccolataTest chris$ ls -l build/Debug/CioccolataTest.webapp/Frameworks/Cioccolata.framework/Headers/Cioccolata.h 
-rw-r--r--  1 chris  staff  201 20 Apr 18:39 build/Debug/CioccolataTest.webapp/Frameworks/Cioccolata.framework/Headers/Cioccolata.h

What have I missed? :confused: The "Frameworks" directory of a bundle should be searched for the framework, right? And the Headers directory does go directly in the top level directory of the framework bundle?
 
I played around with my Copy Files build phase that copies the framework into the Frameworks directory... for some reason when I changed the destination back to "Frameworks" again it has started copying the framework bundle to Contents/Frameworks, not just Frameworks in the top level of the bundle. This looks correct, but I'm still getting the same build error that my framework's header file is not found.
 
Ok, does this make any sense?

I manually copied the framework bundle into /Library/Frameworks (absolute path) and tried to build the application again. It worked.

I'm new to all this, so I wonder if somebody can explain. When I'm creating an embedded framework (one that will be contained within the application bundle itself) do I have to install the compiled framework into a system directory in order to build against it? Is there any way to avoid this?

I tried changing the "Framework Search Paths" build setting of my application to $(SRCROOT)/** but that didn't fix the issue.
 
Problem solved: I hadn't checked the little box that includes the framework in my target. For anybody having the same issue:

In the Groups & Files area, select your references Xcode project.
In the pane that lists the products in that project, the far right column (after File Name, Code, etc, has a little target icon for the column heading. You need to check that box.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.