RestKit/RestKit.h file not found error - version 0

2020-04-01 08:54发布

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.

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条回答
闹够了就滚
2楼-- · 2020-04-01 09:00

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!

查看更多
干净又极端
3楼-- · 2020-04-01 09:04

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
查看更多
姐就是有狂的资本
4楼-- · 2020-04-01 09:06

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.

查看更多
干净又极端
5楼-- · 2020-04-01 09:06

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.

查看更多
ゆ 、 Hurt°
6楼-- · 2020-04-01 09:09

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

查看更多
何必那么认真
7楼-- · 2020-04-01 09:12

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.

查看更多
登录 后发表回答