Simple book transfer 2020.10.28

Anomaly detection is needed in the project

LSSafeProtector

LSSafeProtector is a fast integrated but powerful crash prevention library, does not change the original code support KVO self-release, can detect dealloc when the KVO was not released, etc. 19 kinds of crash, written in Objective-C.

/ / note that must be set to NO) online environment isDebug [LSSafeProtector openSafeProtectorWithIsDebug: YES block: ^ (NSException * exception, LSSafeProtectorCrashType crashType) {[Bugly reportException: exception); / / the method relative to the above methods, advantage Bugly background check bug collapse, don't click on the tracking data, And then crash_attach.log, See the inside of the additional information to view the crash position [Bugly reportExceptionWithCategory: 3 name: exception. The name "reason: [nsstrings stringWithFormat: @" % @ Breakdown location: % @ ", the exception. "reason, exception. The userInfo [@" location "]] callStack: @ [exception. The userInfo [@ "callStackSymbols"]] extraInfo:exception.userInfo terminateApp:NO]; }]; // Open KVO add, remove log information [LSSafeProtector setLogEnable:YES]; [Bugly startWithAppId:@"5c825b6c8d"];Copy the code

Note: [Bugly reportExceptionWithCategory:3 name:exception.name reason:[NSString stringWithFormat:@”%@ Breakdown location: % @ “, the exception. “reason, exception. The userInfo [@” location “]] callStack: @ [exception. The userInfo [@ “callStackSymbols”]] extraInfo:exception.userInfo terminateApp:NO];

  1. Distribution in IPA packages (e.gThe dandelion), will not be able to obtain the error location, the official introduction isSince the crash log of ipA package installation is non-source code, it cannot be directly analyzed and located, and must be symbolized. The Xcode installation is the source installation.
  2. Bugly’s manually uploaded symbol table is also unresolvable in this custom reporting case.
  3. The advantage is that it is very friendly to beginners and can prompt the location of bugs, while the disadvantage is the above two problems.[Bugly reportException:exception];Relatively, full stack information is available and, importantly, manual uploading of the symbol table is supported.
  4. Another advantage is that Bugly will classify bugs, so there will be no obvious warning when the problem marked solved appears again, and the filtering and searching are somewhat inaccurate, which need to be searched one by one.

Bugly

Tencent Bugly provides mobile developers with professional abnormal reporting and operation statistics to help developers quickly find and solve anomalies, and at the same time, master the operation dynamics of products and timely follow up user feedback.

Why configure symbol tables? In order to quickly and accurately locate the code location where APP Crash occurred, Bugly used symbol table to parse and restore the program stack where APP Crash occurred.

Here’s an example:

Symbol Table Configuration (iOS only)

The official automatic configuration is recommended

Note:

  1. Download the symbol table extraction kitbuglySymbolIOS.jarIt must be stored in the bin directory of the Home directory (no bin folder, please create your own).Tips:This kit needs to be configured when changing PCS to pack
  2. Symbol table upload scriptdSYMUpload.shAccording to the official tutorial configuration into the project, need to modify their ownAPP_IDWait for information to complete these two items to complete the configuration of Bugly.Tips:You can customize the lookupbuglySymbolIOS.jar Package directory as wellDEBUGMode Whether to upload.
  3. The number of bugs reported is unverifiable, with varying degrees of delay. (Of course, general projects do not have a large number of bugs, unlike our company a dozen bugs every day, hundreds of abnormal records 🙄)
  4. DSYM symbol table file upload is not necessarily successful !!!!

The symbol table is manually uploaded

The main purpose of manual upload using the symbol table is to aid in parsing stack information in case automatic upload fails. There are several ways to obtain DSYM files, but for now only the symbol table for the published version (that is, after Archive) is covered.

  1. A certain version is inArchive After (or In Xcode’s Window Organizer) select Show In Finder.xcarchiveFile, right – click to display package contents
  2. indSYMs Find the dSYM file for the project name in the folder
  3. Upload it on the symbol table management page of the Bugly page. After the upload is complete, the resolved stack information of the problem of the corresponding version can be seen.
  4. In addition, if you cannot determine whether the version of the dSYM file is the same as that of the dSYM file, go to the fault information page and check whether the UUID is the same as that of the dSYM file. Query the UUID of a local dSYM file:Xcrun dwarfdump --uuid <dSYM file >

In conclusion, the combination of these two tools is a great way to protect our software as well as locate and solve bugs. Purely personal experience, the use of the process is unavoidably biased, if there is a mistake, hope correct.