{"id":75667,"date":"2026-11-23T03:01:00","date_gmt":"2026-11-22T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=75667"},"modified":"2026-11-22T20:26:00","modified_gmt":"2026-11-22T10:26:00","slug":"xcode-executable-finding-and-executing-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-executable-finding-and-executing-tutorial\/","title":{"rendered":"Xcode Executable Finding and Executing Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/find_xcode_executable.gif\" rel=\"noopener\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Xcode Executable Finding and Executing Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/find_xcode_executable.gif\" title=\"Xcode Executable Finding and Executing Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Xcode Executable Finding and Executing Tutorial<\/p><\/div>\n<p>The <a target=\"_blank\" title='Xcode IDE information from Apple' href='https:\/\/developer.apple.com\/technologies\/tools\/' rel=\"noopener\">Xcode<\/a> IDE on macOS, as a desktop application, for &#8230;<\/p>\n<p><code><br \/>\nXcode -&gt; New -&gt; Project... -&gt; macOS \/ Command Line Tool -&gt; Product Name: [up to you] Language: C<br \/>\n<\/code><\/p>\n<p> &#8230; represents, perhaps, the simplest and immediately approachable Xcode Project combination to try.  But even here, you will find it as easy as falling off a log to create an executable that &#8220;runs&#8221; within the Xcode IDE environment.  But Xcode does a great job at making it hard for you to track down where, on your hard disk, it created the executable.  And because we are very much &#8220;old school&#8221; from the command line days where paths to executables were known and a part of the mix for programmers to be totally au fait around, we&#8217;re going to write &#8230;<\/p>\n<ul>\n<li>using PHP server language<\/li>\n<li>under a macOS <a target=\"_blank\" title='MAMP' href='http:\/\/www.mamp.info' rel=\"noopener\">MAMP<\/a> Apache\/PHP local web server environment &#8230;<\/li>\n<li>following great advice of <a target=\"_blank\" href='https:\/\/www.google.com\/search?q=can+a+command+line+xcode+command+determine+the+executable+path+for+an+xcode+project+name%3F&#038;rlz=1C5OZZY_en&#038;oq=can+a+command+line+xcode+command+determine+the+executable+path+for+an+xcode+project+name%3F&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAjIHCAIQIRiPAtIBCTM2NTUyajBqN6gCALACAA&#038;sourceid=chrome&#038;source=chrome.ob&#038;ie=UTF-8' title='can a command line xcode command determine the executable path for an xcode project name?' rel=\"noopener\">can a command line xcode command determine the executable path for an xcode project name?<\/a> we base the logic around setting up command like &#8230;<br \/>\n<blockquote cite='https:\/\/www.google.com\/search?q=can+a+command+line+xcode+command+determine+the+executable+path+for+an+xcode+project+name%3F&#038;rlz=1C5OZZY_en&#038;oq=can+a+command+line+xcode+command+determine+the+executable+path+for+an+xcode+project+name%3F&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRiPAjIHCAIQIRiPAtIBCTM2NTUyajBqN6gCALACAA&#038;sourceid=chrome&#038;source=chrome.ob&#038;ie=UTF-8'><p>\nxcodebuild -project YourProject.xcodeproj -scheme YourScheme -showBuildSettings | grep -E &#8220;^\\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) =&#8221;\n<\/p><\/blockquote>\n<p> &#8230; exemplified by, for us &#8230;<br \/>\n<code><br \/>\nxcodebuild -project \"My Next File C Program.xcodeproj\" -scheme \"My Next File C Program\" -showBuildSettings | grep -E \"^\\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) =\"<br \/>\n<\/code><br \/>\n &#8230; resulting in &#8230;<\/p>\n<blockquote><p>\n2026-11-22 17:57:15.240 xcodebuild[30786:4838683] [MT] IDERunDestination: Supported platforms for the buildables in the current scheme is empty.<br \/>\n&#8212; xcodebuild: WARNING: Using the first of multiple matching destinations:<br \/>\n{ platform:macOS, arch:arm64, id:00008103-000328410EA2001E, name:My Mac }<br \/>\n{ platform:macOS, arch:x86_64, id:00008103-000328410EA2001E, name:My Mac }<br \/>\n{ platform:macOS, name:Any Mac }<br \/>\n    EXECUTABLE_PATH = My Next File C Program<br \/>\n    TARGET_BUILD_DIR = \/Users\/user\/Library\/Developer\/Xcode\/DerivedData\/My_Next_File_C_Program-blfjoaxttlpyniaghlsxiantcafy\/Build\/Products\/Debug\n<\/p><\/blockquote>\n<\/li>\n<\/ul>\n<p> &#8230; as a means forward to help &#8220;unlock the secrets of the X<sup>c<\/sup><sub>o<\/sub><sup>d<\/sup><sub>e<\/sub>&#8220;!<\/p>\n<p>From there, as many programmers will know, as soon as keyboard interactive entry gets to be involved with the execution of a compiled language (in our case C) program, starting with a web browser address bar, it&#8217;s really difficult to arrange up at the public RJM Programming, but here on macOS MAMP within an <br \/><font color=blue>ht<\/font><font color=blue>tp<\/font><font color=blue>:\/\/localhost:8888\/find_xcode_executable.php<\/font><\/br> web browser address bar call we are allowed to code for PHP &#8230;<\/p>\n<p><code><br \/>\n<a target=\"_blank\" title='PHP passthru() method information' href='http:\/\/php.net\/manual\/en\/function.passthru.php' rel=\"noopener\">passthru<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; <font size=1>(deemed a security threat up at the public RJM Programming web server)<\/font> but which was our macOS MAMP pass through to &#8230;<\/p>\n<ul>\n<li>macOS <a target=\"_blank\" title='MacOS Terminal desktop app' href='https:\/\/www.google.com\/search?q=macos+terminal+apple&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=macos+terminal+apple&#038;aqs=chrome..69i57j0i512l4j0i22i30l5.8834j0j4&#038;sourceid=chrome&#038;ie=UTF-8' rel=\"noopener\">Terminal<\/a> desktop application &#8230; <\/li>\n<li>called to run our newly found Xcode C executable, like <font size=1>(with the C code used in <a title='C 2D Array via File Tutorial' href='#c2daft'>C 2D Array via File Tutorial<\/a>)<\/font> via command like &#8230;<br \/>\n<code><br \/>\n\"\/Users\/user\/Library\/Developer\/Xcode\/DerivedData\/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq\/Build\/Products\/Debug\/My C Command Line Project\"<br \/>\n<\/code><br \/>\n &#8230; via passthru command calls like &#8230;<br \/>\n <code><br \/>\n osascript -e 'tell application \"Terminal\" to do script \"\\\"\/Users\/user\/Library\/Developer\/Xcode\/DerivedData\/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq\/Build\/Products\/Debug\/My C Command Line Project\\\"\"'<br \/>\n <\/code>\n <\/li>\n<\/ul>\n<p> &#8230; allowing for interactive entry within that, perhaps new, Terminal window <font size=1>(not necessarily the top window)<\/font> being a possibility.<\/p>\n<p>And so, day one here, got us to our <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/find_xcode_executable.php_GETME\" rel=\"noopener\">find_xcode_executable.php<\/a> proof of concept first draft for this Xcode <font size=1>innards understanding<\/font> helper web application we run around here up at the address bar of a web browser, and on from there, depending on where the user takes it.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=\"_blank\" href='\/\/www.rjmprogramming.com.au\/ITblog\/xcode-executable-finding-and-executing-tutorial\/' rel=\"noopener\">Xcode Executable Finding and Executing Tutorial<\/a>.<\/p-->\n<hr>\n<p id='c2daft'>Previous relevant <a target=\"_blank\" title='C 2D Array via File Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/c-2d-array-via-file-tutorial\/' rel=\"noopener\">C 2D Array via File Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/C\/File2dArray\/File2dArray.jpg\" rel=\"noopener\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C 2D Array via File Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/C\/File2dArray\/File2dArray.jpg\" title=\"C 2D Array via File Tutorial\"  \/><\/a><p class=\"wp-caption-text\">C 2D Array via File Tutorial<\/p><\/div>\n<p>You don&#8217;t have to use an IDE to do C programming.  There is <a target=\"_blank\" title='Digital Mars' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Digital+Mars' rel=\"noopener\">Digital Mars<\/a> C as an example of that.   We have talked about the <a target=\"_blank\" title='Xcode and its Command Line Tools Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5519' rel=\"noopener\">Xcode command line tools<\/a> before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.<\/p>\n<p>So it is today with this tutorial reading a file of numbers that define the workings of a 2D int array the program requires, inspired by this (old) Yahoo Answers <a target=\"_blank\" title='Old Yahoo Answers question' href='http:\/\/au.answers.yahoo.com\/question\/index?qid=20110702111230AA9XfOi' rel=\"noopener\">question<\/a>.<\/p>\n<p>We use stdlib.h&#8217;s memory management function <a target=\"_blank\" title='calloc' href='http:\/\/www.cplusplus.com\/reference\/cstdlib\/calloc\/' rel=\"noopener\">calloc<\/a> to handle the memory management here.   The use of calloc, malloc and realloc can aid with dynamically changeable arrangements with your C program&#8217;s memory management, and you may be interested in the related previous <a target=\"_blank\" title='' href='#xdcspt' rel=\"noopener\">Xcode Debug C Strings Program Tutorial<\/a> as shown below.<\/p>\n<p>So feel free to download the C programming source code here and rename it to <a target=\"_blank\" title='main.cpp' href='http:\/\/www.rjmprogramming.com.au\/C\/File2dArray\/file_2d_array.c_GETME' rel=\"noopener\">file_2d_array.c<\/a><\/p>\n<p>Hope you enjoy this <a target=\"_blank\" title=\"gcc compiling\" href=\"http:\/\/www.rjmprogramming.com.au\/C\/File2dArray\/File2dArray.jpg\" rel=\"noopener\">tutorial<\/a> showing you some command line C gcc compilation work.<\/p>\n<p><code>Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.c<br \/>\n\/\/ file_2d_array.c ... read input file's data into a 2d array<br \/>\n#include \"stdio.h\"<br \/>\n#include \"stdlib.h\"<br \/>\nint main (int argc, char* argv[]) {<br \/>\nFILE* spIn;<br \/>\nint rownum;<br \/>\nint colnum;<br \/>\nint** table;<br \/>\nint row;<br \/>\nint column;<br \/>\nint value;<br \/>\nspIn = fopen (argv[1], \"r\");<br \/>\nif (spIn == NULL)<br \/>\n{<br \/>\nprintf (\" Did not open haha an\");<br \/>\nexit (1);<br \/>\n} <br \/>\nfscanf(spIn,\"%d\", &#038;rownum);<br \/>\nfscanf(spIn,\"%d\", &#038;colnum);<br \/>\ntable = (int**)calloc ((rownum * colnum), sizeof(int*));<br \/>\nfor (row = 0; row < rownum; row++)<br \/>\n{<br \/>\ntable[row] = (int*)calloc ((rownum * 1), sizeof(int));<br \/>\nfor (column = 0; column < colnum; column++)<br \/>\n{<br \/>\nfscanf(spIn, \"%d\", &#038;value);<br \/>\ntable[row][column] = value;<br \/>\nprintf(\" table[%d][%d] = %d n\", row, column, table[row][column]);<br \/>\n}<br \/>\n}<br \/>\nfclose(spIn);<br \/>\nreturn 0;<br \/>\n}<br \/>\nRoberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.txt<br \/>\n2 3 1 2 3 12 12<br \/>\nRoberts-MacBook-Pro:tools robertmetcalfe$ gcc file_2d_array.c -o file_2d_array<br \/>\nRoberts-MacBook-Pro:tools robertmetcalfe$ ls -l file_2d_array*<br \/>\n-rwxr-xr-x  1 robertmetcalfe  staff  8728  9 Mar 09:00 file_2d_array<br \/>\n-rw-r--r--  1 robertmetcalfe  staff   729  9 Mar 08:59 file_2d_array.c<br \/>\n-rw-r--r--  1 robertmetcalfe  staff    17  9 Mar 08:37 file_2d_array.txt<br \/>\nRoberts-MacBook-Pro:tools robertmetcalfe$ .\/file_2d_array file_2d_array.txt<br \/>\n table[0][0] = 1<br \/>\n table[0][1] = 2<br \/>\n table[0][2] = 3<br \/>\n table[1][0] = 12<br \/>\n table[1][1] = 12<br \/>\n table[1][2] = 12<br \/>\nRoberts-MacBook-Pro:tools robertmetcalfe$<br \/>\n<\/code><\/p>\n<p>A really helpful tutorial for code above is shown <a target=\"_blank\" title='Good tutorial' href='http:\/\/stackoverflow.com\/questions\/16715633\/multidimensional-arrays-allocated-through-calloc' rel=\"noopener\">here<\/a> &#8230; thanks.<\/p>\n<hr \/>\n<p id='xdcspt'>Previous <a target=\"_blank\" title='' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5238' rel=\"noopener\">Xcode Debug C Strings Program Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/C\/NonGlobalStrings\/XcodeDebug_C_NonGlobalStrings.m4v\" rel=\"noopener\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Xcode Debug C Strings Program Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/C\/NonGlobalStrings\/XcodeDebug_C_NonGlobalStrings.jpg\" title=\"Xcode Debug C Strings Program Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Xcode Debug C Strings Program Tutorial<\/p><\/div>\n<p>Have a bit of an esoteric C programming scenario today, and because it is esoteric, and some or all of you may fall asleep, am also going to show you how to debug in Xcode &#8230; and only now just realized with the podcast of this tutorial that we went, on a Mac, control-command-Y a lot and should have, instead, shown you this in menu manipulation terms as Product->Debug->Continue &#8230; anyway, if you get into this, you&#8217;ll know what is going on.<\/p>\n<p>Okay, so the C scenario in Xcode is a bit esoteric, as sometimes happens when you are answering &#8220;a brief&#8221; (a Yahoo Answers brief).  The brief was not to use <a target=\"_blank\" title='strcat' href='http:\/\/www.techonthenet.com\/c_language\/standard_library_functions\/string_h\/strcat.php' rel=\"noopener\"><i>strcat<\/i><\/a> in the making of a single string buffer from an array of zero-byte terminated char* strings in an array, with an added stipulation of a maximum string buffer length.   Sounds simple, and it is if you use <i>strcat<\/i> and\/or global strings, but my understanding of the brief would be that <a target=\"_blank\" title='Wikipedia information about global variables' href='http:\/\/en.wikipedia.org\/wiki\/Global_variable' rel=\"noopener\">global variables<\/a> will be frowned upon, as a lot of programmers will tell you.   Mind you, personally, global strings are not a problem for me.   Not using global strings and not using <i>strcat<\/i>, and making this work in a self-sufficient single function is quite interesting, and basically that is what we do here with this tutorial, via memory management using <a target=\"_blank\" title='malloc' href='http:\/\/www.cplusplus.com\/reference\/cstdlib\/malloc\/' rel=\"noopener\">malloc<\/a> &amp; <a target=\"_blank\" title='realloc' href='http:\/\/www.cplusplus.com\/reference\/cstdlib\/realloc\/?kw=realloc' rel=\"noopener\">realloc<\/a>.<\/p>\n<p>So feel free to download the Xcode C programming source code here and rename it to <a target=\"_blank\" title='main.cpp' href='http:\/\/www.rjmprogramming.com.au\/C\/NonGlobalStrings\/main.cpp_GETME' rel=\"noopener\">main.cpp<\/a> (or main.c &#8230; is pretty conservative in its construction &#8230; probably would work with Digital Mars C).<\/p>\n<p>Hope you enjoy this <a target=\"_blank\" title=\"Xcode debugging\" href=\"http:\/\/www.rjmprogramming.com.au\/C\/NonGlobalStrings\/XcodeDebug_C_NonGlobalStrings.m4v\" rel=\"noopener\">tutorial<\/a> showing you some cute Xcode debugging functionality.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d5238' onclick='var dv=document.getElementById(\"d5238\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Xcode\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d5238' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6728' onclick='var dv=document.getElementById(\"d6728\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Digital+Mars\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6728' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d75667' onclick='var dv=document.getElementById(\"d75667\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/executable\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d75667' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Xcode IDE on macOS, as a desktop application, for &#8230; Xcode -&gt; New -&gt; Project&#8230; -&gt; macOS \/ Command Line Tool -&gt; Product Name: [up to you] Language: C &#8230; represents, perhaps, the simplest and immediately approachable Xcode Project &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-executable-finding-and-executing-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,29,33,37,40],"tags":[1669,96,176,233,234,3953,4191,241,319,320,3929,435,585,2780,3954,2427,932,996,997,999,3942,1252,1319,1404,1473],"class_list":["post-75667","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-operating-system","category-software","category-tutorials","category-xcode","tag-address-bar","tag-application","tag-c","tag-command","tag-command-line","tag-command-line-application","tag-compilation","tag-compile","tag-desktop","tag-desktop-application","tag-executable","tag-find","tag-ide","tag-interactive-entry","tag-osascript","tag-passthru","tag-php","tag-program","tag-programming","tag-project","tag-shell_exec","tag-terminal","tag-tutorial","tag-web-browser","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/75667"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=75667"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/75667\/revisions"}],"predecessor-version":[{"id":75678,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/75667\/revisions\/75678"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=75667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=75667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=75667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}