Episode 21 – Swift, Ready or Not Here it Comes

Feed updated

This week we discuss the use of Swift in production apps. We each relate our experiences with the interactive and often difficulties working with Xcode and Swift 1.1. We also discuss the reaction to a post by Marco Arment that sparked many developers into voicing an opinion. We discuss our picks; Smash Hit, Piskell, AV Audio Engine and Printrbot Simple Metal 3D printer. During and after the show we briefly discuss Magicavoxel, Aaron’s prowess at Crossy Road, Dash and app pricing.

Restart USBmux Daemon in Terminal
on the command line enter:
sudo launchctl stop com.apple.usbmuxd

Thanks to Fahim Farook (mentioned as the dev from Malaysia)

Pure Swift Apps on the App Store:

WriteTrack – Submission Tracking for Writers
WriteOn Lite
Instant Poetry 2

Episode 21 Notes:

Swift 1.1
Devices not connecting in Xcode
Apple Has Lost the Functional High Ground
Release Notes Podcast
Fast Fourier Transform
Dash API Docs

Episode 21 Picks:

Smash Hit

WWDC 2014 Videos

Start FTP as service in Leopard

Apple has removed the FTP management functions in Leopard’s System Preferences. However it is still possible to run FTP on your Mac under 10.5.

To start the FTP service in the Terminal type:
sudo /sbin/service ftp start

To stop it type:
sudo /sbin/service ftp stop


Duh! It looks like Apple moved the “FTP” and “Windows” under Options in the Sharing Preference in System Preferences. Oops!

Where has my space gone…

Q. My hard drive seems to be full and Photoshop says my scratch disk is full. I can’t find any more files to through away what can I do?

A. Often your computer will complain that it s full yet there doesn’t appear that there are any big files. In fact there could be a temporary file or and index file and it may be invisible.

The first thing to do is to navigate to the top most folder. Start by clicking on your hard drive. It may be called “Macintosh HD”. From the “View” menu chose “ShowView Options”. You can choose “This Window Only” and check off “Calculate Folder Sizes” near the bottom. Then switch the view for the Finder window to “list” again from the “View” menu. Next click “Size” to sort the items by size, with the triangle pointing down the largest folder will go to the top.

After a short while the folders with the most files by size will move to the top. You can easily clean up files in your own home folder however you should leave the “System”, “Library” and “Applications” alone.

Occasionally you may find a folder has more data in it than its members add up to. In this case there is an invisible item that it taking up a lot of space. This will require a visit from your friendly neighborhood IT guy or a clean up utility to fix

Recently we discovered an invisible 135GB index file called “v_m.txt” that was preventing a user from working. In that case, the file was deleted with the Terminal. You can read about cleaning up space at: http://www.thexlab.com/faqs/freeingspace.html or if you feel inclined you can download TinkerTool from: http://www.bresink.com/osx/TinkerTool.html . Keep in mind my advice and proceed with caution.

Share Mac external HDs with Windows

Q. I have a MacBook and a couple of PCs. I also have an external 1TB drive on my Mac. I can mount the Mac’s internal hard drive on my PCs but I cannot mount the 1TB hard drive. Is this possible?

A. One of the cool things about Macintosh computers is that we’ve always been able to read data on Windows drives and floppy disks. In the past there were utilities to that enabled Windows computer to run AppleTalk protocol and read Macintosh volumes.

Mac OS X includes Samba which allows users to run SMB (Server Message Block) protocol. SMB was developed by IBM, but has been highly modified by Microsoft. The open source Samba has reverse engineered SMB to provide a version for non-Microsoft systems.

By running SMB on your Macintosh you can share your files with your Windows neighbors. Go to System Preferences -> Sharing and check Windows Sharing. Then PC users can add your Mac to their Network Places or “map” your drive as a network drive by adding \yourIPaddressvolumename.

The problem with external drives is that they are not automatically included in the smb shares. When you enable “Windows Sharing” a configuration file is written to the Unix file system. Most configuration files are stored in the “etc” directory and there you’ll find the “smb.conf” file.

So once again open the Terminal (Applications -> Utilities -> Terminal) and at the prompt enter “cd /etc” and press enter – to “change directories” the “etc” directory. You need to be an administrator to edit the file and you should begin by backing up the file. Enter “sudo cp smb.conf smb.bak” at the prompt to make a copy of the file. “sudo” is a special command that lets you act as an administrator for a short period of time.

Check that you’ve made a copy by listing the files with “ls –la” and Return. You should see both the original and the backup. Now edit the file with “ed”, “vi” or “pico”. With pico the display is similar to most text editors and the commands are at the bottom of the file. Enter “pico smb.conf” and scroll to the bottom (with Control V) and add the following to the bottom of the file:

path = /Volumes/LaCie_d2_156_GB
valid users = tmitra
writeable = yes

In the example above my “Share name” is “LaCie” – this is what the PC user will see. The Macintosh name of my drive is “LaCie_d2_156_GB” – note that I have replaced the spaces with underscores. The “valid user” is the name of a user on my Macintosh and “writeable” means that I can read and write to the drive.
Now on the PC go to “My Computer” and choose “Map Network Drive” from the Tools menu. Then in the dialog enter the Mac’s IP as the server and the share name:


Then enter your username and password and the volume should be mounted. You can then copy files to and from your PC – and share them with the Mac.

/etc/master.passwd: no such file or directory

Q. The other day when my Macintosh started, it came up with the registration screen but it wouldn’t let me quit. So I restarted my Mac , it came up with an error saying that ‘/etc/master.passwd: no such file or directory’. I don’t want to erase my files and I can’t reinstall the system. What can I do?

A. Normally when a Macintosh starts up it looks for specific files on your hard drive. These files may have become damaged or corrupt during a crash or if you forced it to reboot. During the start up the machine will test its components, checking the RAM and connections and ‘chime’ to let you know it passed the tests.

Next you’ll see the Apple logo and then the spinning pinwheel while it loads the operating system. If successful, the screen turns blue and you’ll see the mouse pointer icon. Soon after a dialog box with a progress bar indicating the extensions load and then blue screen soon reveals the login screen (or goes directly to the Finder).

In the case of the error mentioned in the question you don’t get to the login screen because the Macintosh cannot find certain files it needs to log you in. This is where we rescue the Mac using our UNIX arsenal of tools. If you’ve followed my columns you’ll know that one of the things I love about Mac OS X is that it is at its heart based on UNIX. What has happened here is that a couple of UNIX directories are missing (or seem to be.)

There are at least three ways to get to the command line on a Mac that won’t start. You could plug the Mac into another in target mode and use a FireWire cable to plug it into another Macintosh. To enter target mode, you hold down the ‘T’ key while your Mac starts. You’ll see a FireWire Icon (instead of an Apple logo) and your drive will appear on the second Mac as a hard drive, but you won’t see the UNIX files that we need to fix except on the command line.

Insert Tiger Install DVD into the DVD drive. Then hold the ‘C’ key while starting your Macintosh. When the Installer starts, choose ‘English’ and click ‘Continue’. At the next screen you’ll see a Utilities menu, from which you can choose ‘Terminal’. Voila! The command line appears. To navigate to you drive (since you started from the DVD) you change directories or type ‘cd /Volumes/Macintosh HD’ and press return (we press ‘Return’ to execute a UNIX command).

If you don’t have the DVD, you can start the Mac holding the ‘Cmd & S’ key. This will start the Mac in ‘Single User Mode’ and your monitor will be a terminal. Next mount the drive by typing ‘mount -uw /' and press Return. You’ll already be on your hard drive so navigate to top (or root) of the drive with: ‘cd /'.

Next you should check and to see if two files are present. These are actually ‘symbolic link’, the UNIX equivalent of Mac ‘alias’ or Windows ‘short cut’. So we list the contents of our hard drive with ‘ls -la’ and you should look for two items named ‘etc’ and ‘var’. The reason why the Macintosh can’t start is because one of these is missing or damaged. They should appear as ‘etc -> /private/etc' and ‘var -> /private/var'.

If they don’t appear like as above then we can rename them with ‘mv’ and the recreate the symbolic links. So type ‘mv etc etc.bad' or ‘mv var var.bad' followed with a ‘return’ and the files will be renamed. To recreate the symbolic links we type ‘ln -s /private/etc etc’ (return) and/or ‘ln -s /private/var var’. So once again check to see that the files are there and correct with list. Type ‘ls -la’.

If they appear to be correct:
lrwxrwxrwx-t 1 root admin (date) etc -> /private/etc
lrwxrwxrwx-t 1 root admin (date) var -> /private/var
Then you can restart the Mac:
Type ‘reboot’ and press Return.

When the Mac restarts, the setup screen may appear again. Create a second user account and when the Finder loads you’ll be able to switch to you regular account.

File sharing Permissions

Q. We have a small graphics department with 4 Macs with external hard drives and no server. We use each other’s files often but we have a problem with permissions. The files are often locked so we can’t open them and save them. It’s very frustrating. How can we get rid of permissions?

A. The problem is that you can’t get rid of permissions. Since MacOS X is Unix, file permissions are at the core of every file. Every file and process on the Mac belongs to a user and a group. Permissions are set up to protect the system from the users and to protect each user’s files.

However, you can get around them or get them to work for you. If you log into the other Macs as “guest” or as a valid user then you can change the permission on a folder (and it’s contents) to be accessible by that user.

Simply stated to change the permissions select the file or folder in the Finder and choose “Get Info” from the “File” menu. Under “Ownership & Permissions” click the triangle to expand and see the Details. You should see the “shortname” of the “Owner”, the “Group” of the owner and “Others”. In order for someone to be able to open (read) and save (write) changes, they either have to be the owner or a member of the group to whom the file belongs.

The easiest way to control a file remotely is to login as the owner. However then you have the same access as the owner – this means you have to be careful. You can create a generic log in to the Mac, such as “macuser” and use the same login on all the Macs – but you would have to do this when you’re setting up the Macs. The installer that sets up the computer doesn’t explain this very well – again to protect the computer…

Another choice you have is to create a second login user on each Mac and then change the permission for the group “staff’ on the folder you want to share. Every user login account on the Mac belongs to the group named “staff”. In order to share a file in the folder, change the permissions for the group to be “staff” and set to “Read and Write”. Also choose “Apply to enclosed items…” to have the permission change all of the files and folders inside – we refer to this as “recursively”. The only drawback is that new file will only be “read only” to staff until you change permissions.

There is also a shareware program called “SharePoints” (www.hornware.com) which emulates the way that a MacOS X sever handles sharing. On a MacOS X Server, you set up folders as “share points” which allow all users in a group to have equal access to the files. This is the same way that MacOS 9 did file sharing as well.

Changing permissions on the command line

Of course, you can also change permissions on the command line. (You have been reading All of my articles – haven’t you?) To change permissions, you have to change a file’s mode using the “chmod” command. To change a file’s owner or group you use the “chown” command.

To begin, open the Terminal app (Applications/Utilities/Terminal). You should then navigate to the folder that contains the file, using the “cd” command. When you open the Terminal you are inside your home folder. (Type “pwd” and Return to see the current or “present working directory”.) You can list the files with “ls” to see the files and folders. Use “ls –la” (that’s list with the options “long” and “all”) to see a long list:

timmitra@TimsG4 [103] ls -la
-rw-r–r– 1 timmitra staff 87444 15 Nov 2005 Configuring.pdf
drwxr-xr-x 141 timmitra staff 4794 7 Jun 16:27 Desktop
drwxr-xr-x 47 timmitra staff 1598 18 Apr 13:16 Documents
-rw-r–r– 1 timmitra staff 3033258 6 Oct 2005 EngStudio 05.pdf

The first part shows the permissions (“d” or “-“ means a directory or file)
The “rwx” is read, write or execute for owner, group and others.
Listed next are the Owner’s short name and group.

To change permissions so all can read and write use the command “chmod 755” and then the file or folder name. If you use the recursive option, “chmod –R 755” on a file then all the file’s contents will be made available. (Remember to be careful and you are opening all the files to be accessible.) If you want to make all files inherit the permissions of the folder, you can use “chmod 1755” and the folder (or “chmod g+s foldername”). This turns on the sticky bit and all new files will have the same permissions.

Becoming root with sudo

This month were going to take a closer look at taking control of MacOS X by becoming a super user. The underpinnings of MacOS X are after all UNIX, so you should be aware of the power a super user wields.
The root account is a “super user” account built into every UNIX system, which you may remember is a multi-user environment. Other systems such as AppleShare IP or Windows Servers had highly privileged administrator accounts, however on a UNIX system the level of access that root has have seems to have no limits.
There are many processes and files are “owned” by root. We’ve looked at “permissions“ in past articles, and you may remember that permissions control what you can do and see. Keep in mind that the all-powerful root account must be treated with respect and root access should be limited to a small group of users. There is no way to stop the root account from altering any file on the system.
You have already experienced becoming a super user while using the Aqua GUI. Whenever you try to install an application or an update, you will have been asked to enter you username and password. Although you’ve already logged in, the “Authentication Manager” is challenging you to prove that you’re an administrator. This is one of the ways that Apple allows users to administrate their own machine.
The “sudo” application is included so you can become a super user on the command line. If you try to run an application or see the contents of a file or folder that belongs to root, you will get an error like “permission denied”.
I’ll tell you a secret – Built into MacOS X is the Apache Web Server. Unlike “Personal Web Sharing”, your Mac can become a fully functional web server. In order to enable it you’ll have to edit a file while becoming a super user.
Let’s start by opening the Terminal application. (Applications => Utilities => Terminal) At that command prompt (%), we’ll change directories to “etc”.
% cd /etc
“etc” is a system directory that contains, among other things, configuration files. The mystery here is that one of the files in “etc” enables the Apache Web Server. Last month I showed you the “fgrep” program, which allows us to find text strings inside files. We’ll look for “WEB” in “etc”. Type this:
% sudo fgrep “WEB” *
Unlike last month, this time we’re going to precede the “fgrep” with “sudo” so that we’re running the application as a super user. “sudo” , or “super-user do” allows us to assume a high level of authority to search through the files. The first time you use “sudo”, you’ll get a short lecture about respecting others and most importantly “Think before you type.”
If UNIX were like a car, it would be a tank . You can start the tank, put it gear and it will drive forward. Even if parts fell off, it would continue. If you, the driver, fell off – It would continue to drive forward! So, think before you type.
After you enter your password (and hit “Return”) your program will run, and you will see something like this:
fgrep: cups: Is a directory
fgrep: httpd: Is a directory
Ah ha! The file we’re looking for is “hostconfig”. In order to activate the Apache Web Server we’ll change the “NO” to “YES”. Let’s use the “ed” program (you can use “pico” or “vi” if you prefer) but we’ll have to precede the command with “sudo” again. If we don’t start with “sudo”, we won’t have permission to save the file.
First let’s backup the file. Type “sudo cp hostconfig hostconfig.backup” to copy (cp) the original. Just in case! You can also use “ls” to confirm that you made a copy… Then we’ll edit the file with “sudo ed hostconfig”
Begin by printing the file to screen with “1,$p” which will print (p) the file from line “1” to the end ($).
Type “/WEB”, to jump to the line that contains the string “WEB”. Next type, “s/NO/YES/p” to substitute (s) “NO” with “YES”, and then print (p) the line.
At any time, you can type “f” to confirm the name of the file you’re editing. You should also use “1,$p” to confirm your changes before you save the file by writing and quit. Type “w” to write the file and “q” to quit.
You have now enabled the Apache Web Server. Open your browser, and enter “localhost” or “” in the URL and you will get the default Apache page. This was possible because you became a super user with “sudo”. Now you can put on your “HTML” hat and start writing your web site.