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 f开发者_StackOverflow社区rom 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.
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
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.
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.
精彩评论