1.Open a new "Cocoa Touch Static Library" Project, Name it Logger.
2. Add following snippet to Logger.h and Logger.m
3.In "Build Phase", Make sure your configuration is like below
- In Compile Source : Make sure Logger.m is there.
- In Copy File : Make sure Logger.h is there.
- In Link Binary With Libraries : Add frameworks and dynamic library to it.
- In many cases, your library might import other files, libraries or frameworks. For example, If you import aObject.h in Logger.h and also import bObject.h in Logger.m. Then you need to add aObject.h in in copy file and add aObject.m / bObject.h / bObject.m in compile source.
- When using ios dynamic library (e.g. libsqlite.dylib libz.dylib) , you still have to include these libraries in the new project that using Logger.a
In Build Setting, make sure Build Active Architecture Only is set to No, then Xcode will build a universal library including armv7,armv7s and arm64.
5. In Products Folder, right click to show libLogger.a in Finder.
- libLogger.a in Debug-iphoneos is library complied for armv6 / armv7.
- libLogger.a in Debug-iphonesimulator is library complied for i386.
Create a New folder LoggerMerged and copy above .a files. Name them libLogger_Device.a and libLogger_Simulator.a separately.
lipo -create "libLogger_Device.a" "libLogger_Simulator.a" -output "Logger.a"
Open a new project TestLogger. Add Logger.a and Logger.h into project. Import Logger.h anywhere you like to test our library. Add following snippets. If it works, it log Test Loger.