I'v searched and it seems all the answers are from are from many years ago. I'm working on a network security command line research tool for Linux/Mac that currently uses a Makefile. I wanted to use the Xcode debugger, so I tried to build an Xcode project, but I'm having some final difficulties.
I created a new project of type command line tool with external build target in the project directory. The default was to use /usr/bin/make. It ended up in a subdirectory, and based on several older web resources, I moved the project file up to the folder with the makefile. I added the source files in the folder to the project and right now I can edit and build from Xcode without difficulty.
The issue is that the final executable ends up in a subfolder called bin, and I can't seem to discover how to tell Xcode that that is the final executable. All of the resources I've found talk about adding a custom executable to the target from the project menu, but that menu no longer exists. Searching project help doesn't seem to point to any setting for the executable produced by an external build process. The closest build setting I could find was PROJECT_NAME, but changing that didn't seem to help.
Thanks.
Xcode supports this really nicely but setting it up is a bit tricky. I took a run at this today and was quite happy with the results. Here’s what I did:
-
On macOS 12.1, I started with a
Hello
directory that contains my source file and a make file:% find hello hello hello/hello.c hello/Makefile % cat hello/hello.c #include <stdio.h> int main(int argc, char ** argv) { printf("Hello Cruel World!\n"); } % cat hello/Makefile hello: hello.c cc -o hello -g hello.c
IMPORTANT The second line in
hello/Makefile
starts with a tab. -
I run Xcode 13.2.1 and chose File > New > Project and selected Other > External Build System. I named it XHello, just to keep things clear.
-
I closed that project window.
-
This left me with the following structure on disk:
% find XHello XHello XHello/XHello.xcodeproj … lots of Xcode goo …
I used the Finder to move
XHello.xcodeproj
to myhello
directory. -
I opened that in Xcode.
-
I chose Product > Build to check that it actually builds.
-
I chose Product > Scheme > Edit Scheme to get to the scheme editor.
-
In Run > Info there’s an Executable popup. I chose Other from the menu and then selected the
hello
executable that Xcode built in step 5. -
I chose Product > Run. Xcode ran the tool and displayed its output.
-
I chose File > Add Files to “XHello” and added
hello.c
to the project. -
I selected
hello.c
on the left. -
I set a breakpoint on the
printf
line. -
I chose Product > Run. Xcode stopped at the breakpoint (with source code and everything).
Neat-o!
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"