I know, this has been asked a few times, but mostly for Xcode 3.x. For the iPad, I have two projects both living in a common workspace
- Foo, a view-based application and
- Foolib, a static Cocoa-Touch library
the former depending on the latter. I seem unable to work out how to add that dependency. It's not well explained in the documentation, so I tried the following:
- Click on the Foo project in the Navigation Area on the left,
- Select Build Phases up the top and expand the Target Dependencies section
- Click the plus button, but the resulting list is empty.
I have also tried to drag/drop the .a file into that section, with little success. Also, the documentation states
If the build product of one project in a workspace is dependent on the build product of another project in the workspace (for example, if one project builds a library used by the other project), Xcode discovers such implicit dependencies and builds in the correct sequence.
I wonder how Xcode discovers those dependencies. Is Apple saying I don't have to add this target dependency at all? But then how would Xcode discover that one is using the other?
Last but not least, I will need to get the .h files from Foolib across to Foo somehow. What is the recommended way of doing that? Obviously, I don't want to just copy them. With frameworks the header files come included, but what do people generally do when working with static libraries that they themselves develop in parallel.
A nudge in the right direction would be much appreciated. Thank you.
In general Xcode 4 seems to discover the dependencies automatically as the Edit Scheme sheet implies. Other developers have mentioned that the dependencies are not automatically discovered and require explicitly listing them:
So, Edit Scheme -> Build -> add targets from your workspace.
As far as the static library header files go, Xcode 4 seems to have a problem, at least with code completion and syntax highlighting. The only way I can get either to work properly with classes in static libraries to to drag a copy of the header files in question to a location into a group folder in the main project. Note that you should uncheck Add to Target... That takes care of the syntax highlighting and code completion. The rest should be handled by giving it the proper header search path. That would be User Header Search Paths = $(BUILT_PRODUCTS_DIR) - depending on how you set up your locations preferences.
See: this link
来源:https://stackoverflow.com/questions/5986586/xcode-4-how-to-add-static-library-target-dependency-to-project