Xcode4 workspace sharing projects

▼魔方 西西 提交于 2019-12-06 00:05:44

After few frustrating hours, I may have found a solution (still not sure if it's the right way).

  1. Created a new workspace
  2. Added the shared library project
  3. Added the application project below shared library (not inside)
  4. Open Build Phase of shared library and made sure when copying headers it is grouped to public
  5. Open Build settings of application and in the Header Search Paths typed in "BUILD_PRODUCTS_DIR"\usr\local\include
  6. 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!