Xcode 4 and nested projects -- header files not found
Solution 1:
Here's my synthesized knowledge so far:
Forget the whole public header thing with Xcode, it's a PITA and doesn't work correctly when archiving your app. Instead, have all static library header files on the project level and tell your app where to find it.
Ease your pain by making sure all targets have the same name for the build configuration (i.e. add an "AdHoc" and "Deployment" configuration to the static libraries).
-
In build settings, point the Header Search Paths (if you use
#include <file.h>
) or User Header Search Paths (if you use#include "file.h"
) to the directory of the static library project. If the static library project is inside your app directory, use this:"$(PROJECT_DIR)"
(recursive enabled)If you have a directory which contains a) the static library project and b) your app, then this should work:
"$(PROJECT_DIR)/.."
(recursive enabled) -
If the submodule contains compiled libraries, set your Library Search Paths to:
"$(TARGET_BUILD_DIR)"
Make sure all the static library projects that you use have Skip Install set to
YES
.Again, no public header files (Build Phases » Copy Headers) in any of the static libraries, otherwise Xcode will not be able to archive an app.
Make sure to tell Xcode when to build the static libraries, as shown in this Tech Doc from Apple.
Old Answer:
I still haven't found a real solution to this problem with static libraries. What works for me is:
- Create an "AdHoc" Configuration for the static library
- Add
$(BUILT_PRODUCTS_DIR)
to User Header Search paths for the application (with recursive checked) -> this is used when running the app - In the Xcode menu, select Product > Build For > Build For Archiving
This works, the app finds the header files and builds itself, it ends up in DerivedData//Build/Products/AdHoc-iphoneos/ as an App bundle. Following these simple instructions (dead link) from TestFlightApp.com I can pack this App into an IPA and send it around. Simply selecting to Archive the app from Xcode does again not find the headers, even if they truly are in the AdHoc-iphoneos build directory.
Solution 2:
(As of Xcode 5.1)
When the subproject is built by XCode, the subproject header files are copied into the build directory. When archiving, it seems that this copy destination directory is not added to the header/include search path. You'll want to go to your Build Settings and add
$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include
to the "Header Search Paths" for the scheme that you use for archiving.
If you're not sure which scheme is used for archiving, go to Product -> Scheme -> Edit Schemes and look for Archive in the left column.
Solution 3:
Make sure your third party framework is added as «group» to your main project, so you can see it in your project's hierarchy...