xcode 命令行应用程序 - 可执行代码在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28201337/
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
xcode command line app - where is the executable code?
提问by kjhart0133
I'm writing a small command line tool/app in Xcode 6. After a steep learning curve (that I'm still climbing) I've got my code working in main.m without errors. My question is: does Xcode build some executable code that I can run from the command line inside a Terminal? I've tried "Build" and "Run & Build" but I don't see where any executable code is created. I'm very new at Xcode and need some help. I'm running OS X 10.9.5 and Xcode 6.1.1 on a Mac Mini.
我正在 Xcode 6 中编写一个小的命令行工具/应用程序。经过陡峭的学习曲线(我仍在攀登)后,我的代码在 main.m 中正常工作,没有错误。我的问题是:Xcode 是否构建了一些我可以从终端内的命令行运行的可执行代码?我试过“构建”和“运行和构建”,但我没有看到任何可执行代码的创建位置。我是 Xcode 的新手,需要一些帮助。我在 Mac Mini 上运行 OS X 10.9.5 和 Xcode 6.1.1。
If viewing my code would be useful, let me know and I'll put it up.
如果查看我的代码会有用,请告诉我,我会放上来。
Thanks for any assistance.
感谢您的任何帮助。
Kevin H.
凯文 H。
回答by Non Plus Ultra
It's hidden very well. In Xcode 6, when you build an app, there is a folder "Products" in the project navigator (left pane). The name of your project will be there too. Right click, and select "show in finder". It will show you an obscure folder hidden deep in your OS X Library where the executable is located.
它隐藏得很好。在 Xcode 6 中,当您构建应用程序时,项目导航器(左窗格)中有一个文件夹“Products”。您的项目名称也会在那里。右键单击,然后选择“在查找器中显示”。它将向您显示隐藏在可执行文件所在的 OS X 库深处的一个不起眼的文件夹。
回答by Patrick Domegan
To copy the executable to a more convenient location each time you compile go into the project settings and select the Build Phase.
要在每次编译时将可执行文件复制到更方便的位置,请进入项目设置并选择构建阶段。
Type in a absolute location such as: ~/Documents/dev/temp. (It does recognize ~ as the current users home directory)
输入绝对位置,例如:~/Documents/dev/temp。(它确实将 ~ 识别为当前用户的主目录)
Then Press the '+' Button Under the 'Copy Files' Section and Select Your File (Select Your executable under the Products Folder)
然后按“复制文件”部分下的“+”按钮并选择您的文件(在产品文件夹下选择您的可执行文件)
Deselect the 'Copy only when installing' button. Then build and it should be at that location.
取消选择“仅在安装时复制”按钮。然后构建,它应该在那个位置。
To launch just open the terminal app and go to that location. The executable should run unless there are dynamic libraries it calls that are not in the lib path.
要启动,只需打开终端应用程序并转到该位置。可执行文件应该运行,除非它调用的动态库不在 lib 路径中。
Hope this helps
希望这可以帮助
回答by Bemipefe
The binary is in a folder under /Users/Username/Library. Something like:
二进制文件位于/Users/Username/Library下的文件夹中。就像是:
/Users/<Username>/Library//Developer/Xcode/DerivedData/.../Build/Products/Debug/<ProjectName>
You can easily find it with this command:
您可以使用以下命令轻松找到它:
find /Users/<Username>/Library/ -name "<ProjectName>"
replace "Username" and "ProjectName" accordingly to reflect your environment.
相应地替换“用户名”和“项目名”以反映您的环境。