In the Apple documentation they are referring to 2 types of frameworks, public ones and private ones.
The public ones you find in /System/Library/Frameworks and /Library/Frameworks.
Now for me, its not a good idea to put my frameworks in a public place, so thats why I opt to create a private framework in my own location (later on its a bit more difficult to use it , but at least I have full control over it).
The first thing we have to do is to startup XCode , and select File>New Project. In the popup that follows you select 'Cocoa Framework'
And click the 'next' button, you now get the opportunity to give a name to your framework.
In a next step, you'll add files, debug them etc etc (the usual development so to speak).
At some time you'll be ready for releasing the framework you made.
Of course , if you want to use your framework in other development projects you need to 'publish' your .h files (your header files).
And this you do in the project browser :

As you notice in the picture, you select in the project explorer 'Targets/
The second column says 'Role', now file by file you can change the role (you do this by clicking on the small triangle, you then get a popup with 3 choices).
Its important to change the ones you want to be public , by default they are all 'project'.
A last step is to build the framework and save it some where. A good convention is to save all your frameworks in a location called 'frameworks' (just like Apple does).
Changing the location you do in the project settings (XCode>Project>Edit Proj

And now you build it and voila you have a framework.
No comments:
Post a Comment