iOS集成Bugly异常上报功能

1.在Bugly官网注册账号,实名认证并通过审核。
2.创建你的移动端产品,拿到AppID和AppKey。
3.集成SDK:
  • 这里不在赘述,我使用cocoapods安装;
    先看-官方文档入口
4.符号表:
  • 没有安装java sdk的,先去Oracle官网下载;
  • 这里我走的是自动配置:XCode + sh脚本;
    先看-官方文档入口
5.上传符号表:

5.1. 自动配置会让你在打包的时候生成对应的符号表:

  • 但是并不会自动上传到bugly网站中你账号底下对应的产品的符号表管理中;


    image.png
image.png

5.2. 使用官方提供的curl命令上传符号表:

  • 注意,这里我已经cd到了dYSM所在目录,如上图中目录;
  • 在目录中执行curl命令,命令为:
curl -k "https://api.bugly.qq.com/openapi/file/upload/symbol" --form "api_version=1" --form "app_id=cf65bdb747" --form "app_key=73ac837b-8399-49f5-8e70-1b59e7316973" --form "symbolType=2"  --form "bundleId=com.demo.buglytestdemoo" --form "productVersion=1.0.1" --form "fileName=D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM" --form "[email protected]" --verbose
  • 始终上传不了,请求出401或500或{"rtcode":"40401", msg: "server exception"},查阅了资料最终也未能解决问题;
☁  dSYMs  curl -k "https://api.bugly.qq.com/openapi/file/upload/symbol" --form "api_version=1" --form "app_id=cf65bdb747" --form "app_key=73ac837b-8399-49f5-8e70-1b59e7316973" --form "symbolType=2"  --form "bundleId=com.demo.buglytestdemoo" --form "productVersion=1.0.1" --form "fileName=D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM" --form "[email protected]" --verbose
*   Trying 183.194.234.212...
* TCP_NODELAY set
* Connected to api.bugly.qq.com (183.194.234.212) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=CN; ST=guangdong; L=shenzhen; O=Tencent Technology (Shenzhen) Company Limited; CN=*.sept03.sparta.3g.qq.com
*  start date: Sep  3 12:15:35 2021 GMT
*  expire date: Oct  5 12:15:35 2022 GMT
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2
*  SSL certificate verify ok.
> POST /openapi/file/upload/symbol HTTP/1.1
> Host: api.bugly.qq.com
> User-Agent: curl/7.64.1
> Accept: */*
> Transfer-Encoding: chunked
> Content-Type: multipart/form-data; boundary=------------------------bb3d4aa3a86e4290
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* Signaling end of chunked upload via terminating chunk.
< HTTP/1.1 401 Unauthorized
< Server: nginx
< Date: Tue, 22 Feb 2022 08:30:42 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 158
< Connection: keep-alive
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Mon, 21-Feb-2022 08:30:42 GMT
<

401 Unauthorized

401 Unauthorized


Resin/4.0.27 Server: 'app-0' * Connection #0 to host api.bugly.qq.com left intact * Closing connection 0 ☁ dSYMs

5.3. 使用手动配置中的java上传:

  • 先下载Bugly iOS符号表工具
    里面是这两个文件
  • cd到已下载工具的目录中(如上图),之后执行命令:
  • 记得改下你的appID appKey bundleID等信息;
☁  buglyqq-upload-symbol-2  java -jar buglyqq-upload-symbol.jar -appid cf65bdb747 -appkey 73ac837b-8399-49f5-8e70-1b59e7316973  -bundleid com.renogy.buglytestdemoo  -version 1.0.1  -platform IOS -inputSymbol /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo\ 2022-2-22,\ 3.19\ PM.xcarchive/dSYMs/buglytestdemoo.app.dSYM
##[info]clear cache buglyQqUploadSymbolLib
##[info]clear cache symbolToolAndroid
##[info]bugly tools android params: -appid cf65bdb747 -appkey 73ac837b-8399-49f5-8e70-1b59e7316973 -bundleid com.renogy.buglytestdemoo -version 1.0.1 -platform IOS -inputSymbol /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM

Bugly(bugly.qq.com)符号表工具上传工具包 V1.0.48

用法 -- Usage
 java -jar buglyqq-upload-symbol.jar -appid  -appkey  -bundleid  -version  -platform  -inputSymbol  -inputMapping 

参数说明 -- Introduction for arguments
 -appid APP ID of Bugly
 -appkey APP Key of Bugly
 -bundleid Android平台对应的是package name/iOS平台是Bundle Id
 -version APP版本,需要和bugly平台上面看到的crash版本号保持对齐
 -platform 平台类型包含三个选项 Android、IOS两个选项,注意大小写要正确
 -inputSymbol 原始符号表[ios是dsym/android平台是debug so]所在文件夹目录地址
 -inputMapping mapping所在文件夹目录地址[Android平台特有,iOS忽略]

##[info]args is ArgsParser{appId='cf65bdb747'appKey='73ac837b-8399-49f5-8e70-1b59e7316973', appPackage='com.renogy.buglytestdemoo', appVersion='1.0.1', appBuildNo='null', platformId=IOS', enviroment=null', symbolPathName='/Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM', mappingPathName='null', appPathName='null'}
##[info]deleteDirFiles file path is /Users/admin/Downloads/buglyqq-upload-symbol/buglybin/symbolResult/BuglyIosStifListZip.zip
##[info]deleteDirFiles file path is /Users/admin/Downloads/buglyqq-upload-symbol/buglybin/symbolResult
##[info]deleteDirFiles file path is /Users/admin/Downloads/buglyqq-upload-symbol/buglybin
##[info]packSymbolFile file
##[info]begin to parse dsymPath : /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM
##[info]dsymFiles: 1
##[info]begin to parse dsym file: D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM
##[info]bugly tools ios params: -i /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM -o /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM.zip
[SymtabTool-I] dSymFiles size is : 1

Bugly Symtab Tool for iOS: 3.3.4
[SymtabTool-I] Begin to parse file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglytestdemoo
[SymtabTool-I] Architecture: arm64
[SymtabTool-I] Begin to parse file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglytestdemoo
[SymtabTool-I] Architecture: arm64
[SymtabTool-I] Successfully parsed the file!
/Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglytestdemoo [arm64] d7873d8c2c6035b0a400f82c898ed4f7

[SymtabTool-I] Extracting symtab file: buglytestdemoo
[SymtabTool-I] Begin to parse file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglytestdemoo
[SymtabTool-I] Architecture: arm64
[SymtabTool-I] Successfully parsed the file!
[SymtabTool-I] Begin to parse file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglytestdemoo
[SymtabTool-I] Architecture: arm64
[SymtabTool-I] Successfully parsed the file!
[SymtabTool-I] Begin to extract symbol table..
[SymtabTool-I] Successfully to extract symbol table!
[SymtabTool-I] Begin to create symtab file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.symbol
[SymtabTool-I] Successfully created symtab file!
[SymtabTool-I] Begin to parse the file:/Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.symbol
[SymtabTool-I] Successfully parsed the file
[SymtabTool-I] Begin to construct stif file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.stif
[SymtabTool-I] getSymtabEntryNum: 3419
[SymtabTool-I] getIndexEntryLength: 24
[SymtabTool-I] Successfully constructed stif file
[SymtabTool-I] Add stif to symtab zip file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.stif
[SymtabTool-I] Begin to zip stif file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM/Contents/Resources/DWARF/buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7
[SymtabTool-I] Successfully zipped stif file!
[SymtabTool-I] Begin to zip symtab file: /Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM.zip
[SymtabTool-I] Successfully zipped symtab file!
##[info]visit file name is : buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.zip
##[info]parseStifFileName prefix : buglySymbol arg1 : buglytestdemoo
##[info]parseStifFileName arg2 : arm64 uuid : d7873d8c2c6035b0a400f82c898ed4f7
##[info]parseStifFileName endfix : zip
##[info]SymbolFileDetailList count is : 1
##[info]sourceZipFile file path is :/Users/admin/Library/Developer/Xcode/Archives/2022-02-22/buglytestdemoo 2022-2-22, 3.19 PM.xcarchive/dSYMs/D7873D8C-2C60-35B0-A400-F82C898ED4F7.dSYM.zip
##[info]uploadSymbolFile file :/Users/admin/Downloads/buglyqq-upload-symbol/buglybin/symbolResult/BuglyIosStifListZip.zip
##[info]postRqdFile fileName: BuglyIosStifListZip.zip
##[info]now begin to uploadFile
##[info]buildName :null&null
##[info]buildID :null
##[info]appID :cf65bdb747
##[info]bundle :com.renogy.buglytestdemoo
##[info]appVersion :1.0.1
##[info]platformId :2
##[info]appBuildNumber :null
##[info]fileType :201
##[info]fileMD5 :591bb8425c525ee00c127399d4cca44a
##[info]fileSize :30729
##[info]symbolFileDetail is [{"name":"buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.zip","uuid":"d7873d8c2c6035b0a400f82c898ed4f7","arch":"arm64","type":101,"moduleName":"buglytestdemoo"}]
##[info]request json is {"appID":"cf65bdb747","authSign":"73ac837b-8399-49f5-8e70-1b59e7316973","appVersion":"1.0.1","appBundleID":"com.renogy.buglytestdemoo","appPlatform":2,"appBuildNumber":null,"fileType":201,"fileSize":30729,"fileMD5":"591bb8425c525ee00c127399d4cca44a","clientType":7,"clientVersion":"1.0.48","buildPlatform":1,"buildID":null,"buildName":"null&null","fileInfoList":[{"name":"buglySymbol&buglytestdemoo&arm64&d7873d8c2c6035b0a400f82c898ed4f7.zip","uuid":"d7873d8c2c6035b0a400f82c898ed4f7","arch":"arm64","type":101,"moduleName":"buglytestdemoo"}],"buildRepo":null,"buildBranch":null,"buildCommitID":null}
##[info]request upload Info Url is https://symbol-v2.bugly.qq.com/trpc.eff_tool.symbol_upload_gateway.SymbolUploadGateway/uploadInfo
##[info]request gitRepoUrl is null
##[info]request gitRepoBranch is null
##[info]request gitRepoHeadCommitId is null
##[info]envtype is null
##[info]getAppModuleList is null
##[info]retCode: 200 response message: {"statusCode":0,"msg":"success","uploadReqID":"cf65bdb747-918f61b0-016b-4704-b5db-29f9c2f3df9c"}
##[info]now begin to uploadFileContent
##[info]request uploadFileurl is https://symbol-v2.bugly.qq.com/trpc.eff_tool.symbol_upload_gateway.SymbolUploadGateway/uploadFile
##[info]retCode: 200 response message: {"statusCode":0,"msg":"success","uploadReqID":"cf65bdb747-918f61b0-016b-4704-b5db-29f9c2f3df9c"}
☁  buglyqq-upload-symbol

5.3. 上传成功之后,你就会在你产品的符号表管理中看见对应uuid的符号表文件了;
5.4. 进行奔溃分析:

  • 以下是我在安装埋有奔溃代码的程序中上传的奔溃信息;
  • 可以看见原始状态只是一些堆栈信息;


    image.png
  • 查看符号表,已上传:


    image.png
  • 对出错堆栈进行解析,和我所设置的奔溃代码对应:


    image.png

    image.png
6. 至此,基本配置完成
  • 有待解决的问题:
  • 能够定位到代码行,但是看不见具体的代码段;
  • 官方的自动上传功能不生效,文档的curl命令行不通,为什么还用curl命令举例,直接换成java命令多好,让我少走点弯路;

你可能感兴趣的:(iOS集成Bugly异常上报功能)