En la impresión de todos, Apple 开源
no tiene nada que ver con Apple. En comparación con las diversas personalizaciones y cambios mágicos de Android, Apple es extremadamente cerrado. Los desarrolladores deben desarrollarse bajo el marco de Apple y no pueden ir más allá de un paso.
El modelo de negocio cerrado no solo garantiza lo último, 用户体验
sino que también determina que el código abierto de Apple no pueda ser conocido y entendido por muchos desarrolladores como otras empresas.
De hecho, Apple solo cierra la capa de experiencia del usuario y el software comercial del sistema.La mayoría de las bibliotecas subyacentes del sistema son de código abierto, ya sea el kernel del sistema Darwin Xnu, GCD, Swift, OC runtime o WebKit, un componente web importante Para demostrar el espíritu de código abierto de Apple, Apple también está abrazando a la mayoría de los entusiastas del código abierto.
Este artículo presenta algunos de los componentes y sitios web oficiales de código abierto de Apple, incluidas las direcciones del código fuente, documentos y versiones, etc. No debe perdérselo como desarrollador de iOS/MacOS.
El primero son los tres principales sitios web de código abierto de Apple.
-
https://opensource.apple.com
Un sitio web oficial de código abierto especialmente diseñado por Apple, que enumera algunas bibliotecas de código abierto dirigidas y participadas por Apple
-
https://github.com/apple
Contiene
Swift
bibliotecas de componentes Swift como language y swift-package-manager swift-foundation swift-nio, que son de código abierto de Apple主战场
-
https://github.com/apple-oss-distributions
iOS/MacOS
系统组件库
, incluido el kernelxnu
, el enlazador dinámicodyld
,objc4
(tiempo de ejecución) GCD (libdispatch) y varias bibliotecas de componentes del sistema
Los componentes y bibliotecas de uso común se presentan a continuación.
Rápido
-
Sitio web oficial: www.swift.org
-
Código fuente: github.com/apple/swift
-
Curso de chino: www.cnswift.org
-
Última versión: 5.9
En la actualidad, el núcleo del código abierto de Apple, la productividad más avanzada y los lenguajes de desarrollo modernos permiten que todos desarrollen aplicaciones sobresalientes.
旨在为开发者提供充分的自由。Swift 易用并且开源,只要有想法,谁都可以创造非凡。
open and powerful
SPM
swift-package-manager
- 源码: github.com/apple/swift…
- 说明文档: www.swift.org/getting-sta…
- 最新版本: 0.6.0
帮助Swift开发人员管理项目,以便复用代码及简化管理流程。
和 Cocoapods、Carthage 作用类似
支持 iOS、macOS、watchOS 和 tvOS 系统
swift-nio
- 源码: github.com/apple/swift…
- 最新版本: 2.57.0
基于事件驱动的Swift for Server
开发框架,用于快速开发高性能且易于维护的Server程序
为了提升性能,SwfitNIO 使用非阻塞 IO,不论是发送数据还是接收数据,应用程序都无需等待,系统内核会在有可操作的 IO 时通知 SwfitNIO。
作用类似 Netty,但开发语言是 Swift。
支持的平台
Ubuntu 18.04+
macOS 10.14+
iOS 12+
swift-corelibs-foundation
Foundation 框架是苹果 macOS 和 iOS 的核心框架,几乎所有的 Swift/OC 项目都使用 Foundation 框架, 提供了各种最基础的工具类和应用API。
使用 Swift 重新实现了 Foundation 框架, 不再需要 C 和 Swift 桥接,从而提高性能。该项目旨在为Server Side
开发提供体量更小更方便的跨平台开发框架。
objc4(OC Runtime)
- 源码: github.com/apple-oss-d…
- 官方文档: developer.apple.com/documentati…
- 最新版本: objc4-876
Objective-C
runtime
库源码,它是 Objective-C 面向对象和动态机制的基石
xnu
- 源码: github.com/apple-oss-d…
- 最新版本: xnu-8796.101.5
xnu is not unix
xnu内核是Mac和iOS的核心,是结合了微内核与宏内核特性的混合内核,它包括三个部分:Mach、BSD 和 I/O Kit
。
GCD
- 源码: github.com/apple-oss-d…
- 最新版本: libdispatch-1415.100.11
Grand Central Dispatch
(GCD) 是 Apple 开发的多线程
编程技术。优化App以支持多核处理器。它在线程池模式的基础上执行的并发任务。支持 iOS 和 MacOS系统
优势:
- 优化多核的并行运算
- 自动利用更多的 CPU 内核(比如双核、四核)
- 自动管理线程的生命周期(创建线程、调度任务、销毁线程)
- 只需要告诉 GCD 想要执行什么任务,不需要编写任何线程管理代码
dyld
- 源码: github.com/apple-oss-d…
- 最新版本: dyld-1066.8
dyld 全称 the dynamic link editor
,即动态链接器,是专门用来加载动态库
的库。
苹果系统的重要组成部分,在App被编译打包成可执行文件格式的 Mach-O 文件之后 ,交由 dyld 负责链接和加载程序。
Core Foundation
- 源码: github.com/apple-oss-d…
- 最新版本: CF-1153.18
Core Foundation和Foundation 功能基本一致, 区别是Core Foundation是由C语言
实现的,而Foundation是 Objective-C 实现的, 为iOS和MacOS提供基本数据管理和服务功能。
distribution-macOS
- 源码: github.com/apple-oss-d…
- 最新版本: macOS 13.0
MacOS 系统的驱动框架、IOKit和各种底层库的集合
下面是苹果参与的开源项目
Webkit
- 源码: github.com/WebKit/WebK…
- 官网: webkit.org
- 最新版本: WebKit-7615.3.12.11.3
WebKit是跨平台的Web浏览器引擎
, 是 Apple Web的核心
Safari、Mail、App Store 以及 macOS/iOS/Linux很多 App 都是基于WebKit来构建 web 服务的。
llvm/Clang
- 源码: github.com/llvm/llvm-p…
- 官网: llvm.org
- 最新版本: LLVM 16.0.6
Apple一开始使用GCC
作为编译器,GCC对Objective-C的语言特性支持一直不够
所以苹果重新开发了LLVM这一整套编译前端
和后端
的项目,llvm是这个项目的代号,
它是高度优化的编译器、优化器和运行时环境。
Clang是LLVM的前端,用来编译C
、C++
和Objective-C
代码,
sqlite
- 源码: github.com/sqlite/sqli…
- 官网: sqlite.org
- 最新版本: version-3.42.0
SQLite
是开源跨平台轻量级数据库, 是移动端数据库的标准, 实现了无服务器的、零配置的、事务性的 SQL 数据库引擎
。
优势:
- 不需要一个单独的服务器进程或操作的系统(无服务器的)。
- 不需要安装或管理。
- 跨平台, 数据库文件所有平台通用, 包括Android、iOS、Linux/Unix、Mac OS和 Windows
- 库非常小, 轻量级
- 没有任何外部的依赖
- 事务是完全兼容 ACID 的,允许从多个进程或线程安全访问。
- 支持 SQL92(SQL2)标准的大多数查询语言的功能。
GNU step(开源Cocoa)
- Código fuente: github.com/gnustep/lib…
- Enlace de descarga: wwwmain.gnustep.org/resources/d…
- Introducción al sitio web oficial: gnustep.github.io/resources/d…
- Última versión: base-1_29_0
El paso GNU es uno de los proyectos del plan GNU, que reabre la biblioteca OC de Cocoa. Utilice GNUstep para comprender Cocoa
cómo se implementa el marco.
Aunque GNU step no es el código fuente oficial de Apple, ¡todavía tiene cierto valor de referencia!
Base GNUstep
- KVO: Fuente/NSKeyValueObserving.m
- KVC: Fuente/NSKeyValueCoding.m
- NSRunLoop: Fuente/NSRunLoop.m
- NSThread: Fuente/NSThread.m
- NSOperation : Fuente/NSOperation.m
Interfaz gráfica de usuario de GNUstep
- NSVer
- NSViewController