Native Mac apps built with Mac Catalyst can share code with your iPad apps, and you can add more features just for Mac. In macOS Big Sur, you can create even more powerful versions of your apps and take advantage of every pixel on the screen by running them at native Mac resolution. Apps built with Mac Catalyst can now be fully controlled using just the keyboard, access more iOS. Meet new long awaited Gantt Chart app. This is as much efficient tool as iOS version and includes all the important features and possibilities.
To create the Mac app in this tutorial, you need Xcode 4.4 or later. Xcode is Apple’s integrated development environment (or IDE) for both OS X and iOS development.
Usage note: This tutorial lists the steps that are required to complete a task in a disclosable area that is defined by two horizontal blue lines and labeled with a blue dot and a phrase that describes the task, such as “To create a new project…” To reveal the steps in a task area, click inside the blue lines.
When you complete the steps in a task, you can leave the task area open or you can close it by clicking the line with the blue dot and the descriptive phrase. (Clicking elsewhere in an open task area does not close it, so you can copy code from a step without closing the task.)
To get started developing your app, you create a new Xcode project.
Launch Xcode (located in the Applications
folder).
If you’ve never created or opened a project in Xcode before, you should see a Welcome to Xcode window similar to this:
If you’ve created or opened a project in Xcode before, you might see a project window instead of the Welcome to Xcode window.
In the Welcome to Xcode window, click “Create a new Xcode project” (or choose File > New > Project).
Xcode opens a new window and displays a dialog in which you choose a template. Xcode includes several built-in app templates that you can use to develop common styles of Mac apps.
In the OS X section to the left of the dialog, select Application.
In the main area of the dialog, select Cocoa Application and click Next.
A new dialog appears that prompts you to name your app and choose additional options for your project.
In the Product Name field, type TrackMix
.
In the Company Identifier field, type the identifier for your company, or com.MyCompany
.
In the App Store Category pop-up, choose None.
Note: Xcode uses the product name you entered to name your project and the app. To keep things simple, this tutorial assumes that you named your product TrackMix
and did not specify a class prefix value. (The prefix is used to create unique class names for your app that won’t conflict with classes in other frameworks.) The organization name property that appears in this dialog is not used in this tutorial.
Make sure that the Use Automatic Reference Counting option is selected and that the Create Document-Based Application (appears above Document Extension), Use Core Data, and Include Unit Tests options are unselected.
Another dialog appears that allows you to specify where to save your project.
Specify a location for your project (make sure that the Source Control option is unselected) and then click Create.
Xcode opens your new project in a window (called the workspace window), which should look similar to this:
Take a few moments to familiarize yourself with the workspace window that Xcode opens for you. You’ll use the buttons and areas identified in the window below throughout the rest of this tutorial.
If the utilities area in your workspace window is already open (as it is in the window shown above), you can close it for now because you won’t need it until later in the tutorial. The rightmost View button controls the utilities area. When the utilities area is visible, the button looks like this:
If necessary, click the rightmost View button to close the utilities area.
Even though you haven’t yet written any code, you can build and run your app in Xcode.
Click the Run button in the Xcode toolbar (or choose Product > Run).
If a dialog appears asking whether Xcode should enable developer mode on this Mac, click Disable.
Xcode should build your project and launch the app. When your app starts up, it should have a standard menu bar and display a single window.
You can move and resize the window. However, if you close the window, there is no way to get it back. You should also find that menus display when you click them, and if you choose TrackMix > About TrackMix, an About window is displayed.
Quit the app by choosing TrackMix > Quit TrackMix.
Don’t mistakenly choose the Quit command in Xcode, or you’ll quit Xcode. You can also click the Stop button in Xcode.
Right now, your app is not very interesting: it simply displays a blank window. To understand where the blank window comes from, you need to learn about the objects in your code and how they work together to start the app.
Because you based your project on an Xcode template, much of the basic app environment is automatically set up when you run the app. For example, Xcode creates an app object which, among a few other things, establishes the run loop. (A run loop registers input sources and enables the delivery of input events to your app.) Most of this work is done by the NSApplicationMain
function, which is supplied for you by the AppKit framework and is automatically called in your project’s main.m
source file.
Note: The AppKit framework provides all the classes that an app needs to construct and manage its user interface. The AppKit framework is just one of many object-oriented frameworks provided by Cocoa, which is the app environment for all Mac apps.
Make sure the project navigator is open in the navigator area.
The project navigator displays all the files in your project. If the project navigator is not open, click the leftmost button in the navigator selector bar:
Open the Supporting Files folder in the project navigator by clicking the disclosure triangle next to it.
Xcode opens the source file in the editor area of the window, which should look similar to this:
The call to the NSApplicationMain
function creates an instance of the NSApplication
class and an instance of the AppDelegate
class, which is provided for you by the Cocoa Application template. In this tutorial, the singleton instance of this class is referred to as the app delegate. The main job of the app delegate is to provide a window you can access through its window
property. The window object provides a container for the app’s visible content and helps deliver events to other app objects. The app delegate can also perform some app configuration tasks before the app is displayed. You add your custom behavior and logic to the AppDelegate
class and any other classes you create.
The instance of the NSApplication
class, called the app object, loads the main nib file when the app launches. Nib files are an archive of UI elements and other objects. The main nib file, MainMenu.xib
, usually contains the parts of your user interface, such as the menu bar and window, that are visible the entire time your app is running. When a nib file is loaded, the objects it contains are instantiated.
Click MainMenu.xib
under the TrackMix group in the project navigator.
The file has the extension .xib
but by convention it is referred to as a nib file. Xcode displays the file on a canvas in the editor area.
If an outline view appears instead of the standard editor, click the Standard editor in the Editor toolbar.
To display the window, click the window icon in the sidebar.
The sidebar contains several items split into two groups by a dividing line. Above the line are placeholders—objects that are not created as part of the nib file itself, but exist externally. Below the line are objects created as part of the nib file:
A menu object
This object is the app’s main menu displayed in the menu bar.
A window object
This object is the window with a plain gray background that you see when the app launches.
An instance of AppDelegate
(a dark blue cube), set to be the app object’s delegate
When the app object has completed its setup, it sends its delegate an applicationDidFinishLaunching:
message. This message gives the delegate an opportunity to configure the user interface and perform other tasks before the app is displayed.
An instance of NSFontManager
(a dark blue cube)
This object manages the app’s font menu, but you won’t use it in this example.
In this chapter you used Xcode to create a new project based on the Cocoa Application template and you built and ran the default app that the template defines. Then you looked at some of the basic pieces of the project, such as the main.m
source file, and the nib file, and learned what objects are created and loaded from the nib file when the app launches.
In the next chapter, you’ll learn how to lay out and configure the user interface without writing any code.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-04-23)
Please try submitting your feedback later.
Your input helps improve our developer documentation.
Even if you don’t buy a new $6,000 Mac Pro, your Mac is about to get a whole lot more powerful. Alongside macOS 10.15 Catalina, Apple unveiled a new way to design apps across all of its platforms. Called Project Catalyst, the new initiative builds on the News, Stocks, Voice Memos, and Home apps Apple launched in macOS 10.14 Mojave, and it has the potential to transform the entire app ecosystem.
Project Catalyst is designed so a team of developers can easily make a single app that runs on the iPhone, iPad, and Mac without needing to spent months on each. In its announcement of the new macOS framework, Apple showcased three apps during the WWDC keynote: Asphalt 9: Legends from Gameloft, Twitter, and Atlassian’s Jira Cloud.
Granted, none of these developers are exactly small, but the idea is that an iOS or iPadOS app can be ported to the Mac with very little work. Twitter, for example, was able to develop a native Mac app in just one day, and Gamelot said it had a macOS version of its racing game, which hit the App Store in July, running on the first day.
That’s a massive accomplishment for a process that normally takes months and tons of resources. With an ever-shrinking audience, many developers have understandably shifted their focus away from the Mac, but Project Catalyst should make it as easy to bring an iOS app to the Mac as it is to turn on iPhone app into an iPad one, completely with drag-and-drop functionality and a full-screen experience..
And they’ll be more than super-sized iOS apps. Apple is respecting the Mac’s menus and interface so apps will look as native as they can. Developers will be able to add unique features as well. Atlassian said it was able to use Project Catalyst to “put the finishing touches that make (Jira Cloud) perfect for the desktop” and Twitter was able to add “native Mac features” without spending weeks designing and testing. On its website, Apple also highlighted DC Universe, TripIt, and Fender Play, all with Mac-style UIs.
Apple presumably used Catalyst on several of macOS 10.15’s new apps as well, including Screen Time, Find My, and the redesigned Reminders app. Project Catalyst is available to developers today as part of the macOS 10.15 Catalina beta. A public beta will be available in July, with the official release happening in the fall.