Comparison diagram of Mac OS and IOS system architectures:
As you can see from the diagram, Mac OS and iOS have a different system architecture hierarchy than the top tier, Mac is the Cocoa framework, and iOS is the cocoa Touch framework, so Mac OS development and iOS development are similar. Here I only analyze the system architecture of iOS:
One, Core OS layer:
The core OS, which was rewritten by FreeBSD and Mach, is an open source, POSIX-compliant UNIX core. This layer includes or provides some basic features of the entire iphone OS, such as: Hardware driver, memory management, program management, thread Management (POSIX), File system, network (BSD Socket), and standard input and output, all of which are provided through the C language API. Also, it is worth noting that this layer has the most Unix color, and if you need to port the programs developed on UNIX to the iphone, you will probably use the core OS API.
The driver of the core OS layer also provides the interface between the hardware and the system framework. However, due to security considerations, only limited system framework classes can access the kernel and drivers.
The iphone OS provides many interface sets to access the low-level features of the operating system, and the iphone app accesses these features through the Libsystem library, which are as follows:
Threads (POSIX threads);
Network (BSD sockets);
File system access;
Standard I/O;
Bonjour and DNS services;
Site information (locale information);
memory allocation;
Mathematical calculations.
The header files for many core OS technologies are located in directory <iphonesdk>/usr/include/,iphonesdk, which is the SDK installation directory.
Second, core service layers (Core services layer):
Core Services provides richer functionality on core OS, including Foundation.framework and core Foundation.framework, which is called Foundation, It is because it provides a series of basic functions to deal with strings, permutations, combinations, calendars, times, and so on. The foundation is the Api,core fundation belonging to Objective-c, which belongs to the C API. In addition, the core Servieces provides other features, such as:
Security, Core location, SQLite, and Address Book. Where security is used to handle authentication, password management, security management, Core location is used to handle GPS positioning, Sqllite is a lightweight database, and addressbook is used to process phone book data. Here is a detailed description:
(1) Telephone book
The telephone frame (addressbook.framework) provides a phone-based programming interface that is stored in a mobile device. Developers can use the framework to access and modify records stored in the user's contact database. For example, a chat program can use the framework to get a list of possible contacts, start a chat process, and display these contact information on the view.
(2) Core Infrastructure framework
The Core Infrastructure Framework (Corefoundation.framework) is a C-based interface set that provides basic data management and service capabilities for iphone applications. The framework supports the following features:
Collection data Types (Arrays, sets, etc.);
Bundles;
string management;
Date and time management;
Raw data block management;
Preference management;
URL and stream operation;
Thread and run loop (run Loops);
Port and socket communication.
The core infrastructure is closely related to the underlying framework, which provides the Objective-c interface for the same basic functionality. If developers mix the foundation Objects and Core Foundation types, they can take full advantage of the existence of the "toll-free bridging" in two frameworks. Toll-Free bridging means that developers can use either of the core foundations and underlying types of the two frameworks, such as collection and string types. The description of the class and data type in each frame indicates whether the object supports toll-free bridged. If so, which object it is bridged with (toll-free bridged).
(3) Cfnetwork
The Cfnetwork framework (cfnetwork.framework) is a set of high-performance C-language interfaces that provide object-oriented abstraction of network protocols. Developers can use the Cfnetwork framework to operate the protocol stack, and can access low-level structures such as BSD sockets. At the same time, developers can simplify the communication with FTP and HTTP servers, or resolve tasks such as DNS. The tasks implemented using the Cfnetwork framework are as follows:
BSD Sockets;
Use SSL or TLS to create an encrypted connection;
Parsing DNS Hosts;
Parsing HTTP protocol, authentication HTTP and HTTPS server;
Working on the FTP server;
Publish, parse, and browse Bonjour services.
(4) Central location Framework (core site framework)
The core location framework (Corelocation.framework) mainly obtains the current latitude and longitude of the mobile device, and the core position frame uses the nearby GPS, cellular base station or Wi-Fi signal information to measure the user's current position. The iphone Map app uses this feature to display the user's current location on the map. Developers can integrate this technology into their own applications, providing users with some location information services. For example, you can provide a service that looks for nearby restaurants, stores, or devices, based on the user's current location.
(5) Security framework
In addition to the built-in security features, the IPhone OS also provides an external security framework (Security.framework) to ensure the security of application data. The framework provides interfaces for managing certificates, public/private key pairs, and trust policies. It supports the generation of cryptographic security pseudo-random numbers, as well as the certificates and keys saved in the keychain. For user-sensitive data, it is a secure knowledge base (Secure Repository). The Commoncrypto interface also supports symmetric encryption, HMAC, and data summarization. There is no OpenSSL library in the iphone OS, but the functionality provided by the Data digest is essentially consistent with the functionality provided by the OpenSSL library.
(6) SQLite
The iphone app can embed a small SQL database SQLite without having to run another database server at the remote. Developers can create local database files and manage the tables and records in these files. Database SQLite is designed for general purpose, but can still be optimized for fast access to database records. The header file that accesses the database SQLite is located in <iphonesdk>/usr/include/sqlite3.h, where <iPhoneSDK> is the target path for the SDK installation.
(7) Support XML
The underlying framework provides the Nsxmlparser class for parsing XML document elements. The LibXML2 library provides the ability to manipulate XML content, an open source library that can quickly parse and edit XML data, and transform XML content into HTML. The header file that accesses the LibXML2 library is located in the directory <iphonesdk>/usr/include/libxml2/, where <iPhoneSDK> is the target directory for the SDK installation.
Third, media layer:
Like its name, the media layer provides multimedia features such as pictures, music, and movies. The image is divided into 2D images and 3D images, the former is supported by quartz2d, while the latter is opengles. The module that corresponds to music is core audio and OpenAL, Media player implements the playback of the movie, and finally provides the core Animation to support the powerful animations. The details are as follows:
(1) Image technology (graphics Technologies)
High-quality images are an important part of all iphone applications. At any time, developers can use the views and features already in the Uikit framework and pre-defined images to develop iphone apps. However, when the views and functions in the Uikit framework do not meet the requirements, developers can apply the techniques and methods described below to make the view.
①quartz. The core image frame (coregraphics.framework) contains the Quartz 2D drawing Api,quartz as advanced as the vector drawing engine used in Mac OS. Quartz supports path-based (path-based) drawing, anti-aliasing (anti-aliased) overloading, gradients (gradients), images (Images), Color (Colors), Coordinate space transformations (coordinate-space Transformations), PDF document creation, display, and parsing. Although the API is based on the C language, it uses object-based abstract representation of the underlying drawing objects, making the image content easy to save and reuse.
② Core animations (cores Animation). The Quartz core framework (quartzcore.framework) contains the Coreanimation interface, and core animation is an advanced animation and compositing technique that uses an optimized overloaded path (Rendering Path) for complex animations and virtual effects. It uses a high-level OBJECTIVE-C interface to configure animations and effects, and then overloads the hardware for better performance. Core animation integrates into many parts of the iphone OS, including Uikit classes such as UIView, which provides animations for many standard system behaviors. Developers can also use the Objective-c interface in this framework to create customized animations.
③opengl ES. The OpenGL ES Framework (Opengles.framework) complies with the OpenGL ES v1.1 specification, which provides a tool for painting 3D content. The OpenGL ES Framework is a C-based framework that is closely related to hardware devices and provides high frame rates for full-screen gaming applications (hi-frame rates). Developers always use the Eagl interface of the OpenGL framework, the EAGL interface is part of the OpenGL ES Framework, which provides the application's OpenGL ES drawing code and the interface of the local window object.
(2) Audio Technology (Technologies)
IPhone OS Audio technology provides a rich audio experience for users. It includes audio playback, high-quality recording and triggering of the device's vibration capabilities.
IPhone OS's audio technology supports the following audio formats: AAC, Apple Lossless (ALAC), A-law, IMA/ADPCM (IMA4), Linear PCM, Μ-law, Core audio, and more.
① Core Audio Family. The core audio family of frameworks provides local support for audio, as shown in table 16-1. Core Audio is a C language-based interface and supports stereo (Stereo Audio). Develop a core audio framework that uses iphone OS to generate, record, mix and play audio in iphone apps. Developers can also access the vibration capabilities of their mobile devices through core audio.
Core Audio frame:
FRAME (framework) |
Services (service) |
Coreaudio.framework |
Define audio data types for Core audio |
Audiounit.framework |
Provides audio and streaming files Playback and recording, and manage sound Frequency files and playback cue sounds |
Audiotoolbox.framework |
Provides the use of built-in audio unit services, Audio Processing Module |
②openal. The IPhone OS also supports the Open Audio Library (OpenAL). OpenAL is a cross-platform standard that delivers location audio (positional). Developers can apply openal to achieve high-performance, high-quality audio in games or other applications that require location audio output.
Since OpenAL is a cross-platform standard, code modules with OpenAL can be migrated smoothly to other platforms.
(3) video technology (video Technologies)
The IPhone OS supports full-screen video playback through the media playback framework (mediaplayer.framework). The video file formats supported by the media playback framework include. mov,. mp4,.m4v and. 3gp, and apply the following compression criteria:
①h.264 Baseline Profile Level 3.0 video with a resolution of 640x480 pixels in the case of the f/s. Note: b frames is not supported;
②MPEG4 the video part of the specification;
③ numerous audio formats included in the list of audio technologies, such as AAC, Apple Lossless (ALAC), A-law, IMA/ADPCM (IMA4), linear PCM, Μ-law, Core audio, and more.
Four, touch layer (Cocoa touch layers):
The top layer is the cocoa touch, which is the Objective-c API, the most central part of which is uikit.framework, the various components of the application interface, all provided by it to provide rendering, in addition to it is also responsible for processing on-screen multi-touch events, the output of the text , images, Web page display, camera or file access, and acceleration sensing parts. The details are as follows:
(1) uikit frame
The UIKit Framework (uikit.framework) contains a OBJECTIVE-C program interface that provides a key architecture for implementing graphics, event-driven iphone applications. Each application in the IPhone OS uses this framework to achieve the following core functions:
Application management;
Support graphics and Windows;
Support Touch event processing;
User interface management;
Provides objects used to characterize standard system views and controls;
Support text and Web content;
Integration with other applications via URL scheme.
To establish an application for basic code, Uikit also supports some special device-related features, as follows:
Accelerometer data;
Built-in camera;
User Picture Library;
Device name and mode information.
(2) Infrastructure Framework (Foundations framework)
The infrastructure Framework (FOUNDATION.FRAMEWORK) supports the following features:
Collection data types (including arrays, sets);
Bundles;
string management;
Date and time management;
Raw data block management;
Preference management;
Threads and loops;
URL and stream processing;
Bonjour;
Communication port management;
Internationalization.
(3) Phonebook UI Framework (Address Book UI Framework)
Telephone this UI framework (Addressbookui.framework) is a OBJECTIVE-C standard program interface that is used primarily to create new contacts, edit and select contacts that exist in the phone book. It simplifies the display of contact information in iphone apps and ensures that all applications use the same program interface to ensure consistency across different platforms.
Summarize:
When we want to develop the iphone program, we first need to start from the top, priority to use the Objective-c encapsulated library, that is, through Uikit.framework with Foundation.framework to develop, and when facing some more complex functions, such as multimedia processing or drawing, then go down to find the relevant framwork to complete.
IOS Operating System Architecture