├── .github └── workflows │ └── build.yml ├── .gitignore ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── CHANGELOG.md ├── GZIP.podspec ├── GZIP.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ └── GZIP.xcscheme ├── GZIP ├── GZIP.h ├── Info.plist └── Sources │ ├── NSData+GZIP.h │ └── NSData+GZIP.m ├── GZIPTests ├── GZIPTests.m ├── Info.plist ├── NSData+SEGGZIP.h ├── NSData+SEGGZIP.m └── UnitTests.m ├── LICENSE.md ├── Package.swift └── README.md /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | jobs: 7 | macos: 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | macos: 12 | - 13 13 | xcode: 14 | - latest-stable 15 | runs-on: macos-${{ matrix.macos }} 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | - name: Build and Test 20 | run: | 21 | xcodebuild -scheme "GZIP" -sdk macosx clean build test -enableCodeCoverage YES -derivedDataPath Build/ 22 | cd Build/Build/ProfileData 23 | cd $(ls -d */|head -n 1) 24 | directory=${PWD##*/} 25 | pathCoverage=Build/Build/ProfileData/${directory}/Coverage.profdata 26 | cd ../../../../ 27 | xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage Build/Build/Products/Debug/GZIP.framework/GZIP > info.lcov 28 | - name: Codecov 29 | uses: codecov/codecov-action@v2 30 | with: 31 | # the token is optional for a public repo, but including it anyway 32 | token: 1132f70a-3f8e-4448-bc3e-e564311f2ced 33 | env_vars: MD_APPLE_SDK_ROOT,RUNNER_OS,RUNNER_ARCH 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | Assets/ 6 | build/ 7 | html/ 8 | .build 9 | *.pbxuser 10 | !default.pbxuser 11 | *.mode1v3 12 | !default.mode1v3 13 | *.mode2v3 14 | !default.mode2v3 15 | *.perspectivev3 16 | !default.perspectivev3 17 | xcuserdata 18 | *.xccheckout 19 | *.moved-aside 20 | DerivedData 21 | *.hmap 22 | *.ipa 23 | *.dot 24 | .docc-build/ 25 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [1.3.2](https://github.com/nicklockwood/GZIP/releases/tag/1.3.2) (2024-03-25) 4 | 5 | - Minimum deployment target for macOS is now 10.13 6 | - Minimum deployment target for tvOS is now 11.0 7 | - Updated podspec to reflect MIT license 8 | 9 | ## [1.3.1](https://github.com/nicklockwood/GZIP/releases/tag/1.3.1) (2023-09-19) 10 | 11 | - Minimum deployment target for iOS is now 11.0. 12 | 13 | ## [1.3.0](https://github.com/nicklockwood/GZIP/releases/tag/1.3.0) (2020-04-26) 14 | 15 | - Added support for Swift Package Manager 16 | - Fixed watchOS and tvOS targets 17 | - Combined platform-specific targets into one 18 | 19 | ## [1.2.3](https://github.com/nicklockwood/GZIP/releases/tag/1.2.3) (2018-11-19) 20 | 21 | - Fixed Xcode 10.1 warnings 22 | - Added compatibility regression tests 23 | - Switched to more-conventional MIT license 24 | 25 | ## [1.2.2](https://github.com/nicklockwood/GZIP/releases/tag/1.2.2) (2018-09-18) 26 | 27 | - Fixed Xcode 10 warnings 28 | 29 | ## [1.2.1](https://github.com/nicklockwood/GZIP/releases/tag/1.2.1) (2017-07-03) 30 | 31 | - Fixed incorrect case in header import 32 | 33 | ## [1.2](https://github.com/nicklockwood/GZIP/releases/tag/1.2) (2017-05-18) 34 | 35 | - Removed dlopen, as Apple have begun rejecting apps that use it. 36 | - Minimum deployment target is now iOS 8.0. 37 | - Added watchOS / tvOS support. 38 | - Added Carthage support. 39 | 40 | ## [1.1.1](https://github.com/nicklockwood/GZIP/releases/tag/1.1.1) (2015-07-24) 41 | 42 | - Fixed crash on iOS 9. 43 | - Added performance tests. 44 | 45 | ## [1.1](https://github.com/nicklockwood/GZIP/releases/tag/1.1) (2015-07-17) 46 | 47 | - Added `isGzippedData` method. 48 | - GZIP will no longer re-encode already-gzipped data, nor try (and fail) to decode ungzipped data. 49 | - GZIP now uses dlopen to load the libz.dylib at runtime, so there's no need to include it manually in your project. 50 | - Fixed warnings and errors on Xcode 7 51 | 52 | ## [1.0.3](https://github.com/nicklockwood/GZIP/releases/tag/1.0.3) (2014-07-02) 53 | 54 | - Fixed new warnings in Xcode 6 55 | - Added Travis CI support 56 | 57 | ## [1.0.2](https://github.com/nicklockwood/GZIP/releases/tag/1.0.2) (2013-12-24) 58 | 59 | - Now complies with -Weverything warning level 60 | 61 | ## [1.0.1](https://github.com/nicklockwood/GZIP/releases/tag/1.0.1) (2013-09-25) 62 | 63 | - Added podspec 64 | - Renamed source files 65 | - Verified compliance with iOS 7 / Mac OS 10.8 66 | - Verified compliance with -Wextra warning level 67 | 68 | 69 | ## [1.0](https://github.com/nicklockwood/GZIP/releases/tag/1.0) (2012-04-06) 70 | 71 | - First release 72 | -------------------------------------------------------------------------------- /GZIP.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'GZIP' 3 | s.version = '1.3.2' 4 | s.license = 'MIT' 5 | s.summary = 'GZIP is category on NSData that provides simple gzip compression and decompression functionality.' 6 | s.homepage = 'https://github.com/nicklockwood/GZIP' 7 | s.author = { "Nick Lockwood" => "support@charcoaldesign.co.uk" } 8 | s.source = { :git => "https://github.com/nicklockwood/GZIP.git", :tag => "1.3.2" } 9 | s.source_files = 'GZIP/**/*.{h,m}' 10 | s.library = 'z' 11 | s.requires_arc = false 12 | s.ios.deployment_target = '11.0' 13 | s.osx.deployment_target = '10.13' 14 | s.tvos.deployment_target = '11.0' 15 | end 16 | -------------------------------------------------------------------------------- /GZIP.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0128EEC32ABCBB3300E60976 /* GZIPTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0128EEC22ABCBB3300E60976 /* GZIPTests.m */; }; 11 | 0128EEC42ABCBB3300E60976 /* GZIP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AE36CDB1B8F5AEF00923C2D /* GZIP.framework */; }; 12 | 0128EECA2ABCBB4500E60976 /* NSData+SEGGZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = C1BE0916228B5F77006800A0 /* NSData+SEGGZIP.m */; }; 13 | 0128EECB2ABCBB4A00E60976 /* UnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A733BD71BA9B6F800089A82 /* UnitTests.m */; }; 14 | 01A377FD24560A040040E02B /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 01A377FC24560A040040E02B /* libz.tbd */; }; 15 | 3AE36CD21B8F5AEF00923C2D /* NSData+GZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE36CCB1B8F59E600923C2D /* NSData+GZIP.m */; }; 16 | 3AE36CD51B8F5AEF00923C2D /* GZIP.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AE36CC21B8F598E00923C2D /* GZIP.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17 | 3AE36CD61B8F5AEF00923C2D /* NSData+GZIP.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AE36CCA1B8F59E600923C2D /* NSData+GZIP.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 0128EEC52ABCBB3300E60976 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 3AE36CB61B8F598E00923C2D /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 3AE36CD01B8F5AEF00923C2D; 26 | remoteInfo = GZIP; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 0128EEC02ABCBB3300E60976 /* GZIPTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GZIPTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 0128EEC22ABCBB3300E60976 /* GZIPTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GZIPTests.m; sourceTree = ""; }; 33 | 01A377FC24560A040040E02B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; 34 | 3A733BD01BA9B6BD00089A82 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 3A733BD71BA9B6F800089A82 /* UnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UnitTests.m; sourceTree = ""; }; 36 | 3AE36CC21B8F598E00923C2D /* GZIP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GZIP.h; sourceTree = ""; }; 37 | 3AE36CC41B8F598E00923C2D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 3AE36CCA1B8F59E600923C2D /* NSData+GZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+GZIP.h"; path = "Sources/NSData+GZIP.h"; sourceTree = ""; }; 39 | 3AE36CCB1B8F59E600923C2D /* NSData+GZIP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+GZIP.m"; path = "Sources/NSData+GZIP.m"; sourceTree = ""; }; 40 | 3AE36CDB1B8F5AEF00923C2D /* GZIP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GZIP.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | C1BE0915228B5F77006800A0 /* NSData+SEGGZIP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+SEGGZIP.h"; sourceTree = ""; }; 42 | C1BE0916228B5F77006800A0 /* NSData+SEGGZIP.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+SEGGZIP.m"; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 0128EEBD2ABCBB3300E60976 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 0128EEC42ABCBB3300E60976 /* GZIP.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | 3AE36CD31B8F5AEF00923C2D /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 01A377FD24560A040040E02B /* libz.tbd in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 0128EEC12ABCBB3300E60976 /* GZIPTests */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 0128EEC22ABCBB3300E60976 /* GZIPTests.m */, 69 | ); 70 | path = GZIPTests; 71 | sourceTree = ""; 72 | }; 73 | 01C8A6C71ECD8CCE0031CB2F /* Frameworks */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 01A377FC24560A040040E02B /* libz.tbd */, 77 | ); 78 | name = Frameworks; 79 | sourceTree = ""; 80 | }; 81 | 3A733BCD1BA9B6BD00089A82 /* GZIPTests */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 3A733BD71BA9B6F800089A82 /* UnitTests.m */, 85 | 3A733BD01BA9B6BD00089A82 /* Info.plist */, 86 | C1BE0915228B5F77006800A0 /* NSData+SEGGZIP.h */, 87 | C1BE0916228B5F77006800A0 /* NSData+SEGGZIP.m */, 88 | ); 89 | path = GZIPTests; 90 | sourceTree = ""; 91 | }; 92 | 3AE36CB51B8F598E00923C2D = { 93 | isa = PBXGroup; 94 | children = ( 95 | 3AE36CC11B8F598E00923C2D /* GZIP */, 96 | 3A733BCD1BA9B6BD00089A82 /* GZIPTests */, 97 | 0128EEC12ABCBB3300E60976 /* GZIPTests */, 98 | 3AE36CC01B8F598E00923C2D /* Products */, 99 | 01C8A6C71ECD8CCE0031CB2F /* Frameworks */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | 3AE36CC01B8F598E00923C2D /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 3AE36CDB1B8F5AEF00923C2D /* GZIP.framework */, 107 | 0128EEC02ABCBB3300E60976 /* GZIPTests.xctest */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 3AE36CC11B8F598E00923C2D /* GZIP */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 3AE36CC21B8F598E00923C2D /* GZIP.h */, 116 | 3AE36CC41B8F598E00923C2D /* Info.plist */, 117 | 3AE36CCA1B8F59E600923C2D /* NSData+GZIP.h */, 118 | 3AE36CCB1B8F59E600923C2D /* NSData+GZIP.m */, 119 | ); 120 | path = GZIP; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXHeadersBuildPhase section */ 126 | 3AE36CD41B8F5AEF00923C2D /* Headers */ = { 127 | isa = PBXHeadersBuildPhase; 128 | buildActionMask = 2147483647; 129 | files = ( 130 | 3AE36CD51B8F5AEF00923C2D /* GZIP.h in Headers */, 131 | 3AE36CD61B8F5AEF00923C2D /* NSData+GZIP.h in Headers */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXHeadersBuildPhase section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 0128EEBF2ABCBB3300E60976 /* GZIPTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 0128EEC72ABCBB3300E60976 /* Build configuration list for PBXNativeTarget "GZIPTests" */; 141 | buildPhases = ( 142 | 0128EEBC2ABCBB3300E60976 /* Sources */, 143 | 0128EEBD2ABCBB3300E60976 /* Frameworks */, 144 | 0128EEBE2ABCBB3300E60976 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | 0128EEC62ABCBB3300E60976 /* PBXTargetDependency */, 150 | ); 151 | name = GZIPTests; 152 | productName = GZIPTests; 153 | productReference = 0128EEC02ABCBB3300E60976 /* GZIPTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | 3AE36CD01B8F5AEF00923C2D /* GZIP */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 3AE36CD81B8F5AEF00923C2D /* Build configuration list for PBXNativeTarget "GZIP" */; 159 | buildPhases = ( 160 | 3AE36CD11B8F5AEF00923C2D /* Sources */, 161 | 3AE36CD31B8F5AEF00923C2D /* Frameworks */, 162 | 3AE36CD41B8F5AEF00923C2D /* Headers */, 163 | 3AE36CD71B8F5AEF00923C2D /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = GZIP; 170 | productName = GZIP; 171 | productReference = 3AE36CDB1B8F5AEF00923C2D /* GZIP.framework */; 172 | productType = "com.apple.product-type.framework"; 173 | }; 174 | /* End PBXNativeTarget section */ 175 | 176 | /* Begin PBXProject section */ 177 | 3AE36CB61B8F598E00923C2D /* Project object */ = { 178 | isa = PBXProject; 179 | attributes = { 180 | BuildIndependentTargetsInParallel = YES; 181 | LastUpgradeCheck = 1500; 182 | TargetAttributes = { 183 | 0128EEBF2ABCBB3300E60976 = { 184 | CreatedOnToolsVersion = 15.0; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = 3AE36CB91B8F598E00923C2D /* Build configuration list for PBXProject "GZIP" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = en; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = 3AE36CB51B8F598E00923C2D; 197 | productRefGroup = 3AE36CC01B8F598E00923C2D /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 3AE36CD01B8F5AEF00923C2D /* GZIP */, 202 | 0128EEBF2ABCBB3300E60976 /* GZIPTests */, 203 | ); 204 | }; 205 | /* End PBXProject section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | 0128EEBE2ABCBB3300E60976 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | }; 215 | 3AE36CD71B8F5AEF00923C2D /* Resources */ = { 216 | isa = PBXResourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | /* End PBXResourcesBuildPhase section */ 223 | 224 | /* Begin PBXSourcesBuildPhase section */ 225 | 0128EEBC2ABCBB3300E60976 /* Sources */ = { 226 | isa = PBXSourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | 0128EECA2ABCBB4500E60976 /* NSData+SEGGZIP.m in Sources */, 230 | 0128EEC32ABCBB3300E60976 /* GZIPTests.m in Sources */, 231 | 0128EECB2ABCBB4A00E60976 /* UnitTests.m in Sources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | 3AE36CD11B8F5AEF00923C2D /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | 3AE36CD21B8F5AEF00923C2D /* NSData+GZIP.m in Sources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | /* End PBXSourcesBuildPhase section */ 244 | 245 | /* Begin PBXTargetDependency section */ 246 | 0128EEC62ABCBB3300E60976 /* PBXTargetDependency */ = { 247 | isa = PBXTargetDependency; 248 | target = 3AE36CD01B8F5AEF00923C2D /* GZIP */; 249 | targetProxy = 0128EEC52ABCBB3300E60976 /* PBXContainerItemProxy */; 250 | }; 251 | /* End PBXTargetDependency section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | 0128EEC82ABCBB3300E60976 /* Debug */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 259 | CLANG_ANALYZER_NONNULL = YES; 260 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 261 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 262 | CLANG_ENABLE_OBJC_WEAK = YES; 263 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 264 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 265 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-"; 266 | CURRENT_PROJECT_VERSION = 1; 267 | GCC_C_LANGUAGE_STANDARD = gnu17; 268 | GENERATE_INFOPLIST_FILE = YES; 269 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 270 | MACOSX_DEPLOYMENT_TARGET = 13.5; 271 | MARKETING_VERSION = 1.0; 272 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 273 | MTL_FAST_MATH = YES; 274 | PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.GZIPTests; 275 | PRODUCT_NAME = "$(TARGET_NAME)"; 276 | SDKROOT = macosx; 277 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 278 | SUPPORTS_MACCATALYST = NO; 279 | SWIFT_EMIT_LOC_STRINGS = NO; 280 | TARGETED_DEVICE_FAMILY = "1,2"; 281 | }; 282 | name = Debug; 283 | }; 284 | 0128EEC92ABCBB3300E60976 /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 289 | CLANG_ANALYZER_NONNULL = YES; 290 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 291 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 292 | CLANG_ENABLE_OBJC_WEAK = YES; 293 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 294 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 295 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-"; 296 | CURRENT_PROJECT_VERSION = 1; 297 | GCC_C_LANGUAGE_STANDARD = gnu17; 298 | GENERATE_INFOPLIST_FILE = YES; 299 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 300 | MACOSX_DEPLOYMENT_TARGET = 13.5; 301 | MARKETING_VERSION = 1.0; 302 | MTL_FAST_MATH = YES; 303 | PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.GZIPTests; 304 | PRODUCT_NAME = "$(TARGET_NAME)"; 305 | SDKROOT = macosx; 306 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 307 | SUPPORTS_MACCATALYST = NO; 308 | SWIFT_EMIT_LOC_STRINGS = NO; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | }; 311 | name = Release; 312 | }; 313 | 3AE36CC51B8F598E00923C2D /* Debug */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 322 | CLANG_WARN_BOOL_CONVERSION = YES; 323 | CLANG_WARN_COMMA = YES; 324 | CLANG_WARN_CONSTANT_CONVERSION = YES; 325 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 326 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 327 | CLANG_WARN_EMPTY_BODY = YES; 328 | CLANG_WARN_ENUM_CONVERSION = YES; 329 | CLANG_WARN_INFINITE_RECURSION = YES; 330 | CLANG_WARN_INT_CONVERSION = YES; 331 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 332 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 333 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 336 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 337 | CLANG_WARN_STRICT_PROTOTYPES = YES; 338 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | COPY_PHASE_STRIP = NO; 343 | CURRENT_PROJECT_VERSION = 1; 344 | DEBUG_INFORMATION_FORMAT = dwarf; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | ENABLE_TESTABILITY = YES; 347 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 348 | GCC_C_LANGUAGE_STANDARD = gnu99; 349 | GCC_DYNAMIC_NO_PIC = NO; 350 | GCC_NO_COMMON_BLOCKS = YES; 351 | GCC_OPTIMIZATION_LEVEL = 0; 352 | GCC_PREPROCESSOR_DEFINITIONS = ( 353 | "DEBUG=1", 354 | "$(inherited)", 355 | ); 356 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 357 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 358 | GCC_WARN_UNDECLARED_SELECTOR = YES; 359 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 360 | GCC_WARN_UNUSED_FUNCTION = YES; 361 | GCC_WARN_UNUSED_VARIABLE = YES; 362 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 363 | MTL_ENABLE_DEBUG_INFO = YES; 364 | ONLY_ACTIVE_ARCH = YES; 365 | SDKROOT = iphoneos; 366 | SUPPORTED_PLATFORMS = "watchsimulator watchos appletvsimulator appletvos iphonesimulator iphoneos macosx"; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | VERSIONING_SYSTEM = "apple-generic"; 369 | VERSION_INFO_PREFIX = ""; 370 | }; 371 | name = Debug; 372 | }; 373 | 3AE36CC61B8F598E00923C2D /* Release */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_COMMA = YES; 384 | CLANG_WARN_CONSTANT_CONVERSION = YES; 385 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 386 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INFINITE_RECURSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 393 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 395 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 396 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 397 | CLANG_WARN_STRICT_PROTOTYPES = YES; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | CURRENT_PROJECT_VERSION = 1; 404 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 405 | ENABLE_NS_ASSERTIONS = NO; 406 | ENABLE_STRICT_OBJC_MSGSEND = YES; 407 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 408 | GCC_C_LANGUAGE_STANDARD = gnu99; 409 | GCC_NO_COMMON_BLOCKS = YES; 410 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 411 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 412 | GCC_WARN_UNDECLARED_SELECTOR = YES; 413 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 414 | GCC_WARN_UNUSED_FUNCTION = YES; 415 | GCC_WARN_UNUSED_VARIABLE = YES; 416 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 417 | MTL_ENABLE_DEBUG_INFO = NO; 418 | SDKROOT = iphoneos; 419 | SUPPORTED_PLATFORMS = "watchsimulator watchos appletvsimulator appletvos iphonesimulator iphoneos macosx"; 420 | TARGETED_DEVICE_FAMILY = "1,2"; 421 | VALIDATE_PRODUCT = YES; 422 | VERSIONING_SYSTEM = "apple-generic"; 423 | VERSION_INFO_PREFIX = ""; 424 | }; 425 | name = Release; 426 | }; 427 | 3AE36CD91B8F5AEF00923C2D /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | APPLICATION_EXTENSION_API_ONLY = YES; 431 | CODE_SIGN_IDENTITY = "Apple Development"; 432 | CODE_SIGN_STYLE = Automatic; 433 | DEAD_CODE_STRIPPING = YES; 434 | DEFINES_MODULE = YES; 435 | DYLIB_COMPATIBILITY_VERSION = 1; 436 | DYLIB_CURRENT_VERSION = 1; 437 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 438 | ENABLE_MODULE_VERIFIER = YES; 439 | INFOPLIST_FILE = GZIP/Info.plist; 440 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 441 | LD_RUNPATH_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "@executable_path/Frameworks", 444 | "@loader_path/Frameworks", 445 | ); 446 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 447 | MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; 448 | MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; 449 | PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.GZIP; 450 | PRODUCT_NAME = GZIP; 451 | PROVISIONING_PROFILE_SPECIFIER = ""; 452 | SDKROOT = macosx; 453 | SKIP_INSTALL = YES; 454 | TARGETED_DEVICE_FAMILY = "1,2,3,4"; 455 | }; 456 | name = Debug; 457 | }; 458 | 3AE36CDA1B8F5AEF00923C2D /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | buildSettings = { 461 | APPLICATION_EXTENSION_API_ONLY = YES; 462 | CODE_SIGN_IDENTITY = "Apple Development"; 463 | CODE_SIGN_STYLE = Automatic; 464 | DEAD_CODE_STRIPPING = YES; 465 | DEFINES_MODULE = YES; 466 | DYLIB_COMPATIBILITY_VERSION = 1; 467 | DYLIB_CURRENT_VERSION = 1; 468 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 469 | ENABLE_MODULE_VERIFIER = YES; 470 | INFOPLIST_FILE = GZIP/Info.plist; 471 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 472 | LD_RUNPATH_SEARCH_PATHS = ( 473 | "$(inherited)", 474 | "@executable_path/Frameworks", 475 | "@loader_path/Frameworks", 476 | ); 477 | MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; 478 | MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; 479 | MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; 480 | PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.GZIP; 481 | PRODUCT_NAME = GZIP; 482 | PROVISIONING_PROFILE_SPECIFIER = ""; 483 | SDKROOT = macosx; 484 | SKIP_INSTALL = YES; 485 | TARGETED_DEVICE_FAMILY = "1,2,3,4"; 486 | }; 487 | name = Release; 488 | }; 489 | /* End XCBuildConfiguration section */ 490 | 491 | /* Begin XCConfigurationList section */ 492 | 0128EEC72ABCBB3300E60976 /* Build configuration list for PBXNativeTarget "GZIPTests" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | 0128EEC82ABCBB3300E60976 /* Debug */, 496 | 0128EEC92ABCBB3300E60976 /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | 3AE36CB91B8F598E00923C2D /* Build configuration list for PBXProject "GZIP" */ = { 502 | isa = XCConfigurationList; 503 | buildConfigurations = ( 504 | 3AE36CC51B8F598E00923C2D /* Debug */, 505 | 3AE36CC61B8F598E00923C2D /* Release */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | 3AE36CD81B8F5AEF00923C2D /* Build configuration list for PBXNativeTarget "GZIP" */ = { 511 | isa = XCConfigurationList; 512 | buildConfigurations = ( 513 | 3AE36CD91B8F5AEF00923C2D /* Debug */, 514 | 3AE36CDA1B8F5AEF00923C2D /* Release */, 515 | ); 516 | defaultConfigurationIsVisible = 0; 517 | defaultConfigurationName = Release; 518 | }; 519 | /* End XCConfigurationList section */ 520 | }; 521 | rootObject = 3AE36CB61B8F598E00923C2D /* Project object */; 522 | } 523 | -------------------------------------------------------------------------------- /GZIP.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GZIP.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GZIP.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GZIP.xcodeproj/xcshareddata/xcschemes/GZIP.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 60 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /GZIP/GZIP.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for GZIP. 4 | FOUNDATION_EXPORT double GZIPVersionNumber; 5 | 6 | //! Project version string for GZIP. 7 | FOUNDATION_EXPORT const unsigned char GZIPVersionString[]; 8 | 9 | #import 10 | -------------------------------------------------------------------------------- /GZIP/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.3.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /GZIP/Sources/NSData+GZIP.h: -------------------------------------------------------------------------------- 1 | // 2 | // GZIP.h 3 | // 4 | // Version 1.3.2 5 | // 6 | // Created by Nick Lockwood on 03/06/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive MIT license 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/GZIP 13 | // 14 | // Permission is hereby granted, free of charge, to any person obtaining a copy 15 | // of this software and associated documentation files (the "Software"), to deal 16 | // in the Software without restriction, including without limitation the rights 17 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | // copies of the Software, and to permit persons to whom the Software is 19 | // furnished to do so, subject to the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be included in all 22 | // copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 | // SOFTWARE. 31 | // 32 | 33 | #import 34 | 35 | 36 | @interface NSData (GZIP) 37 | 38 | - (nullable NSData *)gzippedDataWithCompressionLevel:(float)level; 39 | - (nullable NSData *)gzippedData; 40 | - (nullable NSData *)gunzippedData; 41 | - (BOOL)isGzippedData; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /GZIP/Sources/NSData+GZIP.m: -------------------------------------------------------------------------------- 1 | // 2 | // GZIP.m 3 | // 4 | // Version 1.3.2 5 | // 6 | // Created by Nick Lockwood on 03/06/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive MIT license 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/GZIP 13 | // 14 | // Permission is hereby granted, free of charge, to any person obtaining a copy 15 | // of this software and associated documentation files (the "Software"), to deal 16 | // in the Software without restriction, including without limitation the rights 17 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | // copies of the Software, and to permit persons to whom the Software is 19 | // furnished to do so, subject to the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be included in all 22 | // copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 | // SOFTWARE. 31 | // 32 | 33 | #import "NSData+GZIP.h" 34 | #import 35 | 36 | 37 | #pragma clang diagnostic ignored "-Wcast-qual" 38 | 39 | 40 | @implementation NSData (GZIP) 41 | 42 | - (NSData *)gzippedDataWithCompressionLevel:(float)level 43 | { 44 | if (self.length == 0 || [self isGzippedData]) 45 | { 46 | return self; 47 | } 48 | 49 | z_stream stream; 50 | stream.zalloc = Z_NULL; 51 | stream.zfree = Z_NULL; 52 | stream.opaque = Z_NULL; 53 | stream.avail_in = (uint)self.length; 54 | stream.next_in = (Bytef *)(void *)self.bytes; 55 | stream.total_out = 0; 56 | stream.avail_out = 0; 57 | 58 | static const NSUInteger ChunkSize = 16384; 59 | 60 | NSMutableData *output = nil; 61 | int compression = (level < 0.0f)? Z_DEFAULT_COMPRESSION: (int)(roundf(level * 9)); 62 | if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) 63 | { 64 | output = [NSMutableData dataWithLength:ChunkSize]; 65 | while (stream.avail_out == 0) 66 | { 67 | if (stream.total_out >= output.length) 68 | { 69 | output.length += ChunkSize; 70 | } 71 | stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; 72 | stream.avail_out = (uInt)(output.length - stream.total_out); 73 | deflate(&stream, Z_FINISH); 74 | } 75 | deflateEnd(&stream); 76 | output.length = stream.total_out; 77 | } 78 | 79 | return output; 80 | } 81 | 82 | - (NSData *)gzippedData 83 | { 84 | return [self gzippedDataWithCompressionLevel:-1.0f]; 85 | } 86 | 87 | - (NSData *)gunzippedData 88 | { 89 | if (self.length == 0 || ![self isGzippedData]) 90 | { 91 | return self; 92 | } 93 | 94 | z_stream stream; 95 | stream.zalloc = Z_NULL; 96 | stream.zfree = Z_NULL; 97 | stream.avail_in = (uint)self.length; 98 | stream.next_in = (Bytef *)self.bytes; 99 | stream.total_out = 0; 100 | stream.avail_out = 0; 101 | 102 | NSMutableData *output = nil; 103 | if (inflateInit2(&stream, 47) == Z_OK) 104 | { 105 | int status = Z_OK; 106 | output = [NSMutableData dataWithCapacity:self.length * 2]; 107 | while (status == Z_OK) 108 | { 109 | if (stream.total_out >= output.length) 110 | { 111 | output.length += self.length / 2; 112 | } 113 | stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; 114 | stream.avail_out = (uInt)(output.length - stream.total_out); 115 | status = inflate (&stream, Z_SYNC_FLUSH); 116 | } 117 | if (inflateEnd(&stream) == Z_OK) 118 | { 119 | if (status == Z_STREAM_END) 120 | { 121 | output.length = stream.total_out; 122 | } 123 | } 124 | } 125 | 126 | return output; 127 | } 128 | 129 | - (BOOL)isGzippedData 130 | { 131 | const UInt8 *bytes = (const UInt8 *)self.bytes; 132 | return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b); 133 | } 134 | 135 | @end 136 | -------------------------------------------------------------------------------- /GZIPTests/GZIPTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GZIPTests.m 3 | // GZIPTests 4 | // 5 | // Created by Nick Lockwood on 21/09/2023. 6 | // 7 | 8 | #import 9 | 10 | @interface GZIPTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation GZIPTests 15 | 16 | - (void)setUp { 17 | // Put setup code here. This method is called before the invocation of each test method in the class. 18 | } 19 | 20 | - (void)tearDown { 21 | // Put teardown code here. This method is called after the invocation of each test method in the class. 22 | } 23 | 24 | - (void)testExample { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | - (void)testPerformanceExample { 30 | // This is an example of a performance test case. 31 | [self measureBlock:^{ 32 | // Put the code you want to measure the time of here. 33 | }]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /GZIPTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /GZIPTests/NSData+SEGGZIP.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+SEGGZIP.h 3 | // GZIPTests 4 | // 5 | // Created by John Wolfe on 5/14/19. 6 | // 7 | 8 | #import 9 | 10 | extern void *_Nullable seg_libzOpen(void); 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface NSData (SEGGZIP) 15 | 16 | - (nullable NSData *)seg_gzippedData; 17 | - (BOOL)seg_isGzippedData; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /GZIPTests/NSData+SEGGZIP.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+SEGGZIP.m 3 | // GZIPTests 4 | // 5 | // Created by John Wolfe on 5/14/19. 6 | // 7 | 8 | #import "NSData+SEGGZIP.h" 9 | 10 | #import 11 | #import 12 | 13 | #pragma clang diagnostic ignored "-Wcast-qual" 14 | 15 | @implementation NSData (SEGGZIP) 16 | 17 | void *_Nullable seg_libzOpen(void) 18 | { 19 | static void *libz; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | libz = dlopen("/usr/lib/libz.dylib", RTLD_LAZY); 23 | }); 24 | return libz; 25 | } 26 | 27 | - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level 28 | { 29 | if (self.length == 0 || [self seg_isGzippedData]) { 30 | return self; 31 | } 32 | 33 | void *libz = seg_libzOpen(); 34 | int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) = 35 | (int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_"); 36 | int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate"); 37 | int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd"); 38 | 39 | z_stream stream; 40 | stream.zalloc = Z_NULL; 41 | stream.zfree = Z_NULL; 42 | stream.opaque = Z_NULL; 43 | stream.avail_in = (uint)self.length; 44 | stream.next_in = (Bytef *)(void *)self.bytes; 45 | stream.total_out = 0; 46 | stream.avail_out = 0; 47 | 48 | static const NSUInteger ChunkSize = 16384; 49 | 50 | NSMutableData *output = nil; 51 | int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)(roundf(level * 9)); 52 | if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) { 53 | output = [NSMutableData dataWithLength:ChunkSize]; 54 | while (stream.avail_out == 0) { 55 | if (stream.total_out >= output.length) { 56 | output.length += ChunkSize; 57 | } 58 | stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; 59 | stream.avail_out = (uInt)(output.length - stream.total_out); 60 | deflate(&stream, Z_FINISH); 61 | } 62 | deflateEnd(&stream); 63 | output.length = stream.total_out; 64 | } 65 | 66 | return output; 67 | } 68 | 69 | - (nullable NSData *)seg_gzippedData 70 | { 71 | return [self seg_gzippedDataWithCompressionLevel:-1.0f]; 72 | } 73 | 74 | - (BOOL)seg_isGzippedData 75 | { 76 | const UInt8 *bytes = (const UInt8 *)self.bytes; 77 | return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b); 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /GZIPTests/UnitTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UnitTests.m 3 | // 4 | // Created by Nick Lockwood on 12/01/2012. 5 | // Copyright (c) 2012 Charcoal Design. All rights reserved. 6 | // 7 | 8 | 9 | #import 10 | #import "GZIP.h" 11 | #import "NSData+SEGGZIP.h" 12 | 13 | NSString *longInputString = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Eu consequat ac felis donec et odio. Nec sagittis aliquam malesuada bibendum arcu vitae elementum curabitur vitae. Vitae turpis massa sed elementum tempus egestas. Ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget. Sagittis nisl rhoncus mattis rhoncus urna neque viverra justo nec. Consectetur lorem donec massa sapien faucibus et. Id interdum velit laoreet id donec ultrices tincidunt arcu non. In dictum non consectetur a. Nisl pretium fusce id velit ut tortor. Purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus. Eget sit amet tellus cras adipiscing. Duis tristique sollicitudin nibh sit amet. Faucibus in ornare quam viverra orci sagittis eu. Enim nulla aliquet porttitor lacus luctus. Enim eu turpis egestas pretium. Odio ut enim blandit volutpat maecenas volutpat blandit aliquam. Eget duis at tellus at urna condimentum mattis pellentesque id. Sit amet consectetur adipiscing elit. Vulputate enim nulla aliquet porttitor lacus luctus accumsan tortor posuere.\ 14 | \ 15 | Ullamcorper velit sed ullamcorper morbi. Lobortis feugiat vivamus at augue eget arcu dictum. Aenean et tortor at risus viverra adipiscing at in tellus. Quis vel eros donec ac. Turpis in eu mi bibendum. Et odio pellentesque diam volutpat commodo. Volutpat blandit aliquam etiam erat. Sagittis id consectetur purus ut faucibus pulvinar elementum integer enim. Leo integer malesuada nunc vel. Vestibulum mattis ullamcorper velit sed. Eget sit amet tellus cras adipiscing enim eu turpis. Vitae et leo duis ut diam quam nulla porttitor. Enim sed faucibus turpis in eu mi bibendum neque. Interdum posuere lorem ipsum dolor sit amet consectetur adipiscing. Et pharetra pharetra massa massa. Massa sed elementum tempus egestas sed sed risus pretium quam. Et malesuada fames ac turpis egestas integer. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Amet aliquam id diam maecenas.\ 16 | \ 17 | Tristique magna sit amet purus. Tellus at urna condimentum mattis pellentesque id. Aliquet lectus proin nibh nisl. Lobortis elementum nibh tellus molestie nunc non blandit. Lectus mauris ultrices eros in cursus turpis massa tincidunt dui. Nibh ipsum consequat nisl vel pretium lectus. Sed nisi lacus sed viverra tellus in. Morbi leo urna molestie at elementum eu facilisis sed odio. Nunc sed augue lacus viverra vitae congue eu consequat. Gravida neque convallis a cras semper auctor neque. Commodo odio aenean sed adipiscing diam donec. Tellus rutrum tellus pellentesque eu tincidunt tortor aliquam.\ 18 | \ 19 | Ornare suspendisse sed nisi lacus sed viverra. Sed sed risus pretium quam vulputate. Vestibulum morbi blandit cursus risus at ultrices mi tempus. Dignissim convallis aenean et tortor. Massa sapien faucibus et molestie ac feugiat sed lectus. Etiam non quam lacus suspendisse faucibus interdum posuere. Vel quam elementum pulvinar etiam non. Tincidunt vitae semper quis lectus nulla. Scelerisque purus semper eget duis at tellus at urna condimentum. Malesuada fames ac turpis egestas sed tempus urna. Posuere urna nec tincidunt praesent. Elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi.\ 20 | \ 21 | Tellus id interdum velit laoreet id donec ultrices. Risus in hendrerit gravida rutrum quisque. Volutpat maecenas volutpat blandit aliquam etiam erat velit scelerisque in. Sagittis orci a scelerisque purus semper eget duis at tellus. Consectetur a erat nam at lectus. Vel eros donec ac odio tempor orci dapibus. Non odio euismod lacinia at. Phasellus egestas tellus rutrum tellus pellentesque eu. Aliquet sagittis id consectetur purus. Diam volutpat commodo sed egestas egestas. Lacinia at quis risus sed vulputate. Purus sit amet volutpat consequat mauris nunc congue. Viverra nam libero justo laoreet sit amet cursus. Facilisis leo vel fringilla est ullamcorper eget."; 22 | 23 | NSString *longLongInputString = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Mi in nulla posuere sollicitudin aliquam ultrices sagittis. Vestibulum rhoncus est pellentesque elit ullamcorper dignissim. In ornare quam viverra orci sagittis eu volutpat odio facilisis. Volutpat diam ut venenatis tellus in metus vulputate. Adipiscing enim eu turpis egestas pretium. Augue eget arcu dictum varius duis at consectetur. Sagittis id consectetur purus ut faucibus pulvinar elementum integer enim. Sociis natoque penatibus et magnis dis parturient montes nascetur ridiculus. Imperdiet proin fermentum leo vel orci porta. Commodo viverra maecenas accumsan lacus vel facilisis volutpat est velit. Vestibulum lorem sed risus ultricies tristique nulla. Vel eros donec ac odio tempor orci dapibus. Morbi leo urna molestie at elementum eu facilisis sed. Magna eget est lorem ipsum dolor sit amet consectetur.\ 24 | \ 25 | A arcu cursus vitae congue mauris rhoncus aenean. Libero nunc consequat interdum varius sit. Amet consectetur adipiscing elit duis. Integer malesuada nunc vel risus commodo. Quis varius quam quisque id diam vel quam elementum. Sagittis purus sit amet volutpat consequat mauris. Sed nisi lacus sed viverra. Ultrices neque ornare aenean euismod elementum nisi quis. Tincidunt lobortis feugiat vivamus at. Facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum. Elementum facilisis leo vel fringilla est.\ 26 | \ 27 | Porttitor lacus luctus accumsan tortor posuere ac ut consequat semper. Nibh ipsum consequat nisl vel pretium lectus quam id. Imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada. Posuere ac ut consequat semper viverra. Id porta nibh venenatis cras. Ultrices vitae auctor eu augue ut lectus arcu. Tempor nec feugiat nisl pretium fusce id velit. Sem integer vitae justo eget magna fermentum. Ultricies leo integer malesuada nunc vel. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris. Dui id ornare arcu odio ut sem nulla. Consectetur libero id faucibus nisl tincidunt eget. Nulla posuere sollicitudin aliquam ultrices sagittis orci a scelerisque. Tortor vitae purus faucibus ornare suspendisse. Turpis egestas maecenas pharetra convallis posuere morbi leo urna. Vel pretium lectus quam id leo in vitae turpis. Nisl purus in mollis nunc sed id semper risus. Amet tellus cras adipiscing enim. Ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet. Ipsum faucibus vitae aliquet nec.\ 28 | \ 29 | Id aliquet lectus proin nibh nisl condimentum id. Cras ornare arcu dui vivamus arcu felis bibendum ut tristique. Eu ultrices vitae auctor eu augue ut lectus arcu. Ac odio tempor orci dapibus ultrices in. Tristique et egestas quis ipsum suspendisse. Viverra adipiscing at in tellus integer feugiat scelerisque varius. Nulla pharetra diam sit amet nisl suscipit adipiscing. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Sodales neque sodales ut etiam. Proin nibh nisl condimentum id venenatis a condimentum vitae. Non arcu risus quis varius quam quisque id diam. Purus sit amet luctus venenatis.\ 30 | \ 31 | Dignissim convallis aenean et tortor at risus viverra adipiscing at. Ornare arcu odio ut sem nulla. Tristique magna sit amet purus. Tempus urna et pharetra pharetra massa massa. Nulla facilisi cras fermentum odio eu. Sit amet nisl purus in mollis nunc sed. Imperdiet proin fermentum leo vel orci porta non pulvinar. Nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit amet. Egestas diam in arcu cursus euismod quis viverra nibh. Porttitor leo a diam sollicitudin tempor. Commodo sed egestas egestas fringilla phasellus. Mauris nunc congue nisi vitae suscipit. Viverra adipiscing at in tellus integer feugiat.\ 32 | \ 33 | Faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Bibendum ut tristique et egestas. Neque vitae tempus quam pellentesque. Donec et odio pellentesque diam volutpat. Mi proin sed libero enim sed faucibus. Magnis dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Ac ut consequat semper viverra nam libero. Mattis rhoncus urna neque viverra justo nec ultrices dui sapien. Nunc faucibus a pellentesque sit amet porttitor eget dolor. Arcu cursus vitae congue mauris rhoncus aenean vel. Ac orci phasellus egestas tellus. Adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus urna. Lectus urna duis convallis convallis. Commodo quis imperdiet massa tincidunt nunc pulvinar. Commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend. Consectetur libero id faucibus nisl tincidunt eget. Proin fermentum leo vel orci. Lobortis elementum nibh tellus molestie nunc non. Urna id volutpat lacus laoreet non curabitur gravida arcu.\ 34 | \ 35 | Proin nibh nisl condimentum id venenatis a condimentum vitae. Varius quam quisque id diam vel quam. Malesuada nunc vel risus commodo viverra maecenas accumsan lacus. Ullamcorper dignissim cras tincidunt lobortis. Nibh venenatis cras sed felis eget. Ut sem nulla pharetra diam sit amet nisl. Et sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque. Nunc sed augue lacus viverra vitae congue eu consequat. Id semper risus in hendrerit. Felis eget nunc lobortis mattis aliquam faucibus purus. Sed velit dignissim sodales ut eu sem integer. Elementum pulvinar etiam non quam lacus suspendisse faucibus. Non diam phasellus vestibulum lorem sed risus. Morbi non arcu risus quis. Nunc non blandit massa enim nec.\ 36 | \ 37 | Odio tempor orci dapibus ultrices. Diam in arcu cursus euismod quis viverra nibh cras pulvinar. Natoque penatibus et magnis dis parturient montes nascetur. Nulla facilisi etiam dignissim diam quis enim. Cum sociis natoque penatibus et magnis dis parturient montes nascetur. Pellentesque id nibh tortor id aliquet. Id cursus metus aliquam eleifend mi in nulla posuere. Integer vitae justo eget magna fermentum. Enim neque volutpat ac tincidunt vitae semper quis. Curabitur vitae nunc sed velit dignissim sodales ut eu sem. Sollicitudin aliquam ultrices sagittis orci a scelerisque purus semper. Tortor at risus viverra adipiscing.\ 38 | \ 39 | Sed velit dignissim sodales ut eu. Ipsum nunc aliquet bibendum enim facilisis gravida neque convallis. Id porta nibh venenatis cras sed. Tellus at urna condimentum mattis. Duis at tellus at urna condimentum mattis. Aliquet sagittis id consectetur purus ut faucibus pulvinar elementum. Massa ultricies mi quis hendrerit dolor magna eget. Laoreet sit amet cursus sit amet dictum sit amet. Laoreet suspendisse interdum consectetur libero id. Ut sem viverra aliquet eget sit. Felis imperdiet proin fermentum leo. Nec ultrices dui sapien eget mi proin sed libero enim. Consectetur adipiscing elit ut aliquam. Amet nisl suscipit adipiscing bibendum est ultricies integer quis. Ut eu sem integer vitae justo eget magna fermentum iaculis.\ 40 | \ 41 | Eros donec ac odio tempor orci dapibus. Porttitor massa id neque aliquam vestibulum. Tristique senectus et netus et malesuada fames ac turpis. Amet dictum sit amet justo donec enim diam vulputate ut. Sollicitudin tempor id eu nisl nunc mi ipsum faucibus. Faucibus ornare suspendisse sed nisi lacus sed. Ultrices tincidunt arcu non sodales neque sodales ut. Tempus iaculis urna id volutpat lacus laoreet. Sapien nec sagittis aliquam malesuada. Velit euismod in pellentesque massa placerat duis. Bibendum ut tristique et egestas. Sagittis nisl rhoncus mattis rhoncus urna neque viverra justo nec. Vulputate odio ut enim blandit volutpat maecenas volutpat.."; 42 | 43 | 44 | static NSData *createRandomNSData(void) 45 | { 46 | NSUInteger size = 10 * 1024 * 1024; // 10mb 47 | NSMutableData *data = [NSMutableData dataWithLength:size]; 48 | u_int32_t *bytes = (u_int32_t *)data.mutableBytes; 49 | for (NSUInteger index = 0; index < size/sizeof(u_int32_t); index++) 50 | { 51 | bytes[index] = arc4random(); 52 | } 53 | return data; 54 | } 55 | 56 | 57 | @interface UnitTests : XCTestCase 58 | 59 | @end 60 | 61 | 62 | @implementation UnitTests 63 | 64 | - (void)testOutputEqualsInput 65 | { 66 | //set up data 67 | NSString *inputString = @"Hello World!"; 68 | NSData *inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; 69 | 70 | //compress 71 | NSData *compressedData = [inputData gzippedData]; 72 | 73 | //decode 74 | NSData *outputData = [compressedData gunzippedData]; 75 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 76 | XCTAssertEqualObjects(outputString, inputString); 77 | } 78 | 79 | - (void)testOutputEqualsLongInput 80 | { 81 | //set up data 82 | NSData *inputData = [longInputString dataUsingEncoding:NSUTF8StringEncoding]; 83 | 84 | //compress 85 | NSData *compressedData = [inputData gzippedData]; 86 | 87 | //decode 88 | NSData *outputData = [compressedData gunzippedData]; 89 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 90 | XCTAssertEqualObjects(outputString, longInputString); 91 | } 92 | 93 | - (void)testOutputEqualsLongLongInput 94 | { 95 | //set up data 96 | NSData *inputData = [longLongInputString dataUsingEncoding:NSUTF8StringEncoding]; 97 | 98 | //compress 99 | NSData *compressedData = [inputData gzippedData]; 100 | 101 | //decode 102 | NSData *outputData = [compressedData gunzippedData]; 103 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 104 | XCTAssertEqualObjects(outputString, longLongInputString); 105 | } 106 | 107 | - (void)testUnzipNonZippedData 108 | { 109 | //set up data 110 | NSString *inputString = @"Hello World!"; 111 | NSData *inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; 112 | 113 | //decode 114 | NSData *outputData = [inputData gunzippedData]; 115 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 116 | XCTAssertEqualObjects(outputString, inputString); 117 | } 118 | 119 | - (void)testRezipZippedData 120 | { 121 | //set up data 122 | NSString *inputString = @"Hello World!"; 123 | NSData *inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; 124 | 125 | //compress 126 | NSData *compressedData = [inputData gzippedData]; 127 | 128 | //compress again 129 | NSData *outputData = [compressedData gzippedData]; 130 | XCTAssertEqualObjects(compressedData, outputData); 131 | } 132 | 133 | - (void)testZeroLengthInput 134 | { 135 | NSData *data = [[NSData data] gzippedData]; 136 | XCTAssertEqual(data.length, 0); 137 | 138 | data = [[NSData data] gunzippedData]; 139 | XCTAssertEqual(data.length, 0); 140 | } 141 | 142 | - (void)testCompressionPerformance 143 | { 144 | NSData *inputData = createRandomNSData(); 145 | [self measureBlock:^{ 146 | __unused NSData *compressedData = [inputData gzippedData]; 147 | }]; 148 | } 149 | 150 | - (void)testDecompressionPerformance 151 | { 152 | NSData *inputData = createRandomNSData(); 153 | NSData *compressedData = [inputData gzippedData]; 154 | [self measureBlock:^{ 155 | __unused NSData *outputData = [compressedData gunzippedData]; 156 | }]; 157 | } 158 | 159 | - (void)testEncodeWriteFileDecodeInShell 160 | { 161 | // Create a file of giberish 162 | NSString *inputString = @"Hello World!"; 163 | NSData *inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; 164 | 165 | // compare old-style gzipped data (via /usr/lib/libz.dylib) to gzipped data 166 | NSData *seggzippedData = [inputData seg_gzippedData]; 167 | NSData *gzippedData = [inputData gzippedData]; 168 | XCTAssertEqualObjects(seggzippedData, gzippedData); 169 | 170 | // compare gunzipped SEGGZIPPED data to original data 171 | NSData *expandedSEGGZippedData = [seggzippedData gunzippedData]; 172 | XCTAssertEqualObjects(expandedSEGGZippedData, inputData); 173 | } 174 | 175 | - (void)testHugeEncodeWriteFileDecodeInShell 176 | { 177 | // Create a file of giberish 178 | NSData *inputData = createRandomNSData(); 179 | 180 | // compare old-style gzipped data (via /usr/lib/libz.dylib) to gzipped data 181 | NSData *seggzippedData = [inputData seg_gzippedData]; 182 | NSData *gzippedData = [inputData gzippedData]; 183 | XCTAssertEqualObjects(seggzippedData, gzippedData); 184 | 185 | // compare gunzipped SEGGZIPPED data to original data 186 | NSData *expandedSEGGZippedData = [seggzippedData gunzippedData]; 187 | XCTAssertEqualObjects(expandedSEGGZippedData, inputData); 188 | } 189 | 190 | @end 191 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012 Nick Lockwood 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "GZIP", 8 | products: [ 9 | .library( 10 | name: "GZIP", 11 | targets: ["GZIP"]), 12 | ], 13 | targets: [ 14 | .target( 15 | name: "GZIP", 16 | path: "GZIP", 17 | sources: ["Sources"], 18 | publicHeadersPath: "Sources") 19 | ] 20 | ) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build](https://github.com/nicklockwood/GZIP/actions/workflows/build.yml/badge.svg)](https://github.com/nicklockwood/GZIP/actions/workflows/build.yml) 2 | [![Codecov](https://codecov.io/gh/nicklockwood/GZIP/graphs/badge.svg)](https://codecov.io/gh/nicklockwood/GZIP) 3 | [![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT) 4 | [![Mastodon](https://img.shields.io/badge/mastodon-@nicklockwood@mastodon.social-636dff.svg)](https://mastodon.social/@nicklockwood) 5 | 6 | 7 | Purpose 8 | -------------- 9 | 10 | GZIP is category on NSData that provides simple gzip compression and decompression functionality. 11 | 12 | 13 | Supported OS & SDK Versions 14 | ----------------------------- 15 | 16 | * Supported build target - iOS 12.0 / Mac OS 10.14 (Xcode 10.1) 17 | * Earliest supported deployment target - iOS 11.0 / Mac OS 10.14.6 18 | * Earliest compatible deployment target - iOS 11.0 / Mac OS 10.6 19 | 20 | NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this iOS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly. 21 | 22 | 23 | ARC Compatibility 24 | ------------------ 25 | 26 | The GZIP category will work correctly in either ARC or non-ARC projects without modification. 27 | 28 | 29 | Thread Safety 30 | -------------- 31 | 32 | All the GZIP methods should be safe to call from multiple threads concurrently. 33 | 34 | 35 | Installation 36 | -------------- 37 | 38 | The simplest way to install GZIP is to use CocoaPods, by adding the following to your Podfile: 39 | 40 | pod 'GZIP', '~> 1.3.2' 41 | 42 | Alternatively you can use Carthage, or if you prefer to install manually, drag the GZIP.xcodeproj into your project or workspace and include GZIP.framework under the linked libraries in your target. 43 | 44 | 45 | NSData Extensions 46 | ---------------------- 47 | 48 | - (NSData *)gzippedDataWithCompressionLevel:(float)level; 49 | 50 | This method will apply the gzip deflate algorithm and return the compressed data. The compression level is a floating point value between 0.0 and 1.0, with 0.0 meaning no compression and 1.0 meaning maximum compression. A value of 0.1 will provide the fastest possible compression. If you supply a negative value, this will apply the default compression level, which is equivalent to a value of around 0.7. 51 | 52 | - (NSData *)gzippedData; 53 | 54 | This method is equivalent to calling `gzippedDataWithCompressionLevel:` with the default compression level. 55 | 56 | - (NSData *)gunzippedData; 57 | 58 | This method will unzip data that was compressed using the deflate algorithm and return the result. 59 | 60 | - (BOOL)isGzippedData; 61 | 62 | This method will return YES if the data is gzip-encoded. 63 | --------------------------------------------------------------------------------