Using libraries in apps.

Ok, i'm gonna show everyone how to use a dynamic link library in your code. I am doing this in my apps here, as a framework type thing, so i can code less and make easier apps. Below is the source code for a sample app i made that just resprings using a function from a dynamic link library (.dylib)

We use .mm here, as .m is for objective-c code, .h is for header file, and .mm allows c, c++, and objective-c combined, which in this case we must use for the library.

The product:
librespring.dylib
respring

you will notice that ./respring in terminal will not work unless you have the dylib, proving its dependence on it, and how it works. Note that compiling a dylib requires no main() function, and is created by passing the compiler flag "-dynamiclib". We include the current directory when compiling the app with "-L./", so that we can then link against the library we just created by passing the flag "-lrespring". It automatically looks for librespring.dylib as your dylib must have the prefix "lib" or else you will have to use dlopen, which is a more compicated alternative.