In Xcode start a new project: Framework; I named it Adder. Drag
add2.c(from this post or the linked project files) into Classes. Write declarations of the two functions into a new file
adder.hand drag that in too. I removed the unused Cocoa, Foundation and AppKit Frameworks under External Frameworks .. Build it (Release config).
Now, from the Desktop do:
This is like what we've done before, except for the -F flag which tells the linker where to look for our framework now, at link time. At run time, it will look in a few standard locations, one of which is
~/Library/Frameworks. So move the
Adder/build/Release). And it works:
This one is for a simple "Foundation tool" that loads code from a bundle at runtime. We've seen a bit of that before (here and a few other posts). It makes you appreciate the whole Framework approach, because the natural question is, once I've got it working, where do I put the bundle? You can put it in
Library/Application Supportor something, but it's an issue. The example also introduces the notion of a Protocol.
The code listing for 3 files is given below. The first two,
SimpleMessage.mgo into a new Xcode project: a Cocoa Bundle named SimpleMessage. Set the Principal Class for SimpleMessage: under Resources > Info.plist > Principal Class > SimpleMessage.
Next start a second new Xcode project: Command Line Tool > Foundation, named BundlePrinter. Put in
BundlePrinter.mand another copy of
BundlePrinter.h. Build it.
In Xcode, run BundlePrinter from the Console:
That's the first time I've ever used
goto(and probably the last).