开发者

Xcode linked project header files not found

开发者 https://www.devze.com 2022-12-16 21:30 出处:网络
Here is the situation I have: ProjectA - Xcode static library project. ProjectA contains logical code group ExternLib with file ExternLib.h. ExternLib.h itself is in the folder Classes/lib/ExternLib (

Here is the situation I have:

ProjectA - Xcode static library project.

ProjectA contains logical code group ExternLib with file ExternLib.h. ExternLib.h itself is in the folder Classes/lib/ExternLib (relative to ProjectA folder). Within ProjectA, I use ExternLib.h simply as: #import "ExternLib.h". This works fine.

Next I have ProjectB. This includes 开发者_如何学运维ProjectA as a linked Xcode project. The target has been added correctly etc. However, when I include a file in ProjectB which in turn includes ExternLib.h, upon building ProjectB, I get an error saying that the file ExternLib.h cannot be found.

I have tried adding the path to ExternLib.h to the header search path (all types: relative, absolute, with recursion etc.) but to no avail. I have checked that static library target has the copy headers step and the file ExternLib.h is included in it.

Anybody able to shed some light on how to get around this?


  1. Add a Run Script Build Phase to the target for ExternLib that executes

    mkdir -p "${BUILT_PRODUCTS_DIR}ExternLibHeaders"
    
  2. Add a Copy Files build phase that copies the ExternLib header files into ${BUILT_PRODUCTS_DIR}ExternLibHeaders, and add all of ExternLib's headers into that phase.

  3. In the app target for ProjectB, add ${BUILT_PRODUCTS_DIR}/ExternLibHeaders/ to the Header Search Paths for all configurations.

  4. In Xcode > Preferences > Build, set the Build Products Directory to some common location.

The fourth step is crucial; it ensures that BUILT_PRODUCTS_DIR is the same for both projects.


It's really hard to say what might have gone wrong.

I'd start from scratch with a tutorial on building and using static libraries, and see if any of the steps jog any ideas out of you.

0

精彩评论

暂无评论...
验证码 换一张
取 消