Is it possible to acquire the workspace path in Xcode 4 via an environment variable

末鹿安然 提交于 2019-12-21 09:25:17

问题


I can't find anything workspace related in the Xcode Build Setting Reference.

Essentially I need something like $(WORKSPACE_DIR). If Xcode doesn't provide it, is there any way to define a custom user variable that could somehow accurately provide the workspace path in the event that the working workspace were to move (think branches etc)?


回答1:


Custom variables can be defined under build settings. I think there is a button named Add Build Setting. So, a new variable workspace root can be defined relative to the SRCROOT or use absolute path.

The new setting is shown under "User Defined" group in build settings. "Add Build Setting" button is near lower right corner.




回答2:


If your workspace is set up like:

//bla/bla/bla/workspace/{project directories}* 

then you can use

$(SRCROOT)/../

to get the workspace directory from a give project directory.


For example, if you want to have one project reference headers in another project:

Project Build Settings->User Header Search Paths => $(SRCROOT)/../SomeLibProj

(and set it to 'recursive' if you don't want to add every folder)



来源:https://stackoverflow.com/questions/8658836/is-it-possible-to-acquire-the-workspace-path-in-xcode-4-via-an-environment-varia

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