Jump to content
  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
Sign in to follow this  

Xcode and makefiles

3 posts in this topic

Recommended Posts

I'm in a programming class and part of our assignements is we have to generate our own makefiles. Does anybody know how I can prevent Xcode from generating the makefile for me and instead instead write my own for my C program?





Share this post

Link to post
Share on other sites

Just ignore the Xcode GUI, write your own Makefile, and use it like you would on a Unix box -- by typing "make" in the source directory (which must also include the Makefile). Of course, you can still use the Xcode GUI to edit your code if you like, and it can be helpful for debugging, etc. In other words, you can use both.

Share this post

Link to post
Share on other sites

In fact you can import standard Makefile project in XCode. It's described in Porting UNIX/Linux Applications to Mac OS X


The steps are:


1. Launch Xcode.

2. Choose New Project from the File menu.

3. Select whatever project type you are targeting. If you ultimately want an application, select something like Cocoa Application. If you are just trying to build a command-line utility, select one of the tools—for example, Standard Tool.

4. Follow the prompts to name and save your project. A new default project of that type is opened.

5.Open the Targets disclosure triangle and delete any default targets that may exist.

6. From the Project menu, Choose New Target.

7. Select “External Target” from the list. If this is not shown in the “Special Targets” list, you are not running the latest version of Xcode. Upgrade first.

8. Follow the prompts to name that target. When you have done this, a target icon with the name you just gave it appears in the Targets pane of the open Xcode window.

9. Double-click that new target. You should now see a new window with the build information for this target. This is not the same thing as clicking info. You must double-click the target itself.

10. In the “Custom Build Command” section of the target inspector, change the field called “Directory” to point to the directory containing your makefile, and change any other settings as needed. For example, in the Custom Build Settings pane, you could change Build Tool from /usr/bin/gnumake to /usr/bin/bsdmake. More information on the fields is available in Xcode Help.

11. Change the active target to your new target by choosing "Set Active Target" from the Project menu.

12. Add the source files to the project. To do this, first open the disclosure triangle beside the “Source” folder in the left side of the project window. Next, drag the folder containing the sources from the Finder into that “Source” folder in Xcode. Tell Xcode not to copy files. Xcode will recursively find all of the files in that folder. Delete anything you don’t want listed.

13. When you are ready to build the project, click the Build and Run button in the toolbar, select Build from the Build menu, or just press Command-B.

14. Once the project is built, tell Xcode where to find the executable by choosing “New Custom Executable” from the Project menu. Choose the path where the executable is located, then add the name of the executable.

15. Run the resulting program by pressing Command-R.





Read some of the Apple article. It's really helpfull.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.