See full list on en.wikibooks.org. While there are several books on programming for Mac OS X, Advanced Mac OS X Programming: The Big Nerd Ranch Guide is the only one that contains explanations of how to leverage the powerful underlying technologies. This book gets down to the real nitty-gritty. The third edition is updated for Mac OS X 10.5 and 10.6 and covers new technologies like DTrace, Instruments, Grand Central Dispatch.
About the platform[edit]
- Why programmers think Mac OS X is the best operating system to use; 10 best Mac programming resources for beginners; 10 things every Mac coder should know; 10 tips for new coders; Best Mac for app.
- All-new Interface. MacOS Big Sur brings a new design that’s been finely tuned for the powerful features that make a Mac a Mac. Core features, such as the menu bar and Dock, take advantage of the large Mac display, with translucent backings and spacious pull-down menus.
- Swift is a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV, and Apple Watch. It’s designed to give developers more freedom than ever. Swift is easy to use and open source, so anyone with an idea can create something incredible.
macOS is the primary operating system for the Macintosh computer. It was originally a system designed privately by Apple Inc, however with Mac OS X, it has been based on Unix. Specifically, a modified FreeBSD operating system called 'Darwin'.
There are many different kinds of software that can be developed for Mac OS X. People generally think of applications, but we'll briefly cover some of the other kinds.
Types of Software for Mac OS X[edit]
Applications[edit]
Applications are what people generally think of when they think about software for Mac OS X. Cocoa applications include: Finder, Mail, Address Book, Safari, Microsoft Word, and Microsoft Excel. Anybody can develop applications using Apple's free development tools which includes XCode. Mac OS X applications are developed using Objective-C though there are other possible programming languages that could be used.
The most popular languages for use on the macOS platform is Objective-C which could be thought of as Mac OS X's 'native language' since the Mac OS X libraries, or 'frameworks', all have an Objective-C interface. Objective-C includes everything that plain C can do, and adds object-oriented programming. See: Objective-C.
C++ can be used in developing for the Mac, but generally, it is used in addition to Objective-C rather than being in place of Objective-C. Using both Objective-C and C++ is called 'Objective-C++' and is considered to be optional when developing software for Mac OS X: C++
See Programming:Objective-C for a lesson on the basics of Objective-C [1] may also be of assistance.
Some preliminary thoughts:
Objective-C is the language most commonly used in Mac OS Programming. Objective-C entered Mac OS X and has ancestry in NeXT. Cocoa. Before you learn Mac programming you must know the basics of C since it is the basis for Objective-C.
There used to be three separate APIs for developing a Mac application with a GUI:
1. Classic (Mac OS 9 and lower). Developing for the Classic API is no longer done. When Mac OS X first came out, users and developers had a huge investment in software written for Mac Classic OS and Mac OS X used to have an emulation mode so that users could run their old software. Apple has long since stopped support of the Classic API and Classic emulation in Mac OS X.
2. Carbon (Mac OS 8.5 up to and including Mac OS X 10.6 Snow Leopard). Carbon was an API for developers to update their applications that used the Classic API to be run without the Classic emulator. Carbon was a great way that Apple provided developers to upgrade their software to run on Mac OS X without having to totally rewrite their software, but Carbon, like Classic, is no longer supported by Apple.
3. Cocoa (All versions of Mac OS X). Cocoa is the most native API that can be used to develop applications for Mac OS X that are truly 'Mac-like'. Generally, Objective-C will be used along with Cocoa, though there are other options such as Cocoa-AppleScript and Cocoa-Python, but Cocoa-Objective-C is really the 'mainstream' way to develop Cocoa applications.
Resource Forks Files in Mac OS X have a feature that is unique to Mac OS and that is that each file on disk can have two 'forks'. This feature used to be used for Classic and Carbon applications to separate code from resources (such as menus, windows, etc.), and the Mac OS X file system still supports two forks, but you should only use the 'data fork'. The resource fork is non-standard and can be lost when transferring Mac files to other file systems.
AppleScripts[edit]
Another 'native language' for developing Mac OS X applications is AppleScript. AppleScript is a language that Apple invented to automate repetitive tasks. The AppleScript application is located on your Mac at /Applications/Utilities/AppleScript Editor. AppleScript can be used to record AppleEvents, the events that applications send to themselves or to other applications. Why don't you try it out. Open AppleScript Editor, press the record button, do some things with your other applications and watch the script write itself. AppleScript can be used alone or it can be used along with XCode to develop Cocoa Applications using mostly AppleScript instead of Objective-C. This option is mostly for experienced AppleScript programmers who don't know Objective-C.
Automator Workflows[edit]
Apple also provides an application called 'Automator' that can be used to easily automate repetitive tasks. It is located at /Applications/Automator.app
Shell Scripts[edit]
Mac OS X has an application called Terminal that provides a command-line interface to Mac OS X. It is possible to develop scripts for the command line. Terminal.app is located at /Applications/Utilities/Terminal.app To create a shell script, you need a text editor. There is a text editor that comes with Mac OS X called 'TextEdit.app'. It is located in /Applications/TextEdit.app. But actually, what is better than TextEdit is a program such as TextWrangler.app which is available for free from the following link: http://www.barebones.com/products/textwrangler/
The shell that Terminal.app uses by default is called 'bash'. Here is a simple tutorial on developing bash scriptshttp://www.maclife.com/article/columns/terminal_101_automate_terminal_bash_scripts
We won't go any more deeply into shell scripts here in this wikibook, but it's just good to know what they are. You can always google for more information now that you know what to google for.
Command Line Tools[edit]
When you open Terminal and you learn how to type in commands. The commands are usually command-line tools or scripts. Above, we just talked about developing your own scripts with a text editor. It's also possible to develop your own command-line tools, using XCode. This is an advanced thing to do. Usually, power-users will write a shell-script (or some other kind of thing such as an AppleScript or an Automator Workflow) but it's good to know what a command-line tool is. Command-line tools have a textual user-interface rather than a graphical user interface (GUI).
Java[edit]
Java used to be treated by Apple as a 'first class language' to develop for Mac OS, however in recent years, Apple has less support for Java. Now with Mac OS X 10.7 'Lion' and 10.8 'Mountain Lion', Java doesn't even come pre-installed in Mac OS X. Java is still available, but users have to download Java from Oracle's website and install it themselves. Apple's Mac App Store doesn't even allow Java apps to be sold at their store calling Java 'deprecated'.
However, there still are Mac developers who use Java because it has the advantage of being cross-platform compatible. For example, the same source-code can be used to generate software that runs on Mac, Windows, and Linux.
Apple has said that Java reduces the Mac to the 'least common denominator'. That's why they support it less.
Python[edit]
Python is somewhat supported by Apple. In fact, Python is shipped with Mac OS X and is part of the System Folder. There are third-party libraries that allow developers to develop applications using Python and Cocoa together, but these are not very well maintained, and Python on the Mac is most suitable for developing command-line utilities, or cross-platform scripts that aren't really very Mac-like.
Ruby[edit]
Similar to Python.
Websites[edit]
Most Mac users use Safari for their web browser. Safari uses the standards set by w3c.org You can develop websites that work with Safari by following the standards of the w3c.org. Remember to validate your HMTL, CSS, and JavaScript.
HTML Validator:http://validator.w3.org/
CSS Validator:http://jigsaw.w3.org/css-validator/
JavaScript Lint:http://www.javascriptlint.com/online_lint.php
If you're developing websites using your Mac and using Safari, remember to test your webpages on other platforms and with other web browsers.
Mac OS X Specific Languages[edit]
Objective-C is really the 'native' language for Mac OS X development
You could call AppleScript a 'native' language too, but it isn't really used to make commercial applications. It was designed to be used by real power-users to automate their tasks. Although it is possible to use AppleScript to build Cocoa applications in XCode, this would be more for users who already know AppleScript and don't want to learn Objective-C.
Mac OS X Frameworks[edit]
Important:OpenGL was deprecated in macOS 10.14. To create high-performance code on GPUs, use the Metal framework instead. See Metal.
Important OpenGL was deprecated in macOS 10.14. To create high-performance code on GPUs, use the Metal framework instead. See Metal.
OpenGL is an open, cross-platform graphics standard with broad industry support. OpenGL greatly eases the task of writing real-time 2D or 3D graphics applications by providing a mature, well-documented graphics processing pipeline that supports the abstraction of current and future hardware accelerators.
At a Glance
OpenGL is an excellent choice for graphics development on the Macintosh platform because it offers the following advantages:
Reliable Implementation. The OpenGL client-server model abstracts hardware details and guarantees consistent presentation on any compliant hardware and software configuration. Every implementation of OpenGL adheres to the OpenGL specification and must pass a set of conformance tests.
Performance. Applications can harness the considerable power of the graphics hardware to improve rendering speeds and quality.
Industry acceptance. The specification for OpenGL is controlled by the Khronos Group, an industry consortium whose members include many of the major companies in the computer graphics industry, including Apple. In addition to OpenGL for OS X, there are OpenGL implementations for Windows, Linux, Irix, Solaris, and many game consoles.
OpenGL Is a C-based, Platform-Neutral API
Because OpenGL is a C-based API, it is extremely portable and widely supported. As a C API, it integrates seamlessly with Objective-C based Cocoa applications. OpenGL provides functions your application uses to generate 2D or 3D images. Your application presents the rendered images to the screen or copies them back to its own memory.
The OpenGL specification does not provide a windowing layer of its own. It relies on functions defined by OS X to integrate OpenGL drawing with the windowing system. Your application creates an OS X OpenGL rendering context and attaches a rendering target to it (known as a drawable object). The rendering context manages OpenGL state changes and objects created by calls to the OpenGL API. The drawable object is the final destination for OpenGL drawing commands and is typically associated with a Cocoa window or view.
Different Rendering Destinations Require Different Setup Commands
Depending on whether your application intends to draw OpenGL content to a window, to draw to the entire screen, or to perform offscreen image processing, it takes different steps to create the rendering context and associate it with a drawable object.
Relevant Chapters:Drawing to a Window or View, Drawing to the Full Screen and Drawing Offscreen
Cocoa Programming For Mac Os X 6th Edition
OpenGL on Macs Exists in a Heterogenous Environment
Macs support different types of graphics processors, each with different rendering capabilities, supporting versions of OpenGL from 1.x through OpenGL 3.2. When creating a rendering context, your application can accept a broad range of renderers or it can restrict itself to devices with specific capabilities. Once you have a context, you can configure how that context executes OpenGL commands.
OpenGL on the Mac is not only a heterogenous environment, but it is also a dynamic environment. Users can add or remove displays, or take a laptop running on battery power and plug it into a wall. When the graphics environment on the Mac changes, the renderer associated with the context may change. Your application must handle these changes and adjust how it uses OpenGL.
Relevant Chapters:Choosing Renderer and Buffer Attributes, Working with Rendering Contexts, and Determining the OpenGL Capabilities Supported by the Renderer
OpenGL Helps Applications Harness the Power of Graphics Processors
Graphics processors are massively parallelized devices optimized for graphics operations. To access that computing power adds additional overhead because data must move from your application to the GPU over slower internal buses. Accessing the same data simultaneously from both your application and OpenGL is usually restricted. To get great performance in your application, you must carefully design your application to feed data and commands to OpenGL so that the graphics hardware runs in parallel with your application. A poorly tuned application may stall either on the CPU or the GPU waiting for the other to finish processing.
When you are ready to optimize your application’s performance, Apple provides both general-purpose and OpenGL-specific profiling tools that make it easy to learn where your application spends its time.
Relevant Chapters:Optimizing OpenGL for High Resolution, OpenGL on the Mac Platform,OpenGL Application Design Strategies, Best Practices for Working with Vertex Data, Best Practices for Working with Texture Data, Customizing the OpenGL Pipeline with Shaders, and Tuning Your OpenGL Application
Concurrency in OpenGL Applications Requires Additional Effort
Many Macs ship with multiple processors or multiple cores, and future hardware is expected to add more of each. Designing applications to take advantage of multiprocessing is critical. OpenGL places additional restrictions on multithreaded applications. If you intend to add concurrency to an OpenGL application, you must ensure that the application does not access the same context from two different threads at the same time.
Performance Tuning Allows Your Application to Provide an Exceptional User Experience
Once you’ve improved the performance of your OpenGL application and taken advantage of concurrency, put some of the freed processing power to work for you. Higher resolution textures, detailed models, and more complex lighting and shading algorithms can improve image quality. Full-scene antialiasing on modern graphics hardware can eliminate many of the “jaggies” common on lower resolution images.
Relevant Chapters:Customizing the OpenGL Pipeline with Shaders,Techniques for Scene Antialiasing
How to Use This Document
If you have never programmed in OpenGL on the Mac, you should read this book in its entirety, starting with OpenGL on the Mac Platform. Critical Mac terminology is defined in that chapter as well as in the Glossary.
If you already have an OpenGL application running on the Mac, but have not yet updated it for OS X v10.7, read Choosing Renderer and Buffer Attributes to learn how to choose an OpenGL profile for your application.
To find out how to update an existing OpenGL app for high resolution, see Optimizing OpenGL for High Resolution.
Once you have OpenGL content in your application, read OpenGL Application Design Strategies to learn fundamental patterns for implementing high-performance OpenGL applications, and the chapters that follow to learn how to apply those patterns to specific OpenGL problems.
Important: Although this guide describes how to create rendering contexts that support OpenGL 3.2, most code examples and discussion in the rest of the book describe the earlier legacy versions of OpenGL. See Updating an Application to Support the OpenGL 3.2 Core Specification for more information on migrating your application to OpenGL 3.2.
Prerequisites
This guide assumes that you have some experience with OpenGL programming, but want to learn how to apply that knowledge to create software for the Mac. Although this guide provides advice on optimizing OpenGL code, it does not provide entry-level information on how to use the OpenGL API. If you are unfamiliar with OpenGL, you should read OpenGL on the Mac Platform to get an overview of OpenGL on the Mac platform, and then read the following OpenGL programming guide and reference documents:
OpenGL Programming Guide, by Dave Shreiner and the Khronos OpenGL Working Group; otherwise known as 'The Red book.”
OpenGL Shading Language, by Randi J. Rost, is an excellent guide for those who want to write programs that compute surface properties (also known as shaders).
OpenGL Reference Pages.
Before reading this document, you should be familiar with Cocoa windows and views as introduced in Window Programming Guide and View Programming Guide.
Cocoa Programming For Mac Os X 5th Edition Pdf Download
See Also
Keep these reference documents handy as you develop your OpenGL program for OS X:
NSOpenGLView Class Reference, NSOpenGLContext Class Reference, NSOpenGLPixelBuffer Class Reference, and NSOpenGLPixelFormat Class Reference provide a complete description of the classes and methods needed to integrate OpenGL content into a Cocoa application.
CGL Reference describes low-level functions that can be used to create full-screen OpenGL applications.
OpenGL Extensions Guide provides information about OpenGL extensions supported in OS X.
The OpenGL Foundation website, http://www.opengl.org, provides information on OpenGL commands, the Khronos OpenGL Working Group, logo requirements, OpenGL news, and many other topics. It's a site that you'll want to visit regularly. Among the many resources it provides, the following are important reference documents for OpenGL developers:
OpenGL Specification provides detailed information on how an OpenGL implementation is expected to handle each OpenGL command.
OpenGL Reference describes the main OpenGL library.
OpenGL GLU Reference describes the OpenGL Utility Library, which contains convenience functions implemented on top of the OpenGL API.
OpenGL GLUT Reference describes the OpenGL Utility Toolkit, a cross-platform windowing API.
OpenGL API Code and Tutorial Listings provides code examples for fundamental tasks, such as modeling and texture mapping, as well as for advanced techniques, such as high dynamic range rendering (HDRR).
Cocoa Programming For Mac Os X
Cocoa Programming For Mac Os X Pdf
Copyright © 2004, 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04