Nabin Bhusal
Nabin Bhusal

Reputation: 137

Xcode: creating an executable file

I am using Xcode to do C++ programming but the problem is when i build the program it doesnot creat a executable file like Turbo C++ creates a .exe file. What can i do to create such executable file on OS X environment using xcode.?

Upvotes: 6

Views: 28449

Answers (4)

Yuv
Yuv

Reputation: 71

you need to find the working directory of Xcode.

If you are working with C/C++, type system("pwd"); in your main function. This will print your working directory. In which you shall find the executable.

(I am not sure about other languages but there must be a substitute for system()).

your output should look something like this: /Users/your_username/Library/Developer/Xcode/DerivedData/Build/Products/Debug

Upvotes: 0

Phani Srikar
Phani Srikar

Reputation: 11

I got a simple solution for you got Product > archive and select distribute content and use the build option. Dig deep into the folder created and you can find the Mac executable file that'll run almost on any Mac.

Upvotes: 1

goodstar
goodstar

Reputation: 131

Follows this: File->Project Settings->under Derived Data, Click the Advanced->Click Custom, then choose the option Relative to Workspace->Done. Then build your code and you will see Product file package in your project path. I am using Xcode 8.2.1, hope it may help.

Upvotes: 11

SaschaM78
SaschaM78

Reputation: 4497

I'll try to summarise the following article and hope it'll help you get started:

How To: Compile and Run Basic C++ Programs in Xcode

  1. Start a new project: select File, New Project
  2. in the Application dropdown, pick your desired application type (i.e. "command line utility") and choose "C++ Tool"
  3. choose a location (and remember the path for later) and click Finish
  4. Start coding your application
  5. when you are done, click on the Build button
  6. now Finder and navigate to the project folder that you picked in step 3
  7. in it, you should find a file with the name of your project without any extension
  8. double click the file et voilà, your application should starts (in the example above, a terminal window should appear)

Let me know if it helped you solve your problem.

Upvotes: 1

Related Questions