Xcode 4 C++项目添加文件到构建目录
我是 Xcode 新手。如何将文件添加到构建输出目录?我有一个 file.txt
我想用 C++ 打开它。
以下代码...
string line;
ifstream file ("file.txt");
if (file.is_open())
{
while (file.good())
{
getline (file,line);
cout << line << endl;
}
file.close();
}
...导致无法打开文件
。
我发现可执行文件已部署到 /Users/myusername/Library/Developer/Xcode/DerivedData/IAIK_CMS_Test-dfmszjneldfwjffsmjpmtiepyzej/Build/Products/Debug/
我尝试在项目中添加文件设置到“构建阶段”中的“复制文件”。有关详细信息,请参阅此屏幕截图: https://i.sstatic.net/QhkIT.png
编辑:我正在寻找类似于Eclipse的Java“添加到构建路径”的东西。
有人有建议吗?
I'm new to Xcode. How can I add a file to the build output directory? I have a file.txt
which I want to open in C++.
The following code...
string line;
ifstream file ("file.txt");
if (file.is_open())
{
while (file.good())
{
getline (file,line);
cout << line << endl;
}
file.close();
}
... results in Unable to open file
.
I found out that the executable is deployed to /Users/myusername/Library/Developer/Xcode/DerivedData/IAIK_CMS_Test-dfmszjneldfwjffsmjpmtiepyzej/Build/Products/Debug/
I've tried to add the files in the project settings to the "Copy Files" in the "Build Phases". For details see this screenshot: https://i.sstatic.net/QhkIT.png
Edit: I'm looking for something like Eclipse's "add to Build Path" for Java.
Does anyone have a suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Xcode5 已经出来了,仍然没有答案:)
对于 C++ 项目设置中的 Xcode5,选择您的应用程序目标,选择“构建阶段”选项卡,展开“复制文件”部分,将“产品目录”设置为目标,将子路径字段留空,取消选中“仅在安装时复制”并使用加号将必要的文件 (file.txt) 添加到列表中,如下所示:
并使用“file.txt”路径来访问您的文件。
Xcode5 is out, still no answer :)
For Xcode5 in C++ project settings, choose your app target, select "Build phases" tab, unfold "Copy Files" section, set "Products Directory" for Destination, leave Subpath field blank, uncheck "Copy only when installing" and add necessary file (file.txt) to the list using plus sign, like that:
And use "file.txt" path to access your file.