Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How To Build Cocoa Frameworks

How To Build Cocoa Frameworks
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 20, 2001, 09:56 PM
 
My Cocoa adventures continue, this time I was experimenting with building cocoa frameworks. So I started a new PB project with "Cocoa Framework"; created a couple of class and header files -just plain empty ones, since I wanted it to compile trivialy. I set "Principal class" name to "myFramework" and hit the compile hammer. Kaboom, it builds perfectly -not a surprise of course- but where on earth is the framework? I looked around (HOME)/Library/Frameworks and found nothing. I looked in the PB project folder and found nothing. Any one knows how to do this?

[ 06-21-2001: Message edited by: DaGuy ]
iMac 17" G4 800MHZ & 768 SDRAM
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 21, 2001, 01:31 AM
 
Uhm... It will go into your standard build location, which is either a directory you specifically set for builds or inside the project folder...

Make that it *SHOULD* :/
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 21, 2001, 08:33 AM
 
Well, I don't know what happened but I tried again and it worked this time. The files were in my PB project folder -as usual.

Anyway, now I have a different question. Even if I am using a framework, should I
still put the "@class AFrameworkClass, AnotherFrameWorkClass;" in the header files of classes that will be making use of the framework? It seems like I should, I couldn't get a clean compile without that directive. I thought that by using a framework one avoided such things?
iMac 17" G4 800MHZ & 768 SDRAM
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 21, 2001, 01:05 PM
 
Originally posted by DaGuy:
<STRONG>Anyway, now I have a different question. Even if I am using a framework, should I
still put the "@class AFrameworkClass, AnotherFrameWorkClass;" in the header files of classes that will be making use of the framework? It seems like I should, I couldn't get a clean compile without that directive. I thought that by using a framework one avoided such things? </STRONG>
Uhm... You need to import the framework headers so that Project Builder knows about the class, or you can specify that it's a class by using the @class directive. How else can it tell that AFrameworkClass is a class and not, say, some obscure struct?
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 21, 2001, 10:42 PM
 
Thanks for your help Angus_D. My confusion is about the resulting MyFramework.framework thingy (bundle?) that lives in Products folder in PB. I thought that it would be self sufficient just like a .jar file in Java. I am crawling with this experiment bear with me... Here is what I am doing and hope to do:

0. Create the framework project as described in one of my prior postings. This works.

1. Create .h and .m files as I normally would in an app project. Correct?

2. Compile and obtain the MyFramework.framework thing. This is fine -I think.

3. What do I have to do so that when I import the resulting framework the headers will be imported along with the MyFramework.framework thing.?

4. What is the rationale for not packaging the .h files in the MyFrameWork.framework thing? Is it because it leads to easy browsing of the class methods?

5. I gather that the MyFramework.framework thingy contains compiled binary code corresponding to the .m files; correct?

6. What is the correct name for what I am calling the thingy? The icon looks like MacOS classic extentsion.

Thanks again!
iMac 17" G4 800MHZ & 768 SDRAM
     
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status: Offline
Reply With Quote
Jun 22, 2001, 01:58 AM
 
Originally posted by DaGuy:
<STRONG>What is the correct name for what I am calling the thingy?</STRONG>
Bundle?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 22, 2001, 01:43 PM
 
Originally posted by DaGuy:
<STRONG>0. Create the framework project as described in one of my prior postings. This works.

1. Create .h and .m files as I normally would in an app project. Correct?

2. Compile and obtain the MyFramework.framework thing. This is fine -I think.

3. What do I have to do so that when I import the resulting framework the headers will be imported along with the MyFramework.framework thing.?</STRONG>
You have to import the headers. When you use the Cocoa frameworks, you have to put #import &lt;Cocoa/Cocoa.h&gt; whereever you use the framework (or you can use Foundation/Foundation.h if you are only using Foundation functions). So you would probably need to #import &lt;MyFramework/MyFramework.h&gt;, which you might need to create, and should #import all of the other headers in your framework (see the headers in Foundation or AppKit for an example -- or any other framework that works like this, in fact, e.g. OmniNetworking or something).

<STRONG>4. What is the rationale for not packaging the .h files in the MyFrameWork.framework thing? Is it because it leads to easy browsing of the class methods?</STRONG>
They should be included, otherwise you are not going to be able to use the framework. If they are not being included, I am presuming they're not marked as Public in the Target Settings.

<STRONG>5. I gather that the MyFramework.framework thingy contains compiled binary code corresponding to the .m files; correct?
</STRONG>

Yes. Also the headers, or at least the public ones (Often headers used for internal bits of the framework are kept back, since they are not needed for people using the framework, only for development of the framework itself).

<STRONG>6. What is the correct name for what I am calling the thingy? The icon looks like MacOS classic extentsion.</STRONG>
It's a framework, which is a special type of bundle. See here: http://developer.apple.com/techpubs/...rameworks.html
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 22, 2001, 07:31 PM
 
Boy this is a good forum! Thanks for the feedback, slowly but surely I am getting this Cocoa stuff down.

iMac 17" G4 800MHZ & 768 SDRAM
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jun 22, 2001, 09:31 PM
 
Just got back from following up on the suggestions. Well, I finally got things to work. I guess a combination of not knowing what was up with framework bundle and way too many options in target panel led to some messy outcomes. I think I know what I need to know for the moment. Thanks for helping me get there.
iMac 17" G4 800MHZ & 768 SDRAM
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:23 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2