├── README.md ├── XCache.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── xlx.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── XCache.xcscheme │ └── xcschememanagement.plist ├── XCache ├── 1.jpg ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── XCache.h ├── XCache.m └── main.m ├── XCacheTests ├── Info.plist └── XCacheTests.m └── XCacheUITests ├── Info.plist └── XCacheUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # XCache 2 | 一个对内存进行操作的简单工具 3 | 4 | Compute application cache and clean cache 5 | ``` 6 | /** 7 | * 查询手机剩余内存 8 | * 9 | */ 10 | + (long long) freeDiskSpaceInBytes; 11 | /** 12 | * 查询缓存大小 单位MB 13 | * 14 | */ 15 | +(NSString *)returnCacheSize; 16 | /** 17 | * 计算单个文件大小 18 | * 19 | * @param path 文件地址 20 | * 21 | */ 22 | +(long long)returnFileSize:(NSString *)path; 23 | /** 24 | * 清理缓存 25 | * 26 | */ 27 | +(void)cleanCache:(void(^)())complete; 28 | /** 29 | * 删除单个文件 30 | * 31 | */ 32 | +(void)deleteFile:(NSString *)path; 33 | /** 34 | * 生成大量垃圾数据 35 | */ 36 | +(void)createLargeCache; 37 | 38 | 39 | ``` 40 | -------------------------------------------------------------------------------- /XCache.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2A694AA61C94703B00B2DABD /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2A694AA51C94703B00B2DABD /* 1.jpg */; }; 11 | 2AF487FF1C941B300054827D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF487FE1C941B300054827D /* main.m */; }; 12 | 2AF488021C941B300054827D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF488011C941B300054827D /* AppDelegate.m */; }; 13 | 2AF488051C941B300054827D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF488041C941B300054827D /* ViewController.m */; }; 14 | 2AF488081C941B300054827D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2AF488061C941B300054827D /* Main.storyboard */; }; 15 | 2AF4880A1C941B300054827D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2AF488091C941B300054827D /* Assets.xcassets */; }; 16 | 2AF4880D1C941B300054827D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2AF4880B1C941B300054827D /* LaunchScreen.storyboard */; }; 17 | 2AF488181C941B300054827D /* XCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF488171C941B300054827D /* XCacheTests.m */; }; 18 | 2AF488231C941B300054827D /* XCacheUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF488221C941B300054827D /* XCacheUITests.m */; }; 19 | 2AF488331C941BA80054827D /* XCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF488321C941BA80054827D /* XCache.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 2AF488141C941B300054827D /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 2AF487F21C941B300054827D /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 2AF487F91C941B300054827D; 28 | remoteInfo = XCache; 29 | }; 30 | 2AF4881F1C941B300054827D /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 2AF487F21C941B300054827D /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 2AF487F91C941B300054827D; 35 | remoteInfo = XCache; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 2A694AA51C94703B00B2DABD /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; }; 41 | 2AF487FA1C941B300054827D /* XCache.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XCache.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 2AF487FE1C941B300054827D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 2AF488001C941B300054827D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 2AF488011C941B300054827D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 2AF488031C941B300054827D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 2AF488041C941B300054827D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 2AF488071C941B300054827D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 2AF488091C941B300054827D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 2AF4880C1C941B300054827D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 2AF4880E1C941B300054827D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 2AF488131C941B300054827D /* XCacheTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XCacheTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 2AF488171C941B300054827D /* XCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XCacheTests.m; sourceTree = ""; }; 53 | 2AF488191C941B300054827D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 2AF4881E1C941B300054827D /* XCacheUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XCacheUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 2AF488221C941B300054827D /* XCacheUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XCacheUITests.m; sourceTree = ""; }; 56 | 2AF488241C941B300054827D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 2AF488311C941BA80054827D /* XCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCache.h; sourceTree = ""; }; 58 | 2AF488321C941BA80054827D /* XCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCache.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 2AF487F71C941B300054827D /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 2AF488101C941B300054827D /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 2AF4881B1C941B300054827D /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 2AF487F11C941B300054827D = { 87 | isa = PBXGroup; 88 | children = ( 89 | 2AF487FC1C941B300054827D /* XCache */, 90 | 2AF488161C941B300054827D /* XCacheTests */, 91 | 2AF488211C941B300054827D /* XCacheUITests */, 92 | 2AF487FB1C941B300054827D /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 2AF487FB1C941B300054827D /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 2AF487FA1C941B300054827D /* XCache.app */, 100 | 2AF488131C941B300054827D /* XCacheTests.xctest */, 101 | 2AF4881E1C941B300054827D /* XCacheUITests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 2AF487FC1C941B300054827D /* XCache */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 2A694AA51C94703B00B2DABD /* 1.jpg */, 110 | 2AF488301C941B3B0054827D /* XCache */, 111 | 2AF488001C941B300054827D /* AppDelegate.h */, 112 | 2AF488011C941B300054827D /* AppDelegate.m */, 113 | 2AF488031C941B300054827D /* ViewController.h */, 114 | 2AF488041C941B300054827D /* ViewController.m */, 115 | 2AF488061C941B300054827D /* Main.storyboard */, 116 | 2AF488091C941B300054827D /* Assets.xcassets */, 117 | 2AF4880B1C941B300054827D /* LaunchScreen.storyboard */, 118 | 2AF4880E1C941B300054827D /* Info.plist */, 119 | 2AF487FD1C941B300054827D /* Supporting Files */, 120 | ); 121 | path = XCache; 122 | sourceTree = ""; 123 | }; 124 | 2AF487FD1C941B300054827D /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 2AF487FE1C941B300054827D /* main.m */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 2AF488161C941B300054827D /* XCacheTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 2AF488171C941B300054827D /* XCacheTests.m */, 136 | 2AF488191C941B300054827D /* Info.plist */, 137 | ); 138 | path = XCacheTests; 139 | sourceTree = ""; 140 | }; 141 | 2AF488211C941B300054827D /* XCacheUITests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 2AF488221C941B300054827D /* XCacheUITests.m */, 145 | 2AF488241C941B300054827D /* Info.plist */, 146 | ); 147 | path = XCacheUITests; 148 | sourceTree = ""; 149 | }; 150 | 2AF488301C941B3B0054827D /* XCache */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 2AF488311C941BA80054827D /* XCache.h */, 154 | 2AF488321C941BA80054827D /* XCache.m */, 155 | ); 156 | name = XCache; 157 | sourceTree = ""; 158 | }; 159 | /* End PBXGroup section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | 2AF487F91C941B300054827D /* XCache */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 2AF488271C941B300054827D /* Build configuration list for PBXNativeTarget "XCache" */; 165 | buildPhases = ( 166 | 2AF487F61C941B300054827D /* Sources */, 167 | 2AF487F71C941B300054827D /* Frameworks */, 168 | 2AF487F81C941B300054827D /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = XCache; 175 | productName = XCache; 176 | productReference = 2AF487FA1C941B300054827D /* XCache.app */; 177 | productType = "com.apple.product-type.application"; 178 | }; 179 | 2AF488121C941B300054827D /* XCacheTests */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 2AF4882A1C941B300054827D /* Build configuration list for PBXNativeTarget "XCacheTests" */; 182 | buildPhases = ( 183 | 2AF4880F1C941B300054827D /* Sources */, 184 | 2AF488101C941B300054827D /* Frameworks */, 185 | 2AF488111C941B300054827D /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | 2AF488151C941B300054827D /* PBXTargetDependency */, 191 | ); 192 | name = XCacheTests; 193 | productName = XCacheTests; 194 | productReference = 2AF488131C941B300054827D /* XCacheTests.xctest */; 195 | productType = "com.apple.product-type.bundle.unit-test"; 196 | }; 197 | 2AF4881D1C941B300054827D /* XCacheUITests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 2AF4882D1C941B300054827D /* Build configuration list for PBXNativeTarget "XCacheUITests" */; 200 | buildPhases = ( 201 | 2AF4881A1C941B300054827D /* Sources */, 202 | 2AF4881B1C941B300054827D /* Frameworks */, 203 | 2AF4881C1C941B300054827D /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | 2AF488201C941B300054827D /* PBXTargetDependency */, 209 | ); 210 | name = XCacheUITests; 211 | productName = XCacheUITests; 212 | productReference = 2AF4881E1C941B300054827D /* XCacheUITests.xctest */; 213 | productType = "com.apple.product-type.bundle.ui-testing"; 214 | }; 215 | /* End PBXNativeTarget section */ 216 | 217 | /* Begin PBXProject section */ 218 | 2AF487F21C941B300054827D /* Project object */ = { 219 | isa = PBXProject; 220 | attributes = { 221 | LastUpgradeCheck = 0720; 222 | ORGANIZATIONNAME = xlx; 223 | TargetAttributes = { 224 | 2AF487F91C941B300054827D = { 225 | CreatedOnToolsVersion = 7.2.1; 226 | }; 227 | 2AF488121C941B300054827D = { 228 | CreatedOnToolsVersion = 7.2.1; 229 | TestTargetID = 2AF487F91C941B300054827D; 230 | }; 231 | 2AF4881D1C941B300054827D = { 232 | CreatedOnToolsVersion = 7.2.1; 233 | TestTargetID = 2AF487F91C941B300054827D; 234 | }; 235 | }; 236 | }; 237 | buildConfigurationList = 2AF487F51C941B300054827D /* Build configuration list for PBXProject "XCache" */; 238 | compatibilityVersion = "Xcode 3.2"; 239 | developmentRegion = English; 240 | hasScannedForEncodings = 0; 241 | knownRegions = ( 242 | en, 243 | Base, 244 | ); 245 | mainGroup = 2AF487F11C941B300054827D; 246 | productRefGroup = 2AF487FB1C941B300054827D /* Products */; 247 | projectDirPath = ""; 248 | projectRoot = ""; 249 | targets = ( 250 | 2AF487F91C941B300054827D /* XCache */, 251 | 2AF488121C941B300054827D /* XCacheTests */, 252 | 2AF4881D1C941B300054827D /* XCacheUITests */, 253 | ); 254 | }; 255 | /* End PBXProject section */ 256 | 257 | /* Begin PBXResourcesBuildPhase section */ 258 | 2AF487F81C941B300054827D /* Resources */ = { 259 | isa = PBXResourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 2AF4880D1C941B300054827D /* LaunchScreen.storyboard in Resources */, 263 | 2A694AA61C94703B00B2DABD /* 1.jpg in Resources */, 264 | 2AF4880A1C941B300054827D /* Assets.xcassets in Resources */, 265 | 2AF488081C941B300054827D /* Main.storyboard in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | 2AF488111C941B300054827D /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 2AF4881C1C941B300054827D /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | 2AF487F61C941B300054827D /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 2AF488051C941B300054827D /* ViewController.m in Sources */, 291 | 2AF488021C941B300054827D /* AppDelegate.m in Sources */, 292 | 2AF487FF1C941B300054827D /* main.m in Sources */, 293 | 2AF488331C941BA80054827D /* XCache.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | 2AF4880F1C941B300054827D /* Sources */ = { 298 | isa = PBXSourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | 2AF488181C941B300054827D /* XCacheTests.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | 2AF4881A1C941B300054827D /* Sources */ = { 306 | isa = PBXSourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | 2AF488231C941B300054827D /* XCacheUITests.m in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | /* End PBXSourcesBuildPhase section */ 314 | 315 | /* Begin PBXTargetDependency section */ 316 | 2AF488151C941B300054827D /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = 2AF487F91C941B300054827D /* XCache */; 319 | targetProxy = 2AF488141C941B300054827D /* PBXContainerItemProxy */; 320 | }; 321 | 2AF488201C941B300054827D /* PBXTargetDependency */ = { 322 | isa = PBXTargetDependency; 323 | target = 2AF487F91C941B300054827D /* XCache */; 324 | targetProxy = 2AF4881F1C941B300054827D /* PBXContainerItemProxy */; 325 | }; 326 | /* End PBXTargetDependency section */ 327 | 328 | /* Begin PBXVariantGroup section */ 329 | 2AF488061C941B300054827D /* Main.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 2AF488071C941B300054827D /* Base */, 333 | ); 334 | name = Main.storyboard; 335 | sourceTree = ""; 336 | }; 337 | 2AF4880B1C941B300054827D /* LaunchScreen.storyboard */ = { 338 | isa = PBXVariantGroup; 339 | children = ( 340 | 2AF4880C1C941B300054827D /* Base */, 341 | ); 342 | name = LaunchScreen.storyboard; 343 | sourceTree = ""; 344 | }; 345 | /* End PBXVariantGroup section */ 346 | 347 | /* Begin XCBuildConfiguration section */ 348 | 2AF488251C941B300054827D /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | DEBUG_INFORMATION_FORMAT = dwarf; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | ENABLE_TESTABILITY = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_DYNAMIC_NO_PIC = NO; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_OPTIMIZATION_LEVEL = 0; 374 | GCC_PREPROCESSOR_DEFINITIONS = ( 375 | "DEBUG=1", 376 | "$(inherited)", 377 | ); 378 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 379 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 380 | GCC_WARN_UNDECLARED_SELECTOR = YES; 381 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 382 | GCC_WARN_UNUSED_FUNCTION = YES; 383 | GCC_WARN_UNUSED_VARIABLE = YES; 384 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 385 | MTL_ENABLE_DEBUG_INFO = YES; 386 | ONLY_ACTIVE_ARCH = YES; 387 | SDKROOT = iphoneos; 388 | TARGETED_DEVICE_FAMILY = "1,2"; 389 | }; 390 | name = Debug; 391 | }; 392 | 2AF488261C941B300054827D /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_CONSTANT_CONVERSION = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 407 | CLANG_WARN_UNREACHABLE_CODE = YES; 408 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 409 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 410 | COPY_PHASE_STRIP = NO; 411 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 412 | ENABLE_NS_ASSERTIONS = NO; 413 | ENABLE_STRICT_OBJC_MSGSEND = YES; 414 | GCC_C_LANGUAGE_STANDARD = gnu99; 415 | GCC_NO_COMMON_BLOCKS = YES; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 423 | MTL_ENABLE_DEBUG_INFO = NO; 424 | SDKROOT = iphoneos; 425 | TARGETED_DEVICE_FAMILY = "1,2"; 426 | VALIDATE_PRODUCT = YES; 427 | }; 428 | name = Release; 429 | }; 430 | 2AF488281C941B300054827D /* Debug */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 434 | INFOPLIST_FILE = XCache/Info.plist; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCache; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | }; 439 | name = Debug; 440 | }; 441 | 2AF488291C941B300054827D /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | INFOPLIST_FILE = XCache/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCache; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | }; 450 | name = Release; 451 | }; 452 | 2AF4882B1C941B300054827D /* Debug */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | BUNDLE_LOADER = "$(TEST_HOST)"; 456 | INFOPLIST_FILE = XCacheTests/Info.plist; 457 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 458 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCacheTests; 459 | PRODUCT_NAME = "$(TARGET_NAME)"; 460 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XCache.app/XCache"; 461 | }; 462 | name = Debug; 463 | }; 464 | 2AF4882C1C941B300054827D /* Release */ = { 465 | isa = XCBuildConfiguration; 466 | buildSettings = { 467 | BUNDLE_LOADER = "$(TEST_HOST)"; 468 | INFOPLIST_FILE = XCacheTests/Info.plist; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 470 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCacheTests; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/XCache.app/XCache"; 473 | }; 474 | name = Release; 475 | }; 476 | 2AF4882E1C941B300054827D /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | INFOPLIST_FILE = XCacheUITests/Info.plist; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 481 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCacheUITests; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | TEST_TARGET_NAME = XCache; 484 | USES_XCTRUNNER = YES; 485 | }; 486 | name = Debug; 487 | }; 488 | 2AF4882F1C941B300054827D /* Release */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | INFOPLIST_FILE = XCacheUITests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = com.xlx.XCacheUITests; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | TEST_TARGET_NAME = XCache; 496 | USES_XCTRUNNER = YES; 497 | }; 498 | name = Release; 499 | }; 500 | /* End XCBuildConfiguration section */ 501 | 502 | /* Begin XCConfigurationList section */ 503 | 2AF487F51C941B300054827D /* Build configuration list for PBXProject "XCache" */ = { 504 | isa = XCConfigurationList; 505 | buildConfigurations = ( 506 | 2AF488251C941B300054827D /* Debug */, 507 | 2AF488261C941B300054827D /* Release */, 508 | ); 509 | defaultConfigurationIsVisible = 0; 510 | defaultConfigurationName = Release; 511 | }; 512 | 2AF488271C941B300054827D /* Build configuration list for PBXNativeTarget "XCache" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | 2AF488281C941B300054827D /* Debug */, 516 | 2AF488291C941B300054827D /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | 2AF4882A1C941B300054827D /* Build configuration list for PBXNativeTarget "XCacheTests" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | 2AF4882B1C941B300054827D /* Debug */, 525 | 2AF4882C1C941B300054827D /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | defaultConfigurationName = Release; 529 | }; 530 | 2AF4882D1C941B300054827D /* Build configuration list for PBXNativeTarget "XCacheUITests" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 2AF4882E1C941B300054827D /* Debug */, 534 | 2AF4882F1C941B300054827D /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | /* End XCConfigurationList section */ 540 | }; 541 | rootObject = 2AF487F21C941B300054827D /* Project object */; 542 | } 543 | -------------------------------------------------------------------------------- /XCache.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /XCache.xcodeproj/xcuserdata/xlx.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /XCache.xcodeproj/xcuserdata/xlx.xcuserdatad/xcschemes/XCache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /XCache.xcodeproj/xcuserdata/xlx.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | XCache.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 2AF487F91C941B300054827D 16 | 17 | primary 18 | 19 | 20 | 2AF488121C941B300054827D 21 | 22 | primary 23 | 24 | 25 | 2AF4881D1C941B300054827D 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /XCache/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongX/XCache/b9da0736c7bb065d8c5dd44aeff79b25c367954f/XCache/1.jpg -------------------------------------------------------------------------------- /XCache/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /XCache/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /XCache/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /XCache/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /XCache/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /XCache/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /XCache/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /XCache/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "XCache.h" 11 | 12 | @interface ViewController () 13 | @property (weak, nonatomic) IBOutlet UILabel *cacheLabel; 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | _cacheLabel.text = [XCache returnCacheSize]; 22 | 23 | } 24 | - (IBAction)clean:(id)sender { 25 | [XCache cleanCache:^{ 26 | NSLog(@"清理成功"); 27 | }]; 28 | 29 | } 30 | 31 | - (void)didReceiveMemoryWarning { 32 | [super didReceiveMemoryWarning]; 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /XCache/XCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // XCache.h 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface XCache : NSObject 12 | /** 13 | * 查询手机剩余内存 14 | * 15 | */ 16 | + (long long) freeDiskSpaceInBytes; 17 | /** 18 | * 查询缓存大小 单位MB 19 | * 20 | */ 21 | +(NSString *)returnCacheSize; 22 | /** 23 | * 计算单个文件大小 24 | * 25 | * @param path 文件地址 26 | * 27 | */ 28 | +(long long)returnFileSize:(NSString *)path; 29 | /** 30 | * 清理缓存 31 | * 32 | */ 33 | +(void)cleanCache:(void(^)())complete; 34 | /** 35 | * 删除单个文件 36 | * 37 | */ 38 | +(void)deleteFile:(NSString *)path; 39 | /** 40 | * 生成大量垃圾数据 41 | */ 42 | +(void)createLargeCache; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /XCache/XCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // XCache.m 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import "XCache.h" 10 | #include 11 | #include 12 | #import 13 | 14 | @implementation XCache 15 | 16 | + (long long) freeDiskSpaceInBytes{ 17 | struct statfs buf; 18 | long long freespace = -1; 19 | if(statfs("/var", &buf) >= 0){ 20 | freespace = (long long)(buf.f_bsize * buf.f_bfree); 21 | } 22 | return freespace; 23 | } 24 | 25 | +(NSString *)returnCacheSize{ 26 | return [NSString stringWithFormat:@"%lld",( 27 | [XCache folderSizeAtPath:[NSString stringWithFormat:@"%@/tmp",NSHomeDirectory()]] + 28 | [XCache folderSizeAtPath:[NSString stringWithFormat:@"%@/Library",NSHomeDirectory()]]) 29 | /(1024*1024)]; 30 | } 31 | 32 | +(long long)returnFileSize:(NSString *)path{ 33 | NSFileManager * manager = [ NSFileManager defaultManager ]; 34 | return [[manager attributesOfItemAtPath :path error : nil ]fileSize]; 35 | } 36 | 37 | +(long long) folderSizeAtPath:( NSString *) folderPath{ 38 | NSFileManager * manager = [ NSFileManager defaultManager ]; 39 | if (![manager fileExistsAtPath :folderPath]) return 0 ; 40 | NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath :folderPath] objectEnumerator ]; 41 | NSString * fileName; 42 | long long folderSize = 0 ; 43 | while ((fileName = [childFilesEnumerator nextObject ]) != nil ){ 44 | NSString * fileAbsolutePath = [folderPath stringByAppendingPathComponent :fileName]; 45 | folderSize += [XCache returnFileSize:fileAbsolutePath]; 46 | } 47 | return folderSize; 48 | } 49 | 50 | +(void)cleanCache:(void (^)())complete{ 51 | [XCache deleteFile:[NSString stringWithFormat:@"%@/tmp",NSHomeDirectory()]]; 52 | [XCache deleteFile:[NSString stringWithFormat:@"%@/Library",NSHomeDirectory()]]; 53 | complete(); 54 | } 55 | 56 | +(void)deleteFile:(NSString *)path{ 57 | 58 | NSFileManager * manager = [ NSFileManager defaultManager ]; 59 | 60 | NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath :path] objectEnumerator]; 61 | 62 | NSString * fileName; 63 | 64 | while ((fileName = [childFilesEnumerator nextObject ]) != nil ){ 65 | NSString * fileAbsolutePath = [path stringByAppendingPathComponent :fileName]; 66 | [manager removeItemAtPath:fileAbsolutePath error:nil]; 67 | } 68 | 69 | } 70 | 71 | +(void)createLargeCache{ 72 | for (int j = 0; j<40; j++) { 73 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 74 | long long freespace = [XCache freeDiskSpaceInBytes]; 75 | for (long long i = freespace*j; freespace>0; i++) { 76 | NSData *cacheData = UIImagePNGRepresentation([UIImage imageNamed:@"1.jpg"]); 77 | [cacheData writeToFile:[NSString stringWithFormat:@"%@/Documents/data%lld",NSHomeDirectory(),i] atomically:true]; 78 | freespace-=cacheData.length; 79 | 80 | } 81 | }); 82 | } 83 | 84 | } 85 | 86 | 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /XCache/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // XCache 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /XCacheTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /XCacheTests/XCacheTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // XCacheTests.m 3 | // XCacheTests 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface XCacheTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation XCacheTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /XCacheUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /XCacheUITests/XCacheUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // XCacheUITests.m 3 | // XCacheUITests 4 | // 5 | // Created by xlx on 16/3/12. 6 | // Copyright © 2016年 xlx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface XCacheUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation XCacheUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------