Create a New Mac Cocoa App

Matthew Campbell, January 4, 2013

Usually, our blog readers are more interested in making iPhone apps (hence the title of the blog). But, with the Mac app store and the demands of many users who want desktop versions of apps many developers also want to implement a Mac app. Here’s how to use Xcode to set up a Cocoa application on the Mac.

NOTE Cocoa is the desktop equivalent to the iOS Cocoa-Touch. The name Cocoa refers to the frameworks that provide developers with user controls and other interface elements among other things. While Cocoa is not identical to Cocoa-Touch, the patterns that you follow are very similar so Mac development and will feel familiar to you. Also, the Foundation frameworks and of course the Objective-C programming language are shared between Cocoa and Cocoa-Touch applications.

Setting up an Mac Cocoa application with Xcode is very straightforward. The process is a lot like creating a new text document or Keynote presentation. Here’s how to do it

Install Xcode

Xcode is the IDE, Integrated Development Environment, used to create Mac apps. This app is a free download that you can get from Apple by using the links below.

Click here to download and install Xcode from your Mac: Install Xcode.

BTW: this is a free tool to use on your Mac. To distribute Mac or Mac apps on the app store you’ll need to pay a yearly fee to Apple ($99 for each).

Start Xcode

Locate Xcode from the Applications folder – it’s the app named Xcode.app and will look like the icon below.

You can also use the Spotlight feature on your Mac to locate and start Xcode.

Add New Project

Make sure that Xcode is selected. Select File > New > Project… .

A dialog box will appear with many options that you have. You can actually create Mac, iPad and iPhone apps from this dialog. Here is what the dialog box will look like:

Choose OSX > Application > Cocoa Application . Then click Next. You should see a dialog box that looks like this:

Fill in the fields with your information. Most importantly, include your app’s name and your website URL for the bundle identifier. Make sure to pick iPhone for Devices. Pick iPad for iPad apps and Universal for apps that run on both iPad and iPhone. Also be sure to choose Use Automatic Reference Counting. Click Next. That’s about it.

Inspect and Test Project

Xcode will take the information that you provided to set up a project that can be used to start building your app. The configuration is all set up and you can even test the app on your Mac by clicking the run button located in the lefthand area of the Xcode screen.

Here is an example of what files you will see in your Xcode Mac Cocoa Application project:

Of course now that you have the project set up you can go ahead and start testing some code. Like iOS applications, you will likely start with the AppDelegate. Mac apps don’t have storyboards (at least as of this writing), so you will need to use the NIB files to work with the interface (the files ending in xib).