Why should create own library:
- Have a lots of functions which should be reused in series of projects
- share in secret :) (just share the header files)
- Reduce the number of files enclosed the project
Here we go!!!
1. CREATE YOUR LIBRARY:
open Xcode --> New Project -->Select Framework & Library -->Select "Cocoa Touch Static Library" --> Next ( this is an example of Xcode 4.4.1)
2. DEFINE FUNCTIONS:
In TNTLib.h file, declare the function
Choose the type of simulator --> Run project as your way
4. ARCHIVE LIB FOR DEVICE
the target is "IOS device" --> Run project as your way
Create new finder --> paste libTNTDevice.a and libTNTSimulator.a, libTNT.h --> copy libTNTDevice.a --> rename this file as "libTNT.a"
open Teminal --> type "lipo -create libTNTSimulator.a libTNTDevice.a -output libTNT.a" --> Enter
=> this command will replace libTNT.a as a combined file (you must type the path of these files)
In my case, It likes this:
create New Project --> drag the finder which contains (libTNT.a, libTNT.h) -->check "Copy items into....." --> check "Create groups..." --> Next
Import the header file , then call the function you want
I did it with my app successfully . Here is the result: