Jongers
Jongers

Reputation: 691

Objective-C .h file not found

I was running my project yesterday with these import files:

#import "sip/NgnSipPreferences.h"
#import "services/impl/NgnBaseService.h"
#import "services/INgnSipService.h"

but today I'm getting error on them. It says that 'sip/NgnSipPreferences.h' file not found. but when I remove sip/ making it "NgnSipPreferences.h" then it gets read.

Why did this happen? I don't want to remove the path where the header file comes from because it's so many and I think it's the correct way.

How do I fix this?

Upvotes: 2

Views: 2112

Answers (1)

Prak
Prak

Reputation: 312

#import "sip/NgnSipPreferences.h"

is importing NgnSipPreferences.h from the folder sip/, relative to the file importing it.

So you have 2 solutions, if you don't want to change the #import (usually it's better to do as you say, leaving the imports/includes in the proper place):

  1. you move the .m files in the proper place (above the sip/ directory), or
  2. you add the folder above the sip/ directory to the HEADER_SEARCH_PATHS parameter in your Build_Settings (for example, if you have sip/ in the root folder, just add ${SRCROOT} without recursion - in this case the compiler will for sure find your header file ${SRCROOT}/sip/NgnSipPreferences.h).

Note: to get confidence with the topic, read Adding system header search path to Xcode

Note: if it was working up to yesterday, but not today, you can easily understand what happened if you installed GIT or another versioning tool, but sometimes Xcode is not cleaning all the caches properly, so your problem can be caused much before the date you thought. For this reason, not only "Clean" but also removing the directory DerivedData is quite useful! (I do regularly when something "strange" is happening...)

Upvotes: 2

Related Questions