Content of this section:
New developers of Macintosh
Experienced Macintosh developers, before Mac OS X
Non-Apple integrated development environment for Macintosh developers
Drivers and system software developers
If you first know Mac OS x and an application with a graphical user interface needs to be ported to Mac OS X, start from the following:
- "Porting an existing UNIX application"
- "Porting an existing windows application"
If you have a Java application and want to make sure it works best on Mac OS X, refer to "pure Java developer ".
If you start from scratch, refer to "no existing applications" first ".
No existing applications
The fastest way to write a new Mac OS X graphical user interface application from scratch is to use the cocoa application environment. The cocoa framework has completed a lot of work for you, providing many user interfaces and many underlying functions, such as communication between I/O and applications. If you have used cocoa to develop an application, the maintenance work is easy and the code is easy to reuse, this ensures that your program upgrade is faster than the original development. However, if you plan to port your program to another platform, you may want to use process-oriented calls in whole or in part instead of using the cocoa framework. In this case, you should use the carbon application environment.
The main tools used to develop cocoa and carbon are xcode applications and interface builder. For an introduction to these tools, see Chapter 3, "Apple integrated development environment ". There are many other useful tools for debugging and optimizing your applications, source code control, and other tasks. For more information, see Chapter 4 "development process ".
If you want to write a pure Java application, refer to "pure Java developer ".
For programs without graphical user interfaces, start with the following chapters:
- "Tool developers"
- "Plug-in developers"
- "Drivers and system software developers"
Port an existing UNIX Application
Due to its close relationship with BSD, the backend of the vast majority of UNIX applications (that is, no graphical user interface) it can run in Mac OS X without modification or modification. For a Unix tool or utility designed to run in the command line, you may not need more development work. However, such an application is only useful to other UNIX developers and a few high-end users. The vast majority of Mac OS X users prefer to deal with the finder and do not know how to use the terminal) application.
If you have used the X Window System (x11r6) interface to develop your application, you may only need to make a few changes to compile your application in Mac OS X. Apple provides an X Window System implementation (http://www.apple.com.cn/macosx/x11 ). This solution is sufficient for experienced Unix users who are used to the X Window System and have no other expectations for the application.
However, if you want your applications to be attractive to a large number of mainstream Mac OS x users, you must provide a standard Mac OS X user interface. A Mac OS X user should never use command lines to execute any task in an application with a graphical user interface. Furthermore, Mac OS X users expect their applications to follow the standards in the aqua Human-Machine Interface Guidelines in the user experience document. The outstanding applications of Apple and third-party developers give Mac OS X the world's best-to-use interface honors, and if an application does not follow these rules, it is considered unfriendly and difficult to use.
You can use the cocoa application environment and interface Builder application to quickly complete a standard Mac OS X graphical user interface as the front-end of your application (refer to "cocoa" for brief Introduction ). Interface builder and all other tools you need for cocoa development can be found in xcode and on the ADC website. To start now, see Chapter 3, "Apple integrated development environment ". For more information about porting UNIX applications to Mac OS X, see the "UNIX porting Guide" in the porting document ".
You can also use applescript studio to add an aqua graphical user interface to a Unix command line tool. For example, see developer/examples/applescript studio/archive maker/application. applescript. For more information about applescript studio, see solution provider ".
Port an existing windows application
Although Microsoft Windows and Mac OS X share many basic graphical user interface examples-such as application windows, dialog boxes, controls (buttons, progress bars, and others ), and menu bar-but there are great differences in details and implementation methods of the two user interfaces. Mac OS x users expect that their applications should be consistent and coherent as much as possible if an application does not follow the Mac OS X User Interface (Aqua) they will think that this application is of low quality and difficult to use. For more information about the differences between Microsoft Windows and Mac OS X user interfaces, see http://developer.apple.com/ue/switch/windows.html.
The easiest way to create a graphic user interface following the aqua standard is to use interface builder. For more information about interface builder, see Chapter 3 "Apple integrated development environment ".
If your Microsoft Windows application has certain characteristics, it should be very straightforward to convert it into a Mac OS X application. These features include:
- Use C, C ++, objective-C, or Objective C ++
- The graphic user interface code is completely separated from the backend
- The backend uses process-oriented code instead of Microsoft basic library or some other object-oriented frameworks.
In this case, you can replace Windows API call with carbon API call. In addition, if your graphic user interface code is separated from other codes, you can use cocoa to create a standard aqua graphic user interface for your application. You can use the xcode application to compile your process-oriented code and use interface builder to create your graphical user interface. For more information about xcode applications and interface builder, see Chapter 3 "Apple integrated development environment ". Many other tools are helpful for debugging and optimizing your applications and source code control. For more information, see Chapter 4 "development process ".
For advice and reference on converting a process-oriented windows application into a carbon application, see porting windows Win32 API to Mac OS X (http://developer.apple.com/macosx/win32porting ). For more information about the Mac OS X standard graphic user interface, see "Aqua Man-Machine Interface Guide" in the user experience document ".
ExperiencedMacintoshDevelopers,Mac OS XBefore
If you have a Mac OS 9 or earlier application written using the Mac OS process API, you can replace unsupported functions with carbon functions when necessary, and then use xcode to compile and link your applications. If your graphic user interface is well separated from other code, you can use interface builder to create your user interface.
All the tools you need for carbon development can be found in xcode and on the ADC website. For information on converting an application of Mac OS 8 or Mac OS 9 to Mac OS X, see the carbon porting Guide and other documents on the ADC website. For more information about xcode applications and interface builder, see Chapter 3 "Apple integrated development environment ".
Note that you cannot use xcode applications to compile applications running on Mac OS 9 or earlier systems. If you need to compile and debug code running in Mac OS 9, you can use MPW and macsbug, where you can find: http://developer.apple.com/macos/macos9.html.
Non-Apple integrated development environmentMacintoshDevelopers
If you are using code warrior or other non-Apple integrated development environments for Mac OS X development, you should consider converting to xcode. Xcode is the only development tool that keeps pace with Mac OS, cocoa, and carbon API changes. The xcode application user interface provides the vast majority of functions in code warrior, and some functions are not available in code warrior. The performance of xcode applications is comparable to that of code warrior.
To receive a prompt to convert the code warrior project to xcode, refer to the programming topic "migrate the codewarrior project to xcode ".
The term "Tools" is used to express many different things, but in this document, a tool is any program used by software developers to help complete their projects. A tool can be an application (that is, a program with a graphical user interface). In this case, the tool development is like any other application, or a command line tool. Apart from the graphical user interface, the command line tool is developed in a similar way as an application.
Plug-ins are code and data modules that developers and users can add to an application to expand its capabilities. Because the Mac OS X operating system can dynamically load code as needed, it is not necessary to link the plug-in code to the main application during development; only by putting the plug-ins in the correct directory can the application find the plug-ins and load them as needed.
If you want your application to use the plug-in, you must design an external API for use by plug-in writers. If you are using an object-oriented programming language, you can define a list of abstract basic classes or methods (called as a protocol in objective-C ). In a process-oriented language, for example, C, you can define a set of functions that must be completed by plug-in writers, plus a mechanism for registering callback functions for different types of messages. In the carbon application, you can use the core foundation cfplugin fuzzy type to define an object-oriented architecture so that it can work with C and C ++ plug-ins at the same time. For more information about designing plug-ins, see the "Dynamic Loading Code" programming topic in the "cocoa Resource Management documentation.
From the perspective of development tools, a Mac OS X plug-in is a package type that can be loaded. For more information about packages, see "System Overview" in Mac OS X ".
There are several standard Apple applications you can write plug-ins. For more information about writing plug-ins for Apple programs, see "Standard Apple plug-in project ".
Drivers and system software developers
Mac OS X provides a mechanism that allows you to dynamically load code to the kernel without re-compiling or re-linking. Any other method to modify the kernel requires you to create, distribute, and maintain your custom version of Mac OS X, if you want to load the code into the kernel, you need to use a Mac OS X Kernel extension (kext ).
In particular, it is very dangerous to add code to the kernel. Because there is no mechanism to protect the system from the impact of error code (Protection of memory, preemptible multitasking, virtual memory management), it can work on the Code executed in the kernel, you may cause kernel chaos (that is, the OS crash) due to incorrect kernel code, hardware error operations, data loss, and other application damage. The vast majority of features you need to implement, including many device drivers, can be executed at a higher level in the operating system, rather than in the kernel; please refer to "device driver & I/O toolkit document 《Access hardware from applications. For more information about kernel architecture and common kernel code features, especially kext, see "Darwin & core operating system documentation 《Kernel Programming.
If you want to write a device driver, you should use the I/O toolbox. The I/O toolkit is a collection of system frameworks, libraries, tools, and other resources used to create device drivers in Mac OS X. It is based on an object-oriented programming model and is a restriction mode implementation of c ++. For more information about the I/O toolkit, see "I/O toolkit basics" in "device drivers & I/O toolkit documentation ".
For more information about the kernel environment and the code written in the kernel, visit the "Darwin developer documentation" on the ADC website ".
You can use xcode to develop kext and I/O toolkit drivers. Although you can use xcode applications to write source code, not all tools used to debug and optimize applications are used in the Code executed in the kernel. For more information about xcode applications, see Chapter 3 "Apple integrated development environment ". For other tools for kernel-level code, see "kernel extension" and "I/O toolbox driver ".
Java only refers to programs written in an independent environment on the Java platform, including applications with graphical user interfaces and small programs that do not use user interfaces.
The vast majority of standard Java Development Toolkit (JDK) command line tools are included in Mac OS X as standard components. In addition, xcode provides many other Java-specific tools and common command line tools. Like other Mac OS X programming environments, you can use xcode applications to write your Java code (see "project builder for Java" in the Java documentation "). Jar bundler is a tool that uses compiled Java application packages as Mac OS X application programs.
If you want to develop a web server application, you can use webobjects to accelerate this process. Webobjects 5.2 contains a full set of tools and frameworks for rapid development of standard-based Web Services and Java server applications. In other tools, webobjects contains the eomodeler application, which can reverse engineer an existing database or be used to design a thumbnail of a new database-and create enterprise-level Web Services, HTML, and Java application assistants. You can use the xcode application to compile your web application and use interface builder to add an aqua interface. In addition to xcode applications and interface builder, webobjects tools and frameworks are independent products that you can purchase from Apple. For more information, see http://www.apple.com.cn/webobjectsand webobjects on the ADC website.
For more information about xcode applications and interface builder, see Chapter 3 "Apple integrated development environment ". For more information about other Java tools, see "Java ". To view the complete Mac OS X Java documentation, visit the Java documentation on the ADC website.
With applescript, Perl, and shell scripts, You can automate workflows that involve passing applications. Applescript provides the ability to directly control many Mac OS x applications and Mac OS components. To make an application controllable by scripts, the application writer must support the application applescript. The good news is that many developers have done this, and these applications include the vast majority of commonly used commercial software. For more information about applescript, could you tell me the applescript documentation on the http://www.apple.com/applescript and ADC website.
You can use the Script Editor (in the/application/applesctipt directory) to compile and Execute standard scripts with limited user interface capabilities. You can use applescript studio to create an applescript application with complex user interfaces that support the aqua Human-Machine Interface Guidelines. Applescript studio is a combination of technologies, including applescript, cocoa, xcode applications, and interface builder. To learn more about applesctipt studio, visit the http://www.apple.com/applescript/studio. The applesctipt studio document is in the applescript document on the ADC website.
Perl is a standard scripting language on multiple platforms. It is an open source code project and is free of charge. It can be used to execute a program or get the output of a program, process the data, and then use the processed data as the input of another program. Perl can be used for inter-process communication, reading information on the Internet, and writing CGI scripts. Perl programs can execute modules written in C and other languages and treat them as Perl subfunctions. Perl is included in the released version of Mac OS X.
In addition to applescript and Perl, you can write shell scripts to run in terminal applications. A shell script is a sequence of shell commands that are read from a file rather than manually input. In this way, you can write scripts to complete everything you can do on the terminal. That is to say, almost all things that Mac OS X can do, including some features not available in the finder. You can execute the shell script in applescript or in the shell script. You can execute applescript scripts and command line tools in a carbon or cocoa application.
You can create an xcode project to compile an applescript Studio Application. For more information about xcode applications, see Chapter 3 "Apple integrated development environment ". There are also some tools for Perl, applescript, and terminal script. For more information about other tools used for scripts, see "scripts ".
QuickTime is a technology used to operate and store many different media resources including videos, sounds, animations, images, text, music, and even operations, storage, and display of 360-degree VR. It also allows you to stream media to play digital videos or stored data streams from time to time. QuickTime supports Mac OS X and Microsoft Windows.
It is relatively easy to add QuickTime support to an application using cocoa, carbon, and standard application development tools (mainly xcode applications. For more information, see the quick time data http://developer.apple.com/quicktime/index.html on the Apple developers Alliance website. You can also compile the QuickTime component to expand the capabilities of QuickTime. Because the QuickTime API is process-oriented, you should use carbon to compile the QuickTime component. For more information about component APIs, see the quick time document topic on the ADC website.
If you are interested in making content for QuickTime, Apple and third-party tools will help you. Because these tools operate on data, rather than source code, they are beyond the scope of this document. For more information, see the QuickTime Tool Web page http://developer.apple.com/quicktime/quicktimeintro/tools/index.html.