I am trying to use the new Xcode4 workspace feature to migrate some Xcode3 projects that has dependencies between them. I have a project which creates a static library and then an application project which depends on the static library. So, as the guide mentioned, I created a new workspace and dragged both the projects into the workspace. However, when I build my application, it's unable to find the header files from my static library. I get "No such file or directory" error. My intention is to let Xcode auto detect the dependencies. But, not sure what I am doing wrong, I couldn't get it to work. Any help is greatly appreciated. There isn't much documentation out there either.
3 Answers
After few frustrating hours, I may have found a solution (still not sure if it's the right way).
- Created a new workspace
- Added the shared library project
- Added the application project below shared library (not inside)
- Open Build Phase of shared library and made sure when copying headers it is grouped to public
- Open Build settings of application and in the Header Search Paths typed in "BUILD_PRODUCTS_DIR"\usr\local\include
- And in Build Phase of target, included a link to static library (shared library)
Did a clean and build and everything was built successfully.
However, I am still not convinced this is the right way, as according to Xcode4 guide, no changes to settings is necessary, just adding projects to workspace will take care of everything. Someday, I hope to find the correct solution and use it.
Thanks Javid

- 1,347
- 7
- 29
- 57
-
1set USER_HEADER_SEARCH_PATHS to $(TARGET_BUILD_DIR)/usr/local/include $(DSTROOT)/usr/local/include – ShahidAzim May 30 '11 at 17:15
There are at least a couple of ways to go about this.
What I do is set a value for the User Header Search Path build setting for the main target, pointed to the library path. Just type 'user header' in the build settings editor search box and you'll find it.
If you're consuming a library that you intend to use often, it's best to set up a source tree setting for it. This is in XCode Prefs -> Source Trees. Add an entry, put in the path to the library source, and give it a sensible Setting Name, eg. XXLIBRARY_SOURCE. Then in the user header search path (or any other build setting where you need the library path), you can use $(XXLIBRARY_SOURCE) as the path.
A simpler but less flexible alternative is just to drag the library's headers into your main project.

- 1,939
- 3
- 23
- 37
-
2Thanks Cris, I had set it up this way in Xcode3 and works great, but thought Xcode4 workspace feature allows you to setup projects and automatically detects dependencies. Thought with Xcode4 I can minimize settings but looks not. – user320587 Mar 25 '11 at 15:10
-
I had hoped for the same thing, but it looks like XCode 4' 'implicit dependencies' feature is something much more limited: https://devforums.apple.com/message/383410#383410. I only say 'looks like', because Apple's documentation of the feature is sketchy. – Cris Mar 26 '11 at 00:22
The issue seems to lie with the Xcode environment variables reporting the wrong location. For instance $(TARGET_BUILD_DIR) translates to:
/build/Debug/
..but when using workspaces an extra folder is inserted into that path:
/build/products/Debug
..which Xcode seems to ignore or can't handle.

- 11,080
- 5
- 42
- 40
-
Is there anyway to get around this. I've come to the same conclusion, the $(BUILT_PRODUCTS_DIR) is fine during the building process, but its not fine when its just doing code completion for the user header path. Looks like we need to use static directories for header files? – Matt Dec 11 '12 at 07:20