I’m new to Mac, OS X and swift. I’ve done some work with Windows and C# a few years ago. OBTW, Cocoa Programming for OS X was very well done and useful. I’m not quite done with it yet, but it’s a great place to start.
I understand Xcode 6, the value of the IDE and all that, however, i’d like to write a program in swift using a context sensitive editor, compile it to an executable, and then run it from the command line. I’m not seeing anything online or in a couple books I’ve read on how to do that. I guess I can make due with a simple window app if that’s the best way to go. Is that what the command line Application project in Xcode 6 is all about? Any ideas?
Also, I’m not seeing much on simple binary or text file routines for creating, opening, writing, reading, … in swift. I see the NSStream class, but I need a little more help with it than whats available online. Anyone have a good resource? Thanks!
That’s pretty easy to do in Xcode. You can create a tool in Xcode, and run it from the command line as outlined below.
Create a project for an OSX Application by using the Command Line template and by choosing Swift as the language.
You will have a single Swift file for the ubiquitous Hello, World! program, (in Xcode Version 6.3.2 (6D2105.)
Build the product.
Locate the binary for the product as follows:
Activate the contextual menu on the product under the Products group in the navigation area, and select Show in Finder.
This will open the folder containing the binary file.
Start up the Terminal application, and change the working directory to that folder.
Run the binary: ./
For example: ./MyCommandLineTool
Enjoy watching the output of your masterpiece
[Become a competent programmer faster than you can imagine: pretty-function.org]