Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

xcode4 - Why can't XCode 4 find my .h files during a build?

I have a project that won't build because the compiler (?) can't seem to find the .h files. I have tried using the full path, relative path and setting the Project Search Paths (both Header and User Header) and nothing seems to work. What I find very strange is even with the full path it gives an error: No such file or directory (the file does indeed exist in the specified path).

Can anybody give some suggestions on what could be the problem? I would certainly appreciate it.

import statements:

#import <Foundation/Foundation.h>
#import <zxing/common/Counted.h>
#import <zxing/Result.h>
#import <zxing/BinaryBitmap.h>
#import <zxing/Reader.h>
#import <zxing/ResultPointCallback.h>

Headers are located in:

/Users/rolfmarsh/iPhoneCodeLibrary/BarcodeLibrary/zxing-1.6/cpp/core/src/zxing

Header search path is:

$(inherited)
"$(SRCROOT)/zxing/common"

and

/Users/rolfmarsh/iPhoneCodeLibrary/BarcodeLibrary/zxing-1.6/cpp/core/src

Full path of the include files:

/Users/rolfmarsh/iPhoneCodeLibrary/BarcodeLibrary/zxing-1.6/cpp/core/src/zxing/Result.h
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I also had quite a bit of pain with ZXing's dependencies. Here's some tips that will hopefully be of assistance to others with similar issues.

This line does an import:

#import <zxing/common/Counted.h>

For the compiler to find Counted.h, the header search path must be specified.

Now, because the import statement will look for Counted.h relative to two subfolders zxing/common, we need to give it the parent folder of zxing.

In this case, the parent folder is going to be something like:

/ .. my full path here ../cpp/core/src/

So, under the src directory you'll find zxing.

How do we configure this in Xcode? Best to do it relatively. Otherwise, the project will fail on a different user's machine.

To do this, we specify a path relative to the project directory. As follows:

$(PROJECT_DIR)/../cpp/core/src

That goes in the Header Search Path of Build Settings for the ZXingWidget target.

The crucial thing with this header path stuff is to specify the relative directory to search from. In our case, we specify search relative to $(PROJECT_DIR). That variable specifies the directory of our subproject ZXingWidget.

Other caveats. Be careful to specify these in the build settings of your target. If you do it at project level you'll still need to specify it at target level using the $(inherited) variable.

Also, don't forget that the build transcript can be very useful. Look at the header paths included with the -I flag.

As a general debugging technique, I like to specify the absolute path in my settings. That gives a clean build and I know that the files can be included, and where they definitely are. Having done that I then use the $(PROJECT_DIR) to specify a relative path.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...