B4i Library Firebase Crashlytics

This is a wrapper of Firebase Crashlytics library for B4i. I made this for @Jack Cole and he gave me permission to post this in forum to help other users.

iFirebaseCrashlytics

Author:
@Biswajit
Version: 2
  • Crashlytics
    • Events:
      • HasUnsentReports
    • Functions:
      • checkForUnsentReports
        Check for unsent reports
        You must set setCrashlyticsCollectionEnabled to false in order to use hasUnsentReports
        If there is any unsent report the EventName_HasUnsentReports event will be raised
      • deleteUnsentReports
        Delete unsent reports
      • didCrashDuringPreviousExecution As Boolean
        Detect when a crash happens during your app's last run.
      • Initialize (EventName As String)
        Turn off automatic collection by adding a new key to your project
        #PlistExtra: <key>FirebaseCrashlyticsCollectionEnabled</key><false/>
        Initializes the library inside the Application_Start function.
        You should initialize FirebaseAnalytics before initializing this library.
      • isCrashlyticsCollectionEnabled As Boolean
        Check if automatically report collection is enabled or not
      • Log (msg As String)
        Add custom log messages
        NOTE: To avoid slowing down your app, Crashlytics limits logs to 64kB and deletes older log entries when a session's logs go over that limit.
      • sendUnsentReports
        Send unsent reports
      • setCrashlyticsCollectionEnabled (enable As Boolean)
        Enable collection for select users by calling the Crashlytics data collection override at runtime. The override value persists across launches of your app so Crashlytics can automatically collect reports. To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app
      • SetUserID (ID As String)
        Set user identifiers
      • TestCrash
        Cause a Test Crash

Installation:
  1. Download the latest libraries from here.
  2. Download the attached Zip file.
  3. Copy the .a and .h file to the local build server's Libs folder.
  4. Then copy the XML file to the B4i library folder.
  5. Copy the upload-symbols file to FirebaseCrashlytics.framework folder of your local build server.
Usage:
  1. Follow firebase integration tutorial from here,
  2. After initializing the firebase analytic library initialize this crashlytics library.
  3. You have to build the project in Release Mode. Otherwise, the builder will not generate the dSYM which is needed for the library to work.
Enable opt-in reporting
B4X:
#PlistExtra: <key>FirebaseCrashlyticsCollectionEnabled</key><false/>

After building the project (Not possible from hosted builder):
  1. Don't run the app after building. Open Terminal App.
  2. Type, cd /path/to/your/project/directory
    In my case, it is /Volumes/ExtendedSSD/B4iBuildServer/UploadedProjects/a888heh
  3. Paste this following code to upload dSYM file to google server and hit enter,
    ../../Libs/FirebaseCrashlytics.framework/upload-symbols -gsp ./GoogleService-Info.plist -p ios ./Payload
  4. Now run the app.
  5. For testing the crash call FirebaseCrashlytics.TestCrash.
  6. It may take few minutes to reflect on the firebase dashboard
Update 1.01: Added simulator support.
Update 2.0:
  1. Based on the new SDK.
  2. Added option to check if any crash happens during the last run.
  3. Added option to check if there are any unsent crash reports.
  4. Added option to manually send unsent crash reports.
  5. Added option to delete unsent crash reports.
  6. Added option to check if automatic report collection is enabled or not
  7. Added option to toggle automatic report collection
  8. Added option to send custom log to crashlytics
 

Attachments

  • iFirebaseCrashlytics.zip
    122.5 KB · Views: 28
Last edited:

angel_

Well-Known Member
Licensed User
Longtime User
  1. Paste this following code to upload dSYM file to google server and hit enter,
    ../../Libs/Fabric.framework/upload-symbols -gsp ./GoogleService-Info.plist -p ios ./Payload
I don't know how to include this line, Is it the path to GoogleService-Info?, What is this -p ios./Payload?.

I use hosted builder
 

Biswajit

Active Member
Licensed User
Longtime User
I don't know how to include this line, Is it the path to GoogleService-Info?, What is this -p ios./Payload?.

I use hosted builder
Its not possible to upload dSYM from hosted builder
 

angel_

Well-Known Member
Licensed User
Longtime User
It's a pity because it detects the error very well, but it doesn't give information about it
 

Biswajit

Active Member
Licensed User
Longtime User
Sorry I didn't understand.
 

angel_

Well-Known Member
Licensed User
Longtime User
I was testing and Crashlytics detects the error, but it request to upload the dSYM
 

Attachments

  • Captura.JPG
    Captura.JPG
    11 KB · Views: 15

Biswajit

Active Member
Licensed User
Longtime User
I was testing and Crashlytics detects the error, but it request to upload the dSYM
That is what this following code does,
Paste this following code to upload dSYM file to google server and hit enter,
../../Libs/Fabric.framework/upload-symbols -gsp ./GoogleService-Info.plist -p ios ./Payload

Without dSYM its not possible to show the actual error message.
 

andyr00d

Member
Licensed User
Longtime User
Hello,

Thanks for sharing this library! I've included & updated the required libraries but I'm getting the below error when I run either release or debug mode:

1589627227461.png

My active libs are on the right. Any ideas?
 

Biswajit

Active Member
Licensed User
Longtime User
Hello,

Thanks for sharing this library! I've included & updated the required libraries but I'm getting the below error when I run either release or debug mode:

View attachment 94158

My active libs are on the right. Any ideas?
I've added simulator support. Download the library again and replace the files in your Libs folder.
 

andyr00d

Member
Licensed User
Longtime User
Thank you but I'm still getting the same error. To confirm, I've updated the XML iFirebaseCrashlytics file you uploaded in the internal libraries, and I've placed the other files (.framework, .a & .h files) into the buildserver libs directory on my local mac, still getting (running your attached example.b4i solution):

B4X:
ld: warning: Could not find or use auto-linked framework 'FBLPromises'
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_iFirebaseCrashlytics", referenced from:
      objc-class-ref in b4i_main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Error: ** BUILD FAILED **


The following build commands failed:
    Ld /Users/andrew/Documents/B4iBuildServer/UploadedProjects/<user id>/Payload/B4i\ Example.app/B4i\ Example normal x86_64
(1 failure)
 

Biswajit

Active Member
Licensed User
Longtime User
Maybe I've uploaded the previous version again. I've tested in simulator this time. Please download again. And remember to clear the project before running.
 

andyr00d

Member
Licensed User
Longtime User
An update: it was working well for a while but after submitting some new builds and running the command to upload the DSYMs, it's now saying that they are missing. Couple of questions... Does the provision profile need to be the store/release one? I'm assuming that the DSYMs need to be uploaded after each build, but what if a slight amount of code was updated, then the app was re-build (keeping the same #Version) - will those generated DSYMs still be valid? I'm trying many different ways but can't get past the "Upload missing required dSYMs" - any ideas?
 

Biswajit

Active Member
Licensed User
Longtime User
Does the provision profile need to be the store/release one?
No. It can be anything.
I'm assuming that the DSYMs need to be uploaded after each build, but what if a slight amount of code was updated, then the app was re-build (keeping the same #Version) - will those generated DSYMs still be valid?
For each and every build you have to submit that dSYM file. It doesn't matter if you changed a small amount of code or huge amount of code.
I'm trying many different ways but can't get past the "Upload missing required dSYMs" - any ideas?
Did you upload the dSYM file after release build using the command line code posted above?
 

andyr00d

Member
Licensed User
Longtime User
For each and every build you have to submit that dSYM file. It doesn't matter if you changed a small amount of code or huge amount of code.

So what if I created a new build, uploaded to the App store and forgot to upload the DSYMs, and already modified some code and compiled a new debug build... can the previous (app store) version's DSYMs still be found? so the newly created build's DSYM's wouldn't be compatible and an entirely new build needs to be created for the App store?
 

Biswajit

Active Member
Licensed User
Longtime User
You need xcode to download the dSYM file from app store. (Possible only if you uploaded the app using xcode)
  1. Add your account to xcode from preference.
  2. Goto Window > Organiser > Archives
  3. Select your app from app list at the left side
  4. Select version
  5. Click on download debug symbols button
    1592230561858.png
 

andyr00d

Member
Licensed User
Longtime User
Actually I tried that already, but in archives only my original build version is showing (1.0), not the 1.07 which I uploaded to the App Store but I guess I can try it again with the DSYM from Xcode
 
Top