B4i Library iHockeyCrash - crash reports

Name: iHockeyCrash

Version:
1.0

Description: iHockeyCrash is a wrapper of the HockeySDK (only the crash part) and allows you to receive crash reports directly to your Hockey dashboard, where they are symbolicated automatically (no mac required, you just need to upload the dsym symbols).

License: https://github.com/bitstadium/HockeySDK-iOS/blob/develop/LICENSE

Notes/Tips:
  • first, you need to register a new iOS App at the Hockey dashboard and grab the AppID
  • download the attached "Bundle.zip" and put the HockeySDKResources.bundle into the Special folder of your project
  • the setup is very easy, use the following code in the Application_Start sub:
    B4X:
        HC.Initialize("YOUR APPID")
        HC.SetMsgBox("Ooops","The App crashed. Please help us by sending the crash log","Don't send","Send now","Always send")
        HC.StartManager
    (HC is a HockeyCrash object, declared in the Process_Globals sub)
  • a crash report is send to the dashboard once the App crashes and the user opens the App again
  • you can ignore the following error: [HockeySDK] void bit_fixBackupAttributeForURL(NSURL *__strong)_block_invoke/177 ERROR: Error while setting resource value: The file “Application Support” doesn’t exist. (See also)
Download the Library here.

Feel free to ask questions ;)
 

Attachments

  • Bundle.zip
    152 bytes · Views: 20
Last edited:

Sandman

Well-Known Member
Licensed User
Did something go wrong when creating Bundle.zip? Seems to just contain a dir with an empty file?
 

JanPRO

Well-Known Member
Licensed User
No, thats just a small "hack": Normally, the bundle has a lot's of other files (images, language files, etc), but they are not needed for the crash manager. However, the SDK is still looking for this bundle. When no bundle was found, the app crashes. To avoid this, we need this kind of dummy.

Jan
 

Sandman

Well-Known Member
Licensed User
Clever hack. :)

Can you share any insights into this lib and HockeyApp? Is everything super straight forward, or are there any small oddities that are good to know?
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Hi JanPRO,
Does this work with the Hosted builder. I get an error

B4X:
b4i_main.h:2:9: fatal error: 'iHockeyCrash.h' file not found
#import "iHockeyCrash.h"
        ^~~~~~~~~~~~~~~~
1 error generated.

Error: ** BUILD FAILED **

iHockeyCrash.h is in the AdditionalLibraries directory.

Edited:
 

JanPRO

Well-Known Member
Licensed User
Hi,
@Sandman
Can you share any insights into this lib and HockeyApp?
I think this is one of the most unexciting libraries for B4i (from the code perspective ;)), it doesn't even use any B4IObjects and makes less than 10 calls to the SDK. If you want I can send you the Xcode project, just PM me :)

@Andrew (Digitwell)
Erel needs to upload the library to the hosted builder.

Jan
 

Sandman

Well-Known Member
Licensed User
this is one of the most unexciting libraries for B4i <snip> and makes less than 10 calls to the SDK

That sounds good, unexciting and small might make it more solid. :)

But do tell, have you used it yourself for your projects? Do you feel this is solid enough to put in published apps?


I can send you the Xcode project

That's really nice of you, but I wouldn't know what to do with it. :) Perhaps just upload it in this thread so other B4i developers could learn from it?
 

JanPRO

Well-Known Member
Licensed User
But do tell, have you used it yourself for your projects? Do you feel this is solid enough to put in published apps?

I didn't use such a service yet. If I tell you this library is 100% reliable I would lie, but I feel it's solid enough to use it in production (also taking into consideration that HockeyApp ist quite famous). Personally, I will use it in my next apps as the benefit is huge, for example:

This is how a (automatically) symbolicated backtrace looks for the following error:

-[B4IObjectWrapper object]

*** Terminating app due to uncaught exception '', reason: 'Object was not initialized (UILabel)'

Hockey.PNG
As you can see, it's super easy to locate the issue: Main Module --> Page1_Click sub --> Label.Text

Jan
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Just incorporated into a test app.
It requires a lot more setup then Crashlytics on B4A, within the tool itself, but it works great.

But it works great.

The steps I took:

1. Create App in Dashboard - Use the Manual Option. I also set the Release type to Beta
2. Incorporate the App ID etc, as in the first post.
3. In HockeyApp, Create a Version for the App - use the manual option
The version number must match your Version in the app, I set the Build Number to 1
I enabled External Build option on this screen as well.
4. Upload the dSym file from your app. You can get this by Tools->Build Server -> Build Release App, then Tools->Build Server -> download last build, within the downloaded .ipa file is a .app.dSym directory, extract and then zip up separately.

Niggle
It seems that you need to create a new version with corresponding uploaded dSYM so that the the crash reports look correct with all of the correct symbols etc.
But I will definitely be incorporating this into my next release builds.


One final thing, I didn't get the message box on the phone telling me the app had crashed. Maybe this only appears once the app is released on the store?


Cheers

Andrew
 

JanPRO

Well-Known Member
Licensed User
@Andrew (Digitwell)
Wow, thank you for this detailed instruction. I am sure this will help others :)
It seems that you need to create a new version with corresponding uploaded dSYM
Indeed, that's true. The symbols always needs to fit to the build, you are using the library with. In general, it's a good idea to always backup the symbol archive of release version for the store.

Maybe this only appears once the app is released on the store?
No, it should work in every app build.
Hard to to say. You should see the message box after your App crashed and you open it again. Just to clarify: You have never seen the message box? Also not one time?

Jan
 

Andrew (Digitwell)

Well-Known Member
Licensed User
That's correct, I have never seen the message box. I have just run my test app 3 times in a row.

B4X:
Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    
    Dim hc As HockeyCrash
    hc.Initialize("MyID")
    hc.SetMsgBox("Ooops","The App crashed. Please help us by sending the crash log","Don't send","Send now","Always send")
    hc.StartManager

    Sleep(5000) 'Needed to allow HC initialization to complete, not needed in a real app
    CrashHere
    
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Application_Background
    
End Sub


Sub CrashHere
    CrashMod
End Sub

Sub CrashMod
    lbl.Text = "Crash Here"

End Sub
 

JanPRO

Well-Known Member
Licensed User
Your code is absolutely fine.
Did you copy the HockeySDKResources.bundle to your special folder?
Do you receive any logs with the HockeyApp tag (except from [HockeySDK] void bit_fixBackupAttributeForURL ...) ?

Jan
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Ah, I had forgotten to put the bundle in the Special Folder. :oops: The message box now appears.

TBH, I prefer it to just to send the crash report without giving the user the option. Is it safe to leave this bundle out, do you think Apple will reject without it?
 

JanPRO

Well-Known Member
Licensed User
Are you saying that Apple will have no problems with us sending crash reports without asking for the users' permission first?
No. From the technical perspective Apple will accept the App without this bundle (99% sure), I haven't check whether this proceeding is compliant with Apple guidelines.

I am not a lawyer, but you should also check the laws of your country. In Germany for example we have to give users the option to disable Google analytics, I guess it's the same for crash reporting.

Jan
 
Last edited:
Top