OSX Development

I am noticing that a lot of people are having trouble getting used to developing on OSX. I hope that this is useful to those people, I am targeting someone who has at least some experience with Linux or another unix-like OS. I haven’t been using OSX long myself, but I have adapted quickly :)

What is XCode?
XCode is more than an application, it is a complete development environment. When someone ‘installs xcode’ they are installing compilers, frameworks, headers and build tools. If you can compile a C program you have XCode. Just to be sure, you can check by using commands like this

vortex:~ jhford$ which gcc/usr/bin/gccvortex:~ jhford$ which g++/usr/bin/g++vortex:~ jhford$ which make/usr/bin/makevortex:~ jhford$ which xcodebuild/usr/bin/xcodebuild

What is MacPorts
MacPorts is a system utility to ease installing non-apple unix software. This program is used to install things like subversion, mercurial, libidl, autoconf213 and ccache. Basically, what this program does is fetch sources, patches and build instructions and compiles the program for your system. This is very similar to BSD ports. To use the utility, you use the port command. Some sample uses:

sudo port install ccache mercurial libidl autoconf213port search subversionport list installed

The man page is the best place to go for help with MacPorts (man port). Unlike Fink, which uses Debian/Ubuntu’s apt-get internally, all things you install through MacPorts are compiled on your machine during install. Word of warning: don’t need anything in a hurry! Our network is notoriously slow with MacPorts.

What is a .dmg?
A .dmg is a compressed disc image format. It contains one or more filessytems, usually HFS+ (read: mac filesystem). This is how most .app and .pkg files are distributed because it maintains the mac specific file meta data.

What is a .app? .pkg?
You might have noticed that some applications are just icons, like Firefox or OpenOffice. To install them you drag the icon into your /Applications folder and boom, intalled. The most important thing to remember here is .app is just a folder! I will prove it

This means that if you want to start an application that is in a .app from the command line to see console output, you can do something like $ /Applications/Firefox.app/Contents/MacOS/firefox or /Applications/OpenOffice.org.app/Contents/MacOS/soffice. Usually your application will live under Appname.app/Contents/MacOS/

A .pkg file is an installer file, kind of like a .run script on linux or a .msi file in windows. It is too just a folder. Lots of things that are folders have file extensions on OSX. If in doubt, run file on it in Terminal

Universal Binary?
In case you didn’t know, Macs used to have PowerPC cpus. To ease the transition from PowerPC to Intel, Apple created something called a ‘Universal Binary’. These are basically executable files which can be run on either processor. If you want to check if you have made one you can use the unix command ‘file’ on the application. An example of a Firefox release binary shows that this is a universal binary:

vortex:Firefox.app jhford$ file Contents/MacOS/firefox-bin Contents/MacOS/firefox-bin: Mach-O universal binary with 2 architecturesContents/MacOS/firefox-bin (for architecture i386): Mach-O executable i386Contents/MacOS/firefox-bin (for architecture ppc): Mach-O executable ppc

Sometimes the second architecture will mention ppc7440 or something similar, this means it is a G4+ binary (i.e. requires altivec, similar to MMX/SSE).

Command, Option, Control?
I guess this is only applicable if you are in front of the machine. Command, Option and Control are similar to but not identical to Start, Alt and Control. In OSX, things are a little more logical. If the key combo you want to use involves doing something, say, close a tab, it is Command + W. In Windows/Linux it is Control + W. Keep this in mind, nearly all ctrl or alt key combos for GUI programs on Windows or Linux are the same on Mac but with Command. Option, like the name implies, give you an option. Say you have save and save as. Command + S is like save and since save all is so similar, it may have Command + Option + S. Worst case, you can look around in the menu bar at the top of the screen. A clover-ish thing means Command, a downward sloping line is Option and an up arrow is Shift.

On the command line, Control works just like ctrl in Windows or Linux. Control + D will give you EOF, Control + C will quit the application.

Screenshots!
To take a screenshot simple press one of:
Command + Shift + 3 – Fullscreen
Command + Shift + 4 – An area of the screen, like Snipping Tool in Vista
Command + Shift + 4 then release and press space – A ‘view’, could be a window or a sheet. Like Alt+Printscreen
These commmands will place the pictures on your desktop in the format PictureX.png where X is automatically incrementing.

Hopefully this helps you get the hang of Mac. If you have any questions feel free to leave a comment or ping me in IRC at irc://irc.mozilla.org/#seneca

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>