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];
- Distribution in IPA packages (e.g
The 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.
- Bugly’s manually uploaded symbol table is also unresolvable in this custom reporting case.
- 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. - 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:
- Download the symbol table extraction kit
buglySymbolIOS.jar
It 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 - Symbol table upload script
dSYMUpload.sh
According to the official tutorial configuration into the project, need to modify their ownAPP_ID
Wait for information to complete these two items to complete the configuration of Bugly.Tips:
You can customize the lookupbuglySymbolIOS.jar
Package directory as wellDEBUG
Mode Whether to upload. - 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 🙄)
- 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.
- A certain version is in
Archive
After (or In Xcode’s Window Organizer) select Show In Finder.xcarchive
File, right – click to display package contents - in
dSYMs
Find the dSYM file for the project name in the folder - 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.
- 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.