RestKit/RestKit.h file not found error – version 0.10.0

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 Xcode 4.2 & my project is for iOS.

Earlier, I had debug mode working perfectly with RestKit 0.9.0. Then I ran into issues while trying to archive. After reading this forum and attempting some solutions, I decided to upgrade to 0.10.0 with hopes that it will solve the issue.

  • RestKit GET query parameters
  • When will completionBlock be called for dependencies in NSOperation
  • iOS RestKit can not save local entity to database
  • Map url parameters to objects using RESTKit
  • Restkit on Xcode 4.5 GM does not work on iOS 6 device - file was built for archive which is not the architecture being linked
  • RESTKit POST Request Tutorial
  • Now, my project is not even building in debug mode and I get the same RestKit/RestKit.h file not found error.

    I have this under Header search path: “$(BUILT_PRODUCTS_DIR)/../../Headers”. Can you please suggest (for 0.10.0 version):
    1) Where should the physical location of RestKit be? (It may not matter, but which one worked for you – with hopes that I can mirror your setting)
    2) I tried to point my header search path to “/Developer/Library/RestKit-RestKit-69adee9/” and later to “/Developer/Library/RestKit-RestKit-69adee9/Build”

    Throughly confused and frustrated..

    EDIT1: After several hours, I gave up. Nuked my project. Created a fresh project. Re-created the files (copy paste from prev project). Now “RestKit not found” error is gone! But now, I am getting this other error:

    Undefined symbols for architecture i386:
    "_OBJC_CLASS_$_RKObjectMapping", referenced from:
    objc-class-ref in myclassname1.o
    "_OBJC_CLASS_$_RKObjectManager", referenced from:
    objc-class-ref in myclassname2.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    I checked & made sure that I did NOT add RestKit.framework… I’ve no idea why the clang error is happening now

    EDIT2: The libRestKit.a was red. It is OK according to https://github.com/RestKit/RestKit/wiki/Installation-Troubleshooting Just for the heck of it, I removed all the linked dependencies. Removed the “Other linker flags”. Closed & reopened Xcode. Put them all back. That error is gone. Maybe I missed a framework which resulted in clang error. But it is highly unlikely for I checked & double checked. It works now.

    It builds & archives on debug mode. I haven’t tried the distribution mode yet.

    EDIT3: Apple approved my app in the first go & it is live! I still do not know what caused the issue here. Nuking an existing project & creating a new one & copying over the old files (& periodically checking if build goes through) cannot be a solution. So I am leaving this question open.

    14 Solutions Collect From Internet About “RestKit/RestKit.h file not found error – version 0.10.0”

    I think I can shed some light on this.

    When you upgrade to 0.10.0, you change your header search paths to "$(BUILT_PRODUCTS_DIR)/../../Headers", right?

    The install guide only says to do this for the project settings. However in many cases, mine included, you’ll need to also update them for the target settings as well.

    The target settings will still have the old header search paths, and for whatever reason decide not to inherit from the project settings.

    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.

    Solution I found was not to copy and past the “$(BUILT_PRODUCTS_DIR)/../../Headers” to your target’s Header Search Paths.

    After five hours I deleted the copy and pasted ” and manually typed them in and it worked.

    I recently played around with upgrading from RestKit 0.9.3 to 0.10.0 and had the same thing. Did you delete the RestKit/build directory? This contains a copy of the .h files and is created as part of the build process when building 0.9.x. Doing Product -> Clean doesn’t seem to delete these files. 0.10.0 doesn’t seem to create this build directory. I suspect that your build errors are due to those files still being picked up.

    Also, to answer your question fully, I keep RestKit files in:
    (project dir)/Frameworks/RestKit
    This is a git submodule so it contains a clone of the RestKit git repo at a particular revision.

    And the header search path is:
    $(BUILT_PRODUCTS_DIR)/../../Headers

    The header search path for 0.9.3 was:
    $(SOURCE_ROOT)/RestKit/Build

    I found this guide helpful (maybe this is what you are already following): https://github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x
    and note the section about only having libRestKit.a in the project for the latest RestKit versions where earlier versions had all of:

    • libRestKitNetwork.a
    • libRestKitObjectMapping.a
    • libRestKitSupport.a
    • libRestKitJSONParserJSONKit.a
    • libRestKitXMLParserLibxml.a
    • libRestKitCoreData.a

    If you have all of these, delete them from your project.

    Been fighting with the same issue for the past few hours. What finally worked for me (and I’m not saying this is a definite fix, but at least it’s something to try).

    • Delete RestKit from your Project
    • Close your project
    • Move the RestKit folder next to your main xcodeproject
    • Open the RestKit project and build it
    • Close the RestKit project
    • Open your project, and re-import the RestKit project into your xcodeproject
    • Fix the Dependencies and Linkings in the target settings
    • Add the “$(BUILT_PRODUCTS_DIR)/../../Headers” search path to BOTH the project settings and the target settings. (it only worked for me when they were listed in both).

    This last step might be all that’s necessary to fix it, but since I too was pulling my hair out over this, I tried a lot of different solutions and didn’t want to assume that this last step was the sole reason it fixed itself.

    (and my setup is XCode 4.3.2 and OS X 10.7.3)

    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!

    Had this problem too. It would build and run just fine on simulator, but would not archive. Here’s where I went wrong…

    I did this:

    #import "RestKit.h"
    

    Rather than the correct way:

    #import <RestKit/RestKit.h>
    

    I had the exact same error today. All our code is in a github repo and the restkit folder is ignored so none of the restkit files were in there. Now, when xcode opens the project and finds stuff missing, it assumes all hell broke loose. So, deleted the folder, re cloned it and then grabbed a fresh copy of the restkit and threw it in there and voila, everything worked.

    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:

    • Select the RestKit run target
    • Build
    • Make sure the header search path was set on all target (apparently on project itself is not enough)
    • Build main project

    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”.

    My solution:

    When adding "$(BUILT_PRODUCTS_DIR)/../../Headers" to
    Targets -> Build Settings -> Search Paths -> Header Search paths,
    the value was not set.

    Instead the value has have been set up to User Header Search Paths.
    So you double click to Header Search Paths, some pane with lines appear, you click + down left, paste that string there, click somewhere else to dismiss the window and… nothing.
    The Header Search Paths didnt get updated but User Header Search Path did.

    ?!!!

    So you click on the disclosure button on Header Search Paths.
    Click + sign right of the attribute and add the value…

    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.

    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.

    For me only these steps works. Check here Hope this will help.