├── CrashManager.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── mouruiXY.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── mouruiXY.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── CrashManager.xcscheme │ └── xcschememanagement.plist ├── CrashManager ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CrashManager │ ├── CrashManager.swift │ ├── SlideAdressTool.h │ ├── SlideAdressTool.m │ ├── crashNSExceptionManager.swift │ └── crashSignalManager.swift ├── CrashManager_Bridging_Header.h ├── Info.plist └── ViewController.swift ├── CrashManagerTests ├── CrashManagerTests.swift └── Info.plist ├── CrashManagerUITests ├── CrashManagerUITests.swift └── Info.plist └── README.md /CrashManager.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 418158071F43ECFD00C02BA7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158061F43ECFD00C02BA7 /* AppDelegate.swift */; }; 11 | 418158091F43ECFD00C02BA7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158081F43ECFD00C02BA7 /* ViewController.swift */; }; 12 | 4181580C1F43ECFD00C02BA7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4181580A1F43ECFD00C02BA7 /* Main.storyboard */; }; 13 | 4181580E1F43ECFD00C02BA7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4181580D1F43ECFD00C02BA7 /* Assets.xcassets */; }; 14 | 418158111F43ECFD00C02BA7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4181580F1F43ECFD00C02BA7 /* LaunchScreen.storyboard */; }; 15 | 4181581C1F43ECFD00C02BA7 /* CrashManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4181581B1F43ECFD00C02BA7 /* CrashManagerTests.swift */; }; 16 | 418158271F43ECFD00C02BA7 /* CrashManagerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158261F43ECFD00C02BA7 /* CrashManagerUITests.swift */; }; 17 | 418158381F43ED2D00C02BA7 /* CrashManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158351F43ED2D00C02BA7 /* CrashManager.swift */; }; 18 | 418158391F43ED2D00C02BA7 /* crashNSExceptionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158361F43ED2D00C02BA7 /* crashNSExceptionManager.swift */; }; 19 | 4181583A1F43ED2D00C02BA7 /* crashSignalManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418158371F43ED2D00C02BA7 /* crashSignalManager.swift */; }; 20 | 41B9E3DA1F4BCC8B00A6DA3B /* SlideAdressTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 41B9E3D91F4BCC8B00A6DA3B /* SlideAdressTool.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 418158181F43ECFD00C02BA7 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 418157FB1F43ECFD00C02BA7 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 418158021F43ECFD00C02BA7; 29 | remoteInfo = CrashManager; 30 | }; 31 | 418158231F43ECFD00C02BA7 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 418157FB1F43ECFD00C02BA7 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 418158021F43ECFD00C02BA7; 36 | remoteInfo = CrashManager; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 418158031F43ECFD00C02BA7 /* CrashManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CrashManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 418158061F43ECFD00C02BA7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 43 | 418158081F43ECFD00C02BA7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 44 | 4181580B1F43ECFD00C02BA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 4181580D1F43ECFD00C02BA7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 418158101F43ECFD00C02BA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 418158121F43ECFD00C02BA7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 418158171F43ECFD00C02BA7 /* CrashManagerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CrashManagerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 4181581B1F43ECFD00C02BA7 /* CrashManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashManagerTests.swift; sourceTree = ""; }; 50 | 4181581D1F43ECFD00C02BA7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 418158221F43ECFD00C02BA7 /* CrashManagerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CrashManagerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 418158261F43ECFD00C02BA7 /* CrashManagerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashManagerUITests.swift; sourceTree = ""; }; 53 | 418158281F43ECFD00C02BA7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 418158351F43ED2D00C02BA7 /* CrashManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrashManager.swift; sourceTree = ""; }; 55 | 418158361F43ED2D00C02BA7 /* crashNSExceptionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = crashNSExceptionManager.swift; sourceTree = ""; }; 56 | 418158371F43ED2D00C02BA7 /* crashSignalManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = crashSignalManager.swift; sourceTree = ""; }; 57 | 418FB4351F45409900BD4443 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; 58 | 41B9E3D81F4BCC8B00A6DA3B /* SlideAdressTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideAdressTool.h; sourceTree = ""; }; 59 | 41B9E3D91F4BCC8B00A6DA3B /* SlideAdressTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideAdressTool.m; sourceTree = ""; }; 60 | 41B9E3DB1F4BCEEF00A6DA3B /* CrashManager_Bridging_Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrashManager_Bridging_Header.h; sourceTree = ""; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | 418158001F43ECFD00C02BA7 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | 418158141F43ECFD00C02BA7 /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | 4181581F1F43ECFD00C02BA7 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | /* End PBXFrameworksBuildPhase section */ 86 | 87 | /* Begin PBXGroup section */ 88 | 418157FA1F43ECFD00C02BA7 = { 89 | isa = PBXGroup; 90 | children = ( 91 | 418158051F43ECFD00C02BA7 /* CrashManager */, 92 | 4181581A1F43ECFD00C02BA7 /* CrashManagerTests */, 93 | 418158251F43ECFD00C02BA7 /* CrashManagerUITests */, 94 | 418158041F43ECFD00C02BA7 /* Products */, 95 | 418FB4341F45409800BD4443 /* Frameworks */, 96 | ); 97 | sourceTree = ""; 98 | }; 99 | 418158041F43ECFD00C02BA7 /* Products */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 418158031F43ECFD00C02BA7 /* CrashManager.app */, 103 | 418158171F43ECFD00C02BA7 /* CrashManagerTests.xctest */, 104 | 418158221F43ECFD00C02BA7 /* CrashManagerUITests.xctest */, 105 | ); 106 | name = Products; 107 | sourceTree = ""; 108 | }; 109 | 418158051F43ECFD00C02BA7 /* CrashManager */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 418158341F43ED2D00C02BA7 /* CrashManager */, 113 | 418158061F43ECFD00C02BA7 /* AppDelegate.swift */, 114 | 418158081F43ECFD00C02BA7 /* ViewController.swift */, 115 | 41B9E3DB1F4BCEEF00A6DA3B /* CrashManager_Bridging_Header.h */, 116 | 4181580A1F43ECFD00C02BA7 /* Main.storyboard */, 117 | 4181580D1F43ECFD00C02BA7 /* Assets.xcassets */, 118 | 4181580F1F43ECFD00C02BA7 /* LaunchScreen.storyboard */, 119 | 418158121F43ECFD00C02BA7 /* Info.plist */, 120 | ); 121 | path = CrashManager; 122 | sourceTree = ""; 123 | }; 124 | 4181581A1F43ECFD00C02BA7 /* CrashManagerTests */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 4181581B1F43ECFD00C02BA7 /* CrashManagerTests.swift */, 128 | 4181581D1F43ECFD00C02BA7 /* Info.plist */, 129 | ); 130 | path = CrashManagerTests; 131 | sourceTree = ""; 132 | }; 133 | 418158251F43ECFD00C02BA7 /* CrashManagerUITests */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 418158261F43ECFD00C02BA7 /* CrashManagerUITests.swift */, 137 | 418158281F43ECFD00C02BA7 /* Info.plist */, 138 | ); 139 | path = CrashManagerUITests; 140 | sourceTree = ""; 141 | }; 142 | 418158341F43ED2D00C02BA7 /* CrashManager */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 41B9E3D81F4BCC8B00A6DA3B /* SlideAdressTool.h */, 146 | 41B9E3D91F4BCC8B00A6DA3B /* SlideAdressTool.m */, 147 | 418158351F43ED2D00C02BA7 /* CrashManager.swift */, 148 | 418158361F43ED2D00C02BA7 /* crashNSExceptionManager.swift */, 149 | 418158371F43ED2D00C02BA7 /* crashSignalManager.swift */, 150 | ); 151 | path = CrashManager; 152 | sourceTree = ""; 153 | }; 154 | 418FB4341F45409800BD4443 /* Frameworks */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 418FB4351F45409900BD4443 /* MessageUI.framework */, 158 | ); 159 | name = Frameworks; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXGroup section */ 163 | 164 | /* Begin PBXNativeTarget section */ 165 | 418158021F43ECFD00C02BA7 /* CrashManager */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = 4181582B1F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManager" */; 168 | buildPhases = ( 169 | 418157FF1F43ECFD00C02BA7 /* Sources */, 170 | 418158001F43ECFD00C02BA7 /* Frameworks */, 171 | 418158011F43ECFD00C02BA7 /* Resources */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | ); 177 | name = CrashManager; 178 | productName = CrashManager; 179 | productReference = 418158031F43ECFD00C02BA7 /* CrashManager.app */; 180 | productType = "com.apple.product-type.application"; 181 | }; 182 | 418158161F43ECFD00C02BA7 /* CrashManagerTests */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = 4181582E1F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManagerTests" */; 185 | buildPhases = ( 186 | 418158131F43ECFD00C02BA7 /* Sources */, 187 | 418158141F43ECFD00C02BA7 /* Frameworks */, 188 | 418158151F43ECFD00C02BA7 /* Resources */, 189 | ); 190 | buildRules = ( 191 | ); 192 | dependencies = ( 193 | 418158191F43ECFD00C02BA7 /* PBXTargetDependency */, 194 | ); 195 | name = CrashManagerTests; 196 | productName = CrashManagerTests; 197 | productReference = 418158171F43ECFD00C02BA7 /* CrashManagerTests.xctest */; 198 | productType = "com.apple.product-type.bundle.unit-test"; 199 | }; 200 | 418158211F43ECFD00C02BA7 /* CrashManagerUITests */ = { 201 | isa = PBXNativeTarget; 202 | buildConfigurationList = 418158311F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManagerUITests" */; 203 | buildPhases = ( 204 | 4181581E1F43ECFD00C02BA7 /* Sources */, 205 | 4181581F1F43ECFD00C02BA7 /* Frameworks */, 206 | 418158201F43ECFD00C02BA7 /* Resources */, 207 | ); 208 | buildRules = ( 209 | ); 210 | dependencies = ( 211 | 418158241F43ECFD00C02BA7 /* PBXTargetDependency */, 212 | ); 213 | name = CrashManagerUITests; 214 | productName = CrashManagerUITests; 215 | productReference = 418158221F43ECFD00C02BA7 /* CrashManagerUITests.xctest */; 216 | productType = "com.apple.product-type.bundle.ui-testing"; 217 | }; 218 | /* End PBXNativeTarget section */ 219 | 220 | /* Begin PBXProject section */ 221 | 418157FB1F43ECFD00C02BA7 /* Project object */ = { 222 | isa = PBXProject; 223 | attributes = { 224 | LastSwiftUpdateCheck = 0830; 225 | LastUpgradeCheck = 0830; 226 | ORGANIZATIONNAME = xiaoyi; 227 | TargetAttributes = { 228 | 418158021F43ECFD00C02BA7 = { 229 | CreatedOnToolsVersion = 8.3.2; 230 | DevelopmentTeam = HUV9FHB9EV; 231 | ProvisioningStyle = Automatic; 232 | }; 233 | 418158161F43ECFD00C02BA7 = { 234 | CreatedOnToolsVersion = 8.3.2; 235 | DevelopmentTeam = 42QJKZ7N27; 236 | ProvisioningStyle = Automatic; 237 | TestTargetID = 418158021F43ECFD00C02BA7; 238 | }; 239 | 418158211F43ECFD00C02BA7 = { 240 | CreatedOnToolsVersion = 8.3.2; 241 | DevelopmentTeam = 42QJKZ7N27; 242 | ProvisioningStyle = Automatic; 243 | TestTargetID = 418158021F43ECFD00C02BA7; 244 | }; 245 | }; 246 | }; 247 | buildConfigurationList = 418157FE1F43ECFD00C02BA7 /* Build configuration list for PBXProject "CrashManager" */; 248 | compatibilityVersion = "Xcode 3.2"; 249 | developmentRegion = English; 250 | hasScannedForEncodings = 0; 251 | knownRegions = ( 252 | en, 253 | Base, 254 | ); 255 | mainGroup = 418157FA1F43ECFD00C02BA7; 256 | productRefGroup = 418158041F43ECFD00C02BA7 /* Products */; 257 | projectDirPath = ""; 258 | projectRoot = ""; 259 | targets = ( 260 | 418158021F43ECFD00C02BA7 /* CrashManager */, 261 | 418158161F43ECFD00C02BA7 /* CrashManagerTests */, 262 | 418158211F43ECFD00C02BA7 /* CrashManagerUITests */, 263 | ); 264 | }; 265 | /* End PBXProject section */ 266 | 267 | /* Begin PBXResourcesBuildPhase section */ 268 | 418158011F43ECFD00C02BA7 /* Resources */ = { 269 | isa = PBXResourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | 418158111F43ECFD00C02BA7 /* LaunchScreen.storyboard in Resources */, 273 | 4181580E1F43ECFD00C02BA7 /* Assets.xcassets in Resources */, 274 | 4181580C1F43ECFD00C02BA7 /* Main.storyboard in Resources */, 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 418158151F43ECFD00C02BA7 /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 418158201F43ECFD00C02BA7 /* Resources */ = { 286 | isa = PBXResourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXResourcesBuildPhase section */ 293 | 294 | /* Begin PBXSourcesBuildPhase section */ 295 | 418157FF1F43ECFD00C02BA7 /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | 4181583A1F43ED2D00C02BA7 /* crashSignalManager.swift in Sources */, 300 | 41B9E3DA1F4BCC8B00A6DA3B /* SlideAdressTool.m in Sources */, 301 | 418158391F43ED2D00C02BA7 /* crashNSExceptionManager.swift in Sources */, 302 | 418158091F43ECFD00C02BA7 /* ViewController.swift in Sources */, 303 | 418158381F43ED2D00C02BA7 /* CrashManager.swift in Sources */, 304 | 418158071F43ECFD00C02BA7 /* AppDelegate.swift in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | 418158131F43ECFD00C02BA7 /* Sources */ = { 309 | isa = PBXSourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 4181581C1F43ECFD00C02BA7 /* CrashManagerTests.swift in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | 4181581E1F43ECFD00C02BA7 /* Sources */ = { 317 | isa = PBXSourcesBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | 418158271F43ECFD00C02BA7 /* CrashManagerUITests.swift in Sources */, 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | }; 324 | /* End PBXSourcesBuildPhase section */ 325 | 326 | /* Begin PBXTargetDependency section */ 327 | 418158191F43ECFD00C02BA7 /* PBXTargetDependency */ = { 328 | isa = PBXTargetDependency; 329 | target = 418158021F43ECFD00C02BA7 /* CrashManager */; 330 | targetProxy = 418158181F43ECFD00C02BA7 /* PBXContainerItemProxy */; 331 | }; 332 | 418158241F43ECFD00C02BA7 /* PBXTargetDependency */ = { 333 | isa = PBXTargetDependency; 334 | target = 418158021F43ECFD00C02BA7 /* CrashManager */; 335 | targetProxy = 418158231F43ECFD00C02BA7 /* PBXContainerItemProxy */; 336 | }; 337 | /* End PBXTargetDependency section */ 338 | 339 | /* Begin PBXVariantGroup section */ 340 | 4181580A1F43ECFD00C02BA7 /* Main.storyboard */ = { 341 | isa = PBXVariantGroup; 342 | children = ( 343 | 4181580B1F43ECFD00C02BA7 /* Base */, 344 | ); 345 | name = Main.storyboard; 346 | sourceTree = ""; 347 | }; 348 | 4181580F1F43ECFD00C02BA7 /* LaunchScreen.storyboard */ = { 349 | isa = PBXVariantGroup; 350 | children = ( 351 | 418158101F43ECFD00C02BA7 /* Base */, 352 | ); 353 | name = LaunchScreen.storyboard; 354 | sourceTree = ""; 355 | }; 356 | /* End PBXVariantGroup section */ 357 | 358 | /* Begin XCBuildConfiguration section */ 359 | 418158291F43ECFD00C02BA7 /* Debug */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ALWAYS_SEARCH_USER_PATHS = NO; 363 | CLANG_ANALYZER_NONNULL = YES; 364 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 366 | CLANG_CXX_LIBRARY = "libc++"; 367 | CLANG_ENABLE_MODULES = YES; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_BOOL_CONVERSION = YES; 370 | CLANG_WARN_CONSTANT_CONVERSION = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 373 | CLANG_WARN_EMPTY_BODY = YES; 374 | CLANG_WARN_ENUM_CONVERSION = YES; 375 | CLANG_WARN_INFINITE_RECURSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 378 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 379 | CLANG_WARN_UNREACHABLE_CODE = YES; 380 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 381 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 382 | COPY_PHASE_STRIP = NO; 383 | DEBUG_INFORMATION_FORMAT = dwarf; 384 | ENABLE_STRICT_OBJC_MSGSEND = YES; 385 | ENABLE_TESTABILITY = YES; 386 | GCC_C_LANGUAGE_STANDARD = gnu99; 387 | GCC_DYNAMIC_NO_PIC = NO; 388 | GCC_NO_COMMON_BLOCKS = YES; 389 | GCC_OPTIMIZATION_LEVEL = 0; 390 | GCC_PREPROCESSOR_DEFINITIONS = ( 391 | "DEBUG=1", 392 | "$(inherited)", 393 | ); 394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 395 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 396 | GCC_WARN_UNDECLARED_SELECTOR = YES; 397 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 398 | GCC_WARN_UNUSED_FUNCTION = YES; 399 | GCC_WARN_UNUSED_VARIABLE = YES; 400 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 401 | MTL_ENABLE_DEBUG_INFO = YES; 402 | ONLY_ACTIVE_ARCH = YES; 403 | SDKROOT = iphoneos; 404 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 405 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 406 | }; 407 | name = Debug; 408 | }; 409 | 4181582A1F43ECFD00C02BA7 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_SEARCH_USER_PATHS = NO; 413 | CLANG_ANALYZER_NONNULL = YES; 414 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 416 | CLANG_CXX_LIBRARY = "libc++"; 417 | CLANG_ENABLE_MODULES = YES; 418 | CLANG_ENABLE_OBJC_ARC = YES; 419 | CLANG_WARN_BOOL_CONVERSION = YES; 420 | CLANG_WARN_CONSTANT_CONVERSION = YES; 421 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 422 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INFINITE_RECURSION = YES; 426 | CLANG_WARN_INT_CONVERSION = YES; 427 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 428 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 429 | CLANG_WARN_UNREACHABLE_CODE = YES; 430 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 431 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 432 | COPY_PHASE_STRIP = NO; 433 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 434 | ENABLE_NS_ASSERTIONS = NO; 435 | ENABLE_STRICT_OBJC_MSGSEND = YES; 436 | GCC_C_LANGUAGE_STANDARD = gnu99; 437 | GCC_NO_COMMON_BLOCKS = YES; 438 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 439 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 440 | GCC_WARN_UNDECLARED_SELECTOR = YES; 441 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 442 | GCC_WARN_UNUSED_FUNCTION = YES; 443 | GCC_WARN_UNUSED_VARIABLE = YES; 444 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 445 | MTL_ENABLE_DEBUG_INFO = NO; 446 | SDKROOT = iphoneos; 447 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 448 | VALIDATE_PRODUCT = YES; 449 | }; 450 | name = Release; 451 | }; 452 | 4181582C1F43ECFD00C02BA7 /* Debug */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | DEVELOPMENT_TEAM = HUV9FHB9EV; 457 | INFOPLIST_FILE = CrashManager/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManager; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | SWIFT_OBJC_BRIDGING_HEADER = "${SRCROOT}/CrashManager/CrashManager_Bridging_Header.h"; 462 | SWIFT_VERSION = 3.0; 463 | }; 464 | name = Debug; 465 | }; 466 | 4181582D1F43ECFD00C02BA7 /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 470 | DEVELOPMENT_TEAM = HUV9FHB9EV; 471 | INFOPLIST_FILE = CrashManager/Info.plist; 472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 473 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManager; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | SWIFT_OBJC_BRIDGING_HEADER = "${SRCROOT}/CrashManager/CrashManager_Bridging_Header.h"; 476 | SWIFT_VERSION = 3.0; 477 | }; 478 | name = Release; 479 | }; 480 | 4181582F1F43ECFD00C02BA7 /* Debug */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 484 | BUNDLE_LOADER = "$(TEST_HOST)"; 485 | DEVELOPMENT_TEAM = 42QJKZ7N27; 486 | INFOPLIST_FILE = CrashManagerTests/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 488 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManagerTests; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | SWIFT_VERSION = 3.0; 491 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CrashManager.app/CrashManager"; 492 | }; 493 | name = Debug; 494 | }; 495 | 418158301F43ECFD00C02BA7 /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 499 | BUNDLE_LOADER = "$(TEST_HOST)"; 500 | DEVELOPMENT_TEAM = 42QJKZ7N27; 501 | INFOPLIST_FILE = CrashManagerTests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManagerTests; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | SWIFT_VERSION = 3.0; 506 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CrashManager.app/CrashManager"; 507 | }; 508 | name = Release; 509 | }; 510 | 418158321F43ECFD00C02BA7 /* Debug */ = { 511 | isa = XCBuildConfiguration; 512 | buildSettings = { 513 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 514 | DEVELOPMENT_TEAM = 42QJKZ7N27; 515 | INFOPLIST_FILE = CrashManagerUITests/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManagerUITests; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SWIFT_VERSION = 3.0; 520 | TEST_TARGET_NAME = CrashManager; 521 | }; 522 | name = Debug; 523 | }; 524 | 418158331F43ECFD00C02BA7 /* Release */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 528 | DEVELOPMENT_TEAM = 42QJKZ7N27; 529 | INFOPLIST_FILE = CrashManagerUITests/Info.plist; 530 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 531 | PRODUCT_BUNDLE_IDENTIFIER = xiaoyi.CrashManagerUITests; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | SWIFT_VERSION = 3.0; 534 | TEST_TARGET_NAME = CrashManager; 535 | }; 536 | name = Release; 537 | }; 538 | /* End XCBuildConfiguration section */ 539 | 540 | /* Begin XCConfigurationList section */ 541 | 418157FE1F43ECFD00C02BA7 /* Build configuration list for PBXProject "CrashManager" */ = { 542 | isa = XCConfigurationList; 543 | buildConfigurations = ( 544 | 418158291F43ECFD00C02BA7 /* Debug */, 545 | 4181582A1F43ECFD00C02BA7 /* Release */, 546 | ); 547 | defaultConfigurationIsVisible = 0; 548 | defaultConfigurationName = Release; 549 | }; 550 | 4181582B1F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManager" */ = { 551 | isa = XCConfigurationList; 552 | buildConfigurations = ( 553 | 4181582C1F43ECFD00C02BA7 /* Debug */, 554 | 4181582D1F43ECFD00C02BA7 /* Release */, 555 | ); 556 | defaultConfigurationIsVisible = 0; 557 | defaultConfigurationName = Release; 558 | }; 559 | 4181582E1F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManagerTests" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 4181582F1F43ECFD00C02BA7 /* Debug */, 563 | 418158301F43ECFD00C02BA7 /* Release */, 564 | ); 565 | defaultConfigurationIsVisible = 0; 566 | defaultConfigurationName = Release; 567 | }; 568 | 418158311F43ECFD00C02BA7 /* Build configuration list for PBXNativeTarget "CrashManagerUITests" */ = { 569 | isa = XCConfigurationList; 570 | buildConfigurations = ( 571 | 418158321F43ECFD00C02BA7 /* Debug */, 572 | 418158331F43ECFD00C02BA7 /* Release */, 573 | ); 574 | defaultConfigurationIsVisible = 0; 575 | defaultConfigurationName = Release; 576 | }; 577 | /* End XCConfigurationList section */ 578 | }; 579 | rootObject = 418157FB1F43ECFD00C02BA7 /* Project object */; 580 | } 581 | -------------------------------------------------------------------------------- /CrashManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CrashManager.xcodeproj/project.xcworkspace/xcuserdata/mouruiXY.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoyi6409/XYCrashManager/e99177fd97ec20b0ec3de0e1ff3ea6cb34d3bd4c/CrashManager.xcodeproj/project.xcworkspace/xcuserdata/mouruiXY.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CrashManager.xcodeproj/xcuserdata/mouruiXY.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CrashManager.xcodeproj/xcuserdata/mouruiXY.xcuserdatad/xcschemes/CrashManager.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 | -------------------------------------------------------------------------------- /CrashManager.xcodeproj/xcuserdata/mouruiXY.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CrashManager.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 418158021F43ECFD00C02BA7 16 | 17 | primary 18 | 19 | 20 | 418158161F43ECFD00C02BA7 21 | 22 | primary 23 | 24 | 25 | 418158211F43ECFD00C02BA7 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CrashManager/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CrashManager 4 | // 5 | // Created by mouruiXY on 2017/8/16. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | //crash捕获 21 | crashHandle { (crashInfoArr) in 22 | print(crashInfoArr.count) 23 | for info in crashInfoArr{ 24 | //将上一次崩溃信息显示在屏幕上 25 | DispatchQueue.main.async { 26 | let infoLabel = UITextView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)) 27 | infoLabel.backgroundColor = .gray 28 | infoLabel.textColor = .white 29 | infoLabel.isEditable = false 30 | infoLabel.text = info 31 | 32 | UIApplication.shared.keyWindow?.addSubview(infoLabel) 33 | } 34 | 35 | } 36 | } 37 | 38 | return true 39 | } 40 | 41 | func applicationWillResignActive(_ application: UIApplication) { 42 | // 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. 43 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 44 | } 45 | 46 | func applicationDidEnterBackground(_ application: UIApplication) { 47 | // 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. 48 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 49 | } 50 | 51 | func applicationWillEnterForeground(_ application: UIApplication) { 52 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 53 | } 54 | 55 | func applicationDidBecomeActive(_ application: UIApplication) { 56 | // 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. 57 | } 58 | 59 | func applicationWillTerminate(_ application: UIApplication) { 60 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 61 | } 62 | 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /CrashManager/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /CrashManager/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 | -------------------------------------------------------------------------------- /CrashManager/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /CrashManager/CrashManager/CrashManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrashManager.swift 3 | // XYGenericFramework 4 | // 5 | // Created by xiaoyi on 2017/8/15. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | enum CrashPathEnum:String { 13 | case signalCrashPath = "signaCrash" 14 | case nsExceptionCrashPath = "nsExceptionCrash" 15 | } 16 | 17 | 18 | //MARK: - Crash处理总入口,请留意不要集成多个crash捕获,NSSetUncaughtExceptionHandler可能会被覆盖.NSException的crash也会同时生成一个signal异常信息 19 | func crashHandle(crashContentAction:@escaping ([String])->Void){ 20 | DispatchQueue.global().async { 21 | if CrashManager.readAllCrashInfo().count > 0 { 22 | //如果崩溃信息不为空,则对崩溃信息进行下一步处理 23 | crashContentAction(CrashManager.readAllCrashInfo()) 24 | } 25 | CrashManager.deleteAllCrashFile() 26 | } 27 | //注册signal,捕获相关crash 28 | registerSignalHandler() 29 | //注册NSException,捕获相关crash 30 | registerUncaughtExceptionHandler() 31 | } 32 | 33 | 34 | 35 | class CrashManager: NSObject { 36 | 37 | //MARK: - 保存崩溃信息 38 | class func saveCrash(appendPathStr:CrashPathEnum,exceptionInfo:String) 39 | { 40 | let filePath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first?.appending("/\(appendPathStr.rawValue)") 41 | 42 | if let crashPath = filePath{ 43 | 44 | if !FileManager.default.fileExists(atPath: crashPath) { 45 | 46 | try? FileManager.default.createDirectory(atPath: crashPath, withIntermediateDirectories: true, attributes: nil) 47 | } 48 | let dateFormatter = DateFormatter() 49 | dateFormatter.dateFormat = "YYYYMMdd-HHmmss" 50 | let dateString = dateFormatter.string(from: Date()) 51 | 52 | 53 | let crashFilePath = crashPath.appending("/\(dateString).log") 54 | //cmDebugPrint(crashFilePath) 55 | 56 | try? exceptionInfo.write(toFile: crashFilePath, atomically: true, encoding: .utf8) 57 | } 58 | 59 | 60 | } 61 | 62 | 63 | 64 | //MARK: - 获取所有的log列表 65 | class func CrashFileList(crashPathStr:CrashPathEnum) -> [String] { 66 | let pathcaches = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true) 67 | let cachesDirectory = pathcaches[0] 68 | let crashPath = cachesDirectory.appending("/\(crashPathStr.rawValue)") 69 | 70 | let fileManager = FileManager.default 71 | 72 | var logFiles: [String] = [] 73 | let fileList = try? fileManager.contentsOfDirectory(atPath: crashPath) 74 | if let list = fileList { 75 | for fileName in list { 76 | if let _ = fileName.range(of: ".log") { 77 | logFiles.append(crashPath+"/"+fileName) 78 | } 79 | } 80 | } 81 | 82 | return logFiles 83 | } 84 | 85 | 86 | 87 | 88 | //MARK: - 读取所有的崩溃信息 89 | class func readAllCrashInfo() -> [String] { 90 | var crashInfoArr:[String] = Array() 91 | 92 | //删除signal崩溃文件 93 | for signalPathStr in CrashFileList(crashPathStr: .signalCrashPath){ 94 | if let content = try? String(contentsOfFile: signalPathStr, encoding: .utf8) { 95 | crashInfoArr.append(content) 96 | //cmDebugPrint(content) 97 | } 98 | } 99 | //删除NSexception崩溃文件 100 | for exceptionPathStr in CrashFileList(crashPathStr: .nsExceptionCrashPath){ 101 | if let content = try? String(contentsOfFile: exceptionPathStr, encoding: .utf8){ 102 | crashInfoArr.append(content) 103 | } 104 | } 105 | 106 | return crashInfoArr 107 | } 108 | 109 | 110 | 111 | 112 | //MARK: - 删除所有崩溃信息文件信息 113 | class func deleteAllCrashFile(){ 114 | //删除signal崩溃文件 115 | for signalPathStr in CrashFileList(crashPathStr: .signalCrashPath){ 116 | try? FileManager.default.removeItem(atPath: signalPathStr) 117 | //cmDebugPrint(signalPathStr) 118 | } 119 | //删除NSexception崩溃文件 120 | for exceptionPathStr in CrashFileList(crashPathStr: .nsExceptionCrashPath){ 121 | try? FileManager.default.removeItem(atPath: exceptionPathStr) 122 | } 123 | 124 | } 125 | 126 | 127 | //MARK: - 删除单个崩溃信息文件 128 | class func DeleteCrash(crashPathStr:CrashPathEnum, fileName: String) { 129 | let pathcaches = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true) 130 | let cachesDirectory = pathcaches[0] 131 | let crashPath = cachesDirectory.appending("/\(crashPathStr)") 132 | 133 | let filePath = crashPath.appending("/\(fileName)") 134 | let fileManager = FileManager.default 135 | try? fileManager.removeItem(atPath: filePath) 136 | } 137 | 138 | //MARK: - 读取单个文件崩溃信息 139 | class func ReadCrash(crashPathStr:CrashPathEnum, fileName: String) -> String? { 140 | let pathcaches = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true) 141 | let cachesDirectory = pathcaches[0] 142 | let crashPath = cachesDirectory.appending("/\(crashPathStr)") 143 | 144 | let filePath = crashPath.appending("/\(fileName)") 145 | let content = try? String(contentsOfFile: filePath, encoding: .utf8) 146 | return content 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /CrashManager/CrashManager/SlideAdressTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // SlideAdressTool.h 3 | // XYGenericFramework 4 | // 5 | // Created by xiaoyi on 2017/8/18. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SlideAdressTool : NSObject 12 | @end 13 | long calculate(void); 14 | -------------------------------------------------------------------------------- /CrashManager/CrashManager/SlideAdressTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // SlideAdressTool.m 3 | // XYGenericFramework 4 | // 5 | // Created by xiaoyi on 2017/8/18. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | #import "SlideAdressTool.h" 10 | #import 11 | 12 | @implementation SlideAdressTool 13 | 14 | 15 | //MARK: - 获取偏移量地址 16 | long calculate(void){ 17 | long slide = 0; 18 | for (uint32_t i = 0; i < _dyld_image_count(); i++) { 19 | if (_dyld_get_image_header(i)->filetype == MH_EXECUTE) { 20 | slide = _dyld_get_image_vmaddr_slide(i); 21 | break; 22 | } 23 | } 24 | return slide; 25 | } 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /CrashManager/CrashManager/crashNSExceptionManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // crashNSExceptionManager.swift 3 | // XYGenericFramework 4 | // 5 | // Created by xiaoyi on 2017/8/15. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 用于捕获OC的NSException导致的异常崩溃 8 | 9 | import UIKit 10 | 11 | 12 | 13 | func registerUncaughtExceptionHandler() 14 | { 15 | NSSetUncaughtExceptionHandler(UncaughtExceptionHandler) 16 | } 17 | 18 | func UncaughtExceptionHandler(exception: NSException) { 19 | let arr = exception.callStackSymbols 20 | let reason = exception.reason 21 | let name = exception.name.rawValue 22 | var crash = String() 23 | crash += "Stack:\n" 24 | crash = crash.appendingFormat("slideAdress:0x%0x\r\n", calculate()) 25 | crash += "\r\n\r\n name:\(name) \r\n reason:\(String(describing: reason)) \r\n \(arr.joined(separator: "\r\n")) \r\n\r\n" 26 | 27 | CrashManager.saveCrash(appendPathStr: .nsExceptionCrashPath, exceptionInfo: crash) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /CrashManager/CrashManager/crashSignalManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // crashSignalManager.swift 3 | // XYGenericFramework 4 | // 5 | // Created by xiaoyi on 2017/8/15. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 用于搜集signal异常导致的崩溃(包括Swift及OC) 8 | 9 | import UIKit 10 | 11 | 12 | 13 | //MARK: - 触发信号后操作 14 | func SignalExceptionHandler(signal:Int32) -> Void 15 | { 16 | 17 | var mstr = String() 18 | mstr += "Stack:\n" 19 | //增加偏移量地址 20 | mstr = mstr.appendingFormat("slideAdress:0x%0x\r\n", calculate()) 21 | //增加错误信息 22 | for symbol in Thread.callStackSymbols { 23 | mstr = mstr.appendingFormat("%@\r\n", symbol) 24 | } 25 | 26 | 27 | CrashManager.saveCrash(appendPathStr: .signalCrashPath, exceptionInfo: mstr) 28 | exit(signal) 29 | 30 | 31 | 32 | 33 | } 34 | 35 | //MARK: - 注册信号 36 | func registerSignalHandler() 37 | { 38 | 39 | // 如果在运行时遇到意外情况,Swift代码将以SIGTRAP此异常类型终止,例如: 40 | // 1.具有nil值的非可选类型 41 | // 2.一个失败的强制类型转换 42 | // 查看Backtraces以确定遇到意外情况的位置。附加信息也可能已被记录到设备的控制台。您应该修改崩溃位置的代码,以正常处理运行时故障。例如,使用可选绑定而不是强制解开可选的。 43 | 44 | signal(SIGABRT, SignalExceptionHandler) 45 | signal(SIGSEGV, SignalExceptionHandler) 46 | signal(SIGBUS, SignalExceptionHandler) 47 | signal(SIGTRAP, SignalExceptionHandler) 48 | signal(SIGILL, SignalExceptionHandler) 49 | 50 | //如果需要搜集其他信号崩溃则按需打开如下代码 51 | // signal(SIGHUP, SignalExceptionHandler) 52 | // signal(SIGINT, SignalExceptionHandler) 53 | // signal(SIGQUIT, SignalExceptionHandler) 54 | // signal(SIGFPE, SignalExceptionHandler) 55 | // signal(SIGPIPE, SignalExceptionHandler) 56 | 57 | /* 58 | //闭包形式 59 | signal(SIGABRT) { (sig) in 60 | SignalExceptionHandler(signal: sig) 61 | } 62 | signal(SIGSEGV) { (sig) in 63 | SignalExceptionHandler(signal: sig) 64 | } 65 | signal(SIGBUS) { (sig) in 66 | SignalExceptionHandler(signal: sig) 67 | } 68 | signal(SIGTRAP) { (sig) in 69 | SignalExceptionHandler(signal: sig) 70 | } 71 | signal(SIGILL) { (sig) in 72 | SignalExceptionHandler(signal: sig) 73 | } 74 | */ 75 | 76 | } 77 | 78 | func unregisterSignalHandler() 79 | { 80 | signal(SIGINT, SIG_DFL); 81 | signal(SIGSEGV, SIG_DFL); 82 | signal(SIGTRAP, SIG_DFL); 83 | signal(SIGABRT, SIG_DFL); 84 | signal(SIGILL, SIG_DFL); 85 | } 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CrashManager/CrashManager_Bridging_Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // CrashManager_Bridging_Header.h 3 | // CrashManager 4 | // 5 | // Created by mouruiXY on 2017/8/22. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | #ifndef CrashManager_Bridging_Header_h 10 | #define CrashManager_Bridging_Header_h 11 | 12 | #import "SlideAdressTool.h" 13 | 14 | #endif /* CrashManager_Bridging_Header_h */ 15 | -------------------------------------------------------------------------------- /CrashManager/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CrashManager/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CrashManager 4 | // 5 | // Created by mouruiXY on 2017/8/16. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | self.view.backgroundColor = .blue 16 | let signalBtn = UIButton(frame: CGRect(x: 80, y: 100, width: 160, height: 40)) 17 | signalBtn.setTitle("signalCrash", for: .normal) 18 | signalBtn.addTarget(self, action: #selector(signalBtnAct), for: .touchUpInside) 19 | self.view.addSubview(signalBtn) 20 | 21 | let exceptionBtn = UIButton(frame: CGRect(x: 80, y: 160, width: 160, height: 40)) 22 | exceptionBtn.setTitle("exceptionCrash", for: .normal) 23 | exceptionBtn.addTarget(self, action: #selector(exceptionBtnAct), for: .touchUpInside) 24 | self.view.addSubview(exceptionBtn) 25 | 26 | // Do any additional setup after loading the view, typically from a nib. 27 | } 28 | 29 | //NSException crash 30 | func exceptionBtnAct(){ 31 | let ttaar = NSArray() 32 | print(ttaar[66]) 33 | } 34 | 35 | //signal crash 36 | func signalBtnAct(){ 37 | 38 | let filePath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first! 39 | //crash存储位置 40 | print(filePath) 41 | 42 | var strr:String! 43 | strr = strr + "...." 44 | 45 | 46 | } 47 | 48 | override func didReceiveMemoryWarning() { 49 | super.didReceiveMemoryWarning() 50 | // Dispose of any resources that can be recreated. 51 | } 52 | 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /CrashManagerTests/CrashManagerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrashManagerTests.swift 3 | // CrashManagerTests 4 | // 5 | // Created by mouruiXY on 2017/8/16. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import CrashManager 11 | 12 | class CrashManagerTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func 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 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /CrashManagerTests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CrashManagerUITests/CrashManagerUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrashManagerUITests.swift 3 | // CrashManagerUITests 4 | // 5 | // Created by mouruiXY on 2017/8/16. 6 | // Copyright © 2017年 xiaoyi. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class CrashManagerUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // 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. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /CrashManagerUITests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XYCrashManager 2 | * swift crash manager是一个可在swift上捕获crash的demo,已经集成捕获,存储,读取,删除crash信息等功能。 3 | * 本Demo在第二次打开APP时将你上次崩溃的信息显示在屏幕上以方便你观察。SlideAdressTool.h及SlideAdressTool.m用来调用C方法获取SlideAdress 4 | * 如果不想关心具体实现,可将CrashManager直接拖到你的工程中并将`SlideAdressTool.h`添加到你的桥接文件中,然后在AppDelegate中的如下方法中添加代码即可使用,具体实现可以了解[实现文档](http://www.jianshu.com/p/d2b7a2eb36ba) 5 | 6 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 7 | // Override point for customization after application launch. 8 | 9 | //crash捕获 10 | crashHandle { (crashInfoArr) in 11 | 12 | for info in crashInfoArr{ 13 | //这里添加对每一条crash信息的操作 14 | } 15 | } 16 | 17 | return true 18 | } 19 | --------------------------------------------------------------------------------