{"id":55360,"date":"2022-04-12T03:01:01","date_gmt":"2022-04-11T17:01:01","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=55360"},"modified":"2022-04-11T21:33:23","modified_gmt":"2022-04-11T11:33:23","slug":"xcode-command-line-project-executable-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-command-line-project-executable-tutorial\/","title":{"rendered":"Xcode Command Line Project Executable Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/find_executable_and_go.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Xcode Command Line Project Executable Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/find_executable_and_go.jpg\" title=\"Xcode Command Line Project Executable Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Xcode Command Line Project Executable Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='Xcode Swift Command Line Project Primer Tutorial' href='#xsclppt'>Xcode Swift Command Line Project Primer Tutorial<\/a> combines with our recent macOS <a target=_blank title='Linux find command information from computerhope' href='http:\/\/www.computerhope.com\/unix\/ufind.htm'>find<\/a> related work, so that, today, we&#8217;ve written a small PHP &#8220;helper&#8221; web application, which &#8220;fishes out&#8221; that Xcode macOS executable, and executes it for you, that we want you to download to (the Document Root of) a macOS <a target=_blank title='MAMP' href='http:\/\/www.mamp.info'>MAMP<\/a> local Apache\/PHP\/MySql web server environment, &#8220;Intranet style&#8221;, as has also been a theme of our work recently.<\/p>\n<p>What are the modes of use of this PHP &#8220;helper&#8221; web application?  Well, any of &#8230;<\/p>\n<ul>\n<li>surfing the web &#8230; via web browser URL like  &#8230;<br \/>\n<code>HTTP:\/\/localhost:8888\/find_executable_and_go.php?inproject=Swift%20Command%20Line&amp;argvs=one+two+three<\/code><br \/>\n &#8230; or fill out a form at <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/find_executable_and_go.php_GETME\" title=\"find_executable_and_go.php\">find_executable_and_go.php<\/a>&#8216;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/find_executable_and_go.php\" title=\"Click picture\">live run<\/a> link\n<\/li>\n<li>curl &#8230; via macOS command like  &#8230;<br \/>\n<code>curl \"HTTP:\/\/localhost:8888\/find_executable_and_go.php?inproject=Swift%20Command%20Line&amp;argvs=one+two+three\"<\/code>\n<\/li>\n<li>PHP on command line &#8230; via macOS command like  &#8230;<br \/>\n<code><br \/>\nphp find_executable_and_go.php one two three<br \/>\n<\/code><br \/>\n &#8230; and fill out the Xcode project name\n<\/li>\n<\/ul>\n<p> &#8230; or, after your downloading to macOS (where you&#8217;ve installed, and are using, <a target=_blank title=Xcode href='https:\/\/developer.apple.com\/xcode\/'>Xcode<\/a>), the ideas below could work &#8230;<\/p>\n<p><iframe src='http:\/\/www.rjmprogramming.com.au\/PHP\/find_executable_and_go.php' style='width:100%;height:350px;'><\/iframe><\/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-command-line-project-executable-tutorial\/'>Xcode Command Line Project Executable Tutorial<\/a>.<\/p-->\n<hr>\n<p id='xsclppt'>Previous relevant <a target=_blank title='Xcode Swift Command Line Project Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/xcode-swift-command-line-project-primer-tutorial\/'>Xcode Swift Command Line Project Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/xcode_swift_command_llne_project.gif\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Xcode Swift Command Line Project Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/xcode_swift_command_llne_project.gif\" title=\"Xcode Swift Command Line Project Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Xcode Swift Command Line Project Primer Tutorial<\/p><\/div>\n<p>The macOS Xcode IDE (<a target=_blank title='Integrated Development Environment information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Integrated_development_environment'>Integrated Development Language<\/a>)  is a great place to create many and various types of executable software.  The language Swift is Apple&#8217;s language of choice, within Xcode, for &#8230;<\/p>\n<ul>\n<li>iOS mobile apps &#8230; and today we build a simple &#8230;<\/li>\n<li>macOS command line app<\/li>\n<\/ul>\n<p> &#8230; which we allow to process your command line arguments.  Then &#8220;we fish out&#8221; where Xcode has stored the resultant Swift command line executable, and execute that &#8220;binary&#8221;.<\/p>\n<p>All told, we &#8230;<\/p>\n<ol>\n<li>open Xcode via clicking its macOS icon<\/li>\n<li>click &#8220;Create a new Xcode project&#8221; button<\/li>\n<li>choose Application -&gt; &#8220;Command Line Tool&#8221; then click &#8220;Next&#8221; button<\/li>\n<li>Project Name: &#8220;Swift Command Line&#8221;<\/li>\n<li>Language: &#8220;Swift&#8221; then click &#8220;Next&#8221; button<\/li>\n<li>in Project Navigator menu click &#8220;main&#8221; to see the default Swift code<\/li>\n<li>we end up making our code be like <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/main.swift_GETME\" title=\"main.swift\">main.swift<\/a> &#8230;<br \/>\n<code><br \/>\n\/\/<br \/>\n\/\/  main.swift<br \/>\n\/\/  Swift Command Line<br \/>\n\/\/<br \/>\n\/\/  Created by User on 10\/4\/22.<br \/>\n\/\/<br \/>\n<br \/>\nimport Foundation<br \/>\n<br \/>\nvar msg = \"\"<br \/>\nvar i = 2<br \/>\n<br \/>\nif CommandLine.arguments.count <= 1\n{\n    print(\"Hello, World!\")\n}\nelse\n{\n    msg = CommandLine.arguments[1]\n    while i < CommandLine.arguments.count\n    {\n        msg += \" \" + CommandLine.arguments[i]\n        i += 1\n    }\n    print(msg)\n}\n<\/code><br \/>\n ... via good help from <a target=_blank title='good help' href='https:\/\/stackoverflow.com\/posts\/24110744\/edit'>this link<\/a>, thanks\n<\/li>\n<li>to execute in Xcode's Console we choose the menu option Product -&gt; \"Run\" and see the results down the bottom to left in Xcode's Console with \"Hello, World!\" output because there are no command line arguments as the default condition<\/li>\n<li>to execute within Xcode with command line arguments ...\n<ul>\n<li>we choose the menu option Swift Command Line -&gt; \"Edit Schema...\"<\/li>\n<li>we choose the menu option Info -&gt; Build Configuration -&gt; \"Release\"<\/li>\n<li>we click \"Arguments\" tab<\/li>\n<li>we click \"Arguments Passed on Launch\" tab's \"+\" button ... and ...<\/li>\n<li>type in \"one two three four five\" as our user specific command line arguments<\/li>\n<li>click \"Close\" button<\/li>\n<\/ul>\n<\/li>\n<li>we choose the menu option Product -&gt; \"Run\" and see the results down the bottom to right in Xcode's Console with \"one two three four five\"<\/li>\n<\/ol>\n<p> ... and then (with thanks to advice of <a target=_blank title='good advice' href='https:\/\/stackoverflow.com\/questions\/28201337\/xcode-command-line-app-where-is-the-executable-code'>this link<\/a>) we ...<\/p>\n<ol>\n<li>open Terminal via clicking its macOS icon<\/li>\n<li>type in the command (where, for us, <i>\/Users\/user<\/i> can equate to <i>$HOME<\/i> if you'd prefer) ...<br \/>\n<code><br \/>\nfind \/Users\/user\/Library\/ -name \"Swift Command Line\" -exec file {} \\; 2> \/dev\/null<br \/>\n<\/code><br \/>\n ... leading us to conclude that ...\n<\/li>\n<li>typing in ...<br \/>\n<code><br \/>\n\"\/Users\/user\/Library\/\/Developer\/Xcode\/DerivedData\/Swift_Command_Line-ayzqxnplmfgugrclirdeaxwmiryj\/Build\/Products\/Release\/Swift Command Line\"<br \/>\n<\/code><br \/>\n ... would result in the output \"Hello, World!\" (as it did) ... and ...<\/li>\n<li>typing in ...<br \/>\n<code><br \/>\n\"\/Users\/user\/Library\/\/Developer\/Xcode\/DerivedData\/Swift_Command_Line-ayzqxnplmfgugrclirdeaxwmiryj\/Build\/Products\/Release\/Swift Command Line\" one three five<br \/>\n<\/code><br \/>\n ... would result in the output \"one three five\" (as it did)<\/li>\n<\/ol>\n<p>We hope this is of interest to beginners in Swift and Xcode IDE software development in macOS operating system.<\/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='#d55355' onclick='var dv=document.getElementById(\"d55355\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/swift\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d55355' 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='#d55360' onclick='var dv=document.getElementById(\"d55360\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d55360' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday&#8217;s Xcode Swift Command Line Project Primer Tutorial combines with our recent macOS find related work, so that, today, we&#8217;ve written a small PHP &#8220;helper&#8221; web application, which &#8220;fishes out&#8221; that Xcode macOS executable, and executes it for you, that &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-command-line-project-executable-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,29,37],"tags":[91,96,170,233,234,3953,3929,435,3572,585,624,2178,744,885,932,996,997,999,1227,1319,1473],"class_list":["post-55360","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-apple","tag-application","tag-build","tag-command","tag-command-line","tag-command-line-application","tag-executable","tag-find","tag-helper","tag-ide","tag-intranet","tag-macos","tag-mamp","tag-operating-system-2","tag-php","tag-program","tag-programming","tag-project","tag-swift","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55360"}],"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=55360"}],"version-history":[{"count":8,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55360\/revisions"}],"predecessor-version":[{"id":55386,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55360\/revisions\/55386"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=55360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=55360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=55360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}