在 Xcode 中更改工作目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3396378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:29:26  来源:igfitidea点击:

Change the working directory in Xcode

xcodegdb

提问by Nils

I managed to get my C++ project running in Xcode using cmake -G Xcode. Now I would like to debug it, because of the nice gdb fronted it provides.

我设法使用 cmake -G Xcode 在 Xcode 中运行我的 C++ 项目。现在我想调试它,因为它提供了很好的 gdb 前端。

However I need to change the working directory where gdb is executed otherwise it wont work. (It needs to read some data from files relative to the path of the working directory) What I can do is after gdb has stopped typing cd working_dir and then run it manually typing r. This works, but Xcode will complain constantly and is also not an elegant solution.

但是我需要更改执行 gdb 的工作目录,否则它将无法工作。(它需要从与工作目录路径相关的文件中读取一些数据)我能做的是在 gdb 停止输入 cd working_dir 然后手动输入 r 运行它之后。这有效,但 Xcode 会不断抱怨,也不是一个优雅的解决方案。

So somewhere in the build settings I should be able to set the working directory..but where?!

所以在构建设置的某个地方我应该能够设置工作目录......但是在哪里?!

采纳答案by Paul R

In Xcode do a "Get Info" on the executable and look at the first tab - there is a setting there for working directory.

在 Xcode 中对可执行文件执行“获取信息”并查看第一个选项卡 - 那里有一个工作目录设置。

回答by gibertoni

Just updating this solution to XCode 4.x

只需将此解决方案更新到 XCode 4.x

You go on Product -> Scheme -> Edit Scheme

你继续产品 -> 方案 -> 编辑方案

On the tab Options you choose your working directory.

在选项卡选项中选择您的工作目录。

回答by avee

In Xcode 4 the working directory settings is under Scheme Settings.

在 Xcode 4 中,工作目录设置位于 Scheme Settings 下。

回答by Dave Mooney

The default debug working directory is somewhere under ~/Library/Developer/Xcode/DerivedData/project-/Build/Products/Debug. You're better off using the full path.

默认调试工作目录位于 ~/Library/Developer/Xcode/DerivedData/project-/Build/Products/Debug 下。最好使用完整路径。