ZipArchive 是一个简单的实用工具类,用于在 iOS、macOS、tvOS、watchOS 和 visionOS 上压缩和解压缩文件。
这个项目的一个关键依赖是 zlib 库。根据CVE-2018-25032,zlib 1.2.12 之前的版本在解压缩(即压缩)时,如果输入具有许多远距离匹配,则允许内存损坏。
zlib 1.2.12 包含在 macOS 10.15+(具有最新的安全补丁)、iOS 15.5+、tvOS 15.4+、watchOS 8.4+ 中。 因此,从 ZipArchive 的 2.5.0 版本开始,这些操作系统版本将成为新的最低要求。
如果您需要支持早期操作系统的 ZipArchive 的先前版本,您可以针对较早的版本,但请注意您将使用此库的未维护版本。
我们将不支持使用具有已知漏洞的依赖项的 ZipArchive 版本。
主发布分支配置为支持 Objective-C 和 Swift 4+。
SSZipArchive 可在以下环境中运行
在您的 Podfile 中
pod 'SSZipArchive'
您应该明确定义您的最低部署目标,例如:platform :ios, '15.5'
建议使用的 CocoaPods 版本应至少为 CocoaPods 1.7.5。
添加一个 Swift Package 引用到 https://github.com/ZipArchive/ZipArchive.git (SSZipArchive 2.5.0 及更高版本或 master)
在您的 Cartfile 中
github "ZipArchive/ZipArchive"
我们不发布 Carthage 预构建包。鼓励开发人员自己构建一个。
SSZipArchive
和 minizip
文件夹添加到您的项目中。libz
和 libiconv
库添加到您的 target 中。Security
framework 添加到您的 target 中。HAVE_ARC4RANDOM_BUF HAVE_ICONV HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB ZLIB_COMPAT $(inherited)
。SSZipArchive 需要 ARC。
//Import "#import <ZipArchive.h>" for SPM/Carthage, and "#import <SSZipArchive.h>" for CocoaPods.
// Create
[SSZipArchive createZipFileAtPath:zipPath withContentsOfDirectory:sampleDataPath];
// Unzip
[SSZipArchive unzipFileAtPath:zipPath toDestination:unzipPath];
//Import "import ZipArchive" for SPM/Carthage, and "import SSZipArchive" for CocoaPods.
// Create
SSZipArchive.createZipFileAtPath(zipPath, withContentsOfDirectory: sampleDataPath)
// Unzip
SSZipArchive.unzipFileAtPath(zipPath, toDestination: unzipPath)
SSZipArchive 在 MIT 许可证 下受到保护,我们略作修改的 minizip-ng (formally minizip) 3.0.10 版本在 Zlib 许可证 下获得许可。