I'm trying to convert a small demo project that uses version 1.1.3 of the static framework to a project that uses the CoconutKit sources directly. I created an empty workspace, added my project and the CoconutKit project to it, added the libCoconutKit.a library to the application link phase and added "CoconutKit/CoconutKit/**" to the User Header Search Paths.
The first problem was that the global import of <CoconutKit/CoconutKit.h> no longer works — it seems like this file is generated automatically.
I tried adding everything from the CoconutKit-dev-Prefix.pch to my own prefix file, and my application now builds and runs, but crashes immediately with an uncaught exception:
'NSInvalidArgumentException', reason: '-[LifeCycleTestViewController className]: unrecognized selector sent to instance 0x896cd90'
Is this a completely wrong approach, or is there some small detail I need to add?
If you want your project to use CoconutKit sources only, you must not add libCoconutKit.a to your project (after all, that's the compiled library), you must only use .m and .h files (and resources files). I do not recommend using CoconutKit this way since you will basically compile everything from scratch every time you clean & build your project.
If you still want to use CoconutKit as source files, here is how:
1) Add the CoconutKit/Sources and CoconutKit/Resources folders to your project
2) Open CoconutKit-dev-Prefix.pch, copy all #import directives, and paste them into your project .pch file
If you are trying to use CoconutKit as a static library file and a set of header files, I strongly recommend sticking to the .staticframework I provide. The .staticframework binaries include special tricks so you do not run into linking issues (have a look at the CoconutKit_bootstrap.m file). If you want to use the static library file without those linking issues, you will need to add the -ObjC and -all_load flags to your project linker flags (which you do not need to do with the .staticframework). There is an associated space overhead, though, which you won't pay if you use the .staticframework.
Hmmm, manually adding references to my project is precisely what I was trying to avoid. I usually try to add project dependencies as git submodules and as separate projects in a workspace.
Well, it works as well:
1) Add CoconutKit.xcodeproj to your project
2) Link your project with libCoconutKit.a (target -> Build Phases -> Link Binary With Libraries)
3) Add -ObjC to your project / target "Other linker flags" settings. -all_load might be needed as well, though -ObjC was sufficient when I tested it
4) Add /path/where/you/store/CoconutKit_1.1.3/CoconutKit/Sources/** to the Header Search Paths
5) Link your project against CoreData.framework, MessageUI.framework and QuartzCore.framework as well
6) Where you want to use some CoconutKit feature, #import "HeaderFile.h". Alternatively, you may want to open CoconutKit-dev-Prefix.pch, copy all #import directives, and paste them into your project .pch file
I was doing most of what you recommended, except for adding the "-ObjC" linker flag, which turns out to be crucial if you're using Categories from your linked library. That's why I was getting an exception when using the className method from NSObject+HLSExtensions.h.
It now works. Thanks for the help!