two projects in xcode4 workspaces (#import failure)

Erik picture Erik · Mar 11, 2011 · Viewed 9.4k times · Source

I'm really struggling to get this to work in xcode 4.

I have one project that I will reuse in many applications (networking) so I create a workspace and add my two projects. So far so good.... This is where it fails..

#import "JSONRequest.h"

For no apparent reason. It auto completes the file name of the header file. I thought this had something to do with the "scheme" (also new in xcode 4) so I've tried to add my networking target in the build phase. Changing order of them... set "Shared" under Manage schemes.. I've tried so many different combinations of the settings without any success.. And the error message is get is:

JSONRequest.h: No such file or directory

If you have a clue, please let me know.

Answer

bobc picture bobc · Mar 31, 2011

You can add the header or source folder of your project you're referencing to your Header Search Paths.

  1. Click on the target that's importing JSONRequest.h.
  2. Click on Build Settings.
  3. Enter "Header Search Paths" into the search box.
  4. Double click on the value cell.
  5. Click the + sign.
  6. Set the path to the project you're referring. Let's say it's called JSONlib. The path is relative to the root of the referring project (the project that's using JSONlib). For example: ../JSONlib/src/headers/ or wherever it is that the .h file lives.
  7. Click done.
  8. Clean and then build.

You'll find more info about this problem in the apple developer forums. Best of luck.