简体   繁体   English

从Cocoa Application Project导出XCode中可执行的OSX

[英]Export OSX Executable in XCode from Cocoa Application Project

I made a command line tool as a Cocoa Application in XCode and when I archive it, it generates a .app file that contains the underlying executable file. 我使用XCode作为Cocoa应用程序制作了一个命令行工具,当我对其进行存档时,它会生成一个包含基础可执行文件的.app文件。 To actually run it, I need to execute that underlying file which is located at AppName.app/Contents/MacOS/AppName. 要实际运行它,我需要执行位于AppName.app/Contents/MacOS/AppName的基础文件。 Is there any way I can have it build just the executable? 有什么办法可以让我仅构建可执行文件? I don't want to have to create a post build step that copies the executable out of the .app file. 我不想创建一个将可执行文件从.app文件复制出来的后期构建步骤。

Thanks 谢谢

When you create an Xcode project you choose the project type. 创建Xcode项目时,请选择项目类型。 Cocoa Application and Command Line Tool are two of the choices. 可可应用程序和命令行工具是两个选择。 Apparently you created a Cocoa Application but modified the template provided main.m file to execute as a Command Line Tool. 显然,您创建了一个Cocoa应用程序,但是修改了模板提供的main.m文件以作为命令行工具执行。 However, once a project has been created it cannot be converted to another project type. 但是,一旦创建了项目,就无法将其转换为其他项目类型。 Xcode will still treat it as the project type you created it as. Xcode仍会将其视为您创建时所使用的项目类型。

You can solve your problem by creating a new project, this time with type Command Line Tool, copy in the same software, and build. 您可以通过创建一个新项目来解决您的问题,这次使用命令行工具类型,在同一软件中进行复制并进行构建。 The build product will be a UNIX command line program just as you wish. 就像您希望的那样,构建产品将是UNIX命令行程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM