OS X以defaults機制管理每一個程序的設置,具體就是每一個程序就是每一個程序都會擁有一個名稱空間(程序的域)存儲本身的配置文件;java
程序以plist文件格式保存各自的配置,能夠經過系統的defaults
命令來設置默認配置;c++
defaults
命令僅僅修改各個域的配置文件,可是對於每一個程序如何響應倒是不必定的;數據庫
OS X 中加載默認程序的功能是由launchService框架實現的,它是core service框架的一部分;在OS X中能夠經過open -with
命令打開某個application;launchService的基礎是創建在一個數據庫上,這個數據索引了每一個文件格式所對應的程序;在launchService中蘋果提供了一個二進制程序lsregister
來管理管理這個數據庫,好比顯示數據庫中的所有條目;編程
➜ cd /System/Library/Frameworks/CoreServices.framework ➜ cd Frameworks/LaunchServices.framework/Support
lsregister: [OPTIONS] [ <path>... ] [ -apps <domain>[,domain]... ] [ -libs <domain>[,domain]... ] [ -all <domain>[,domain]... ] Paths are searched for applications to register with the Launch Service database. Valid domains are "system", "local", "network" and "user". Domains can also be specified using only the first letter. -kill Reset the Launch Services database before doing anything else -seed If database isn't seeded, scan default locations for applications and libraries to register -lint Print information about plist errors while registering bundles -lazy n Sleep for n seconds before registering/scanning -r Recursive directory scan, do not recurse into packages or invisible directories -R Recursive directory scan, descending into packages and invisible directories -f force-update registration even if mod date is unchanged -u unregister instead of register -v Display progress information -dump Display full database contents after registration -h Display this help
Framework也是bundle的一種,它不是drawin內核架構中的內容,經過各類framework,OS X實現各類界面效果和功能,這是蘋果自有的技術,除此以外OS X中的framework還提供了「傳統」的系統級API,好比運行時系統等;安全
Framework與Application等bundle不一樣,它具備內建版本,簡單的說就是其中bundle存儲了多個版本的編譯文件,經過current連接符號指向不一樣的版本。網絡
OS X和iOS的gcc中有一個-framework
也能夠指定framework進行編譯;在編譯OS X軟件也可經過配置環境變量添加framework的尋找路徑;架構
在OS X中有兩個頂層框架
* carbon 當前已經廢棄,兼容多種架構的框架;但部分私有API在內部使用
* cocoa 是NeXTSTEP/NS 的遺產,其支持object-c、java、AppleScript訪問;app
庫
即dylib動態加載庫,由OS X中的mach-o加載器dyld
加載;框架
BSD/Mach原生程序dom
OS X的原生編程語言是oc,可是也支持c/c++,經過直接調用底層的bsd/mach接口,使得OS X程序也能夠移植到其餘類unix系統中;處理系統的API以外,mach trap API依然是OS X獨有的;
OS X符合POSIX標準,POSIX標準主要有兩項內容:
* 系統調用原型,支持源代碼層的移植;
* 系統調用編號,支持二進制文件層次的移植;
OS X僅僅支持源代碼層次的移植;
Mach
進程和線程抽象,虛擬內存管理、任務調度、進程通訊、消息傳遞
I/O Kit