I am losing my hair in my attempts to get RestKit to build and work. I get the dreaded \"Lexical or Preprocessor issue: RestKit/RestKit.h file not found\" message. I use Xc
After spending 2 days on this same error and navigating to every possibile google result I finally got it!
It's not due to Derived Data settings, those are fine already in XCode 4.3.2.
The problem is that you are doing a #import "RKObjectMapping.h"
or some other include.
Instead use @class RKObjectMapping
or if you really nead the .h use <RestKit/RKObjectMapping.h>
I went with @class
since I just need to compile...
Hope this help!
Here's a common mistake that'll make you want to slap yourself after you fix it.
Yes, you definitely do want to add "$(BUILT_PRODUCTS_DIR)/../../Headers"
to your target's Header Search Paths
, but don't forget to include the quotes!
I'm talking about the quotes that are before $(BUILT
and after _DIR)/../../Headers
If your build configuration has a space in the name (e.g. mine is 'Ad Hoc') and you've just added $(BUILT_PRODUCTS_DIR)/../../Headers
without the leading and trailing quotes, you may end up getting the "Lexical or Preprocessor issue: RestKit/RestKit.h file not found" problem.
I found that I need to manually build the RestKit target for the header files to be copied into the build directory. Apparently the master project build does not reliably run the subproject build?
So, my steps for fixing this issue:
This is a problem that I don't think has enough answers for this problem, because if you have this problem it feels like there is nothing to be done! After trying all of the proposed solutions (none of them worked). I finally found the problem
The problem was that one of my folders had a space in it. Don't use spaces in your source folder names!
Used to be : (/Xcode projects/basicRestkit etc...) -- lots of pain and suffering
changed to : (/projects/basicRestkit) -- lots of rejoicing
This caused the header search paths not to work, and therefore not to find the files. There may very well be a way to use alter the header search paths to find your files even with spaces.
This might not help you, but it very well could. Good luck.
Mind you - its a total hack - but it got my project running.
Assuming that you've already followed the installation steps from the RestKit Github https://github.com/RestKit/RestKit/blob/master/README.md#quick-start-aka-tldr
In the RestKit target, goto Build Phases. Under the Copy Headers dropdown, move all of the header files from "Project" to "Public".
Clean, Build, Run.
Had a very similar problem. It turned out to be I had accidentally added the build setting to "User Header Search Paths" rather than "Header Search Paths".