Using XCode10.5.1, iOS 14.6, Swift5.4.2,
Using the Swift Package Manger (SPM) for getting Firebase dependency in to my project – I try to get going Google Crashlytics on my iOS device.
I saw in several posts (ex. this one) that in order for Crashlytics to work via the SPM, you need to add a Build run script in Xcode as follows:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
Now since I do have two different configurations defines (DEV and PROD), I somehow need to make this run script know about this.
My script looks as follows:
if ["${CONFIGURATION}" == "Release"] || ["${CONFIGURATION}" == "Debug"]; then
${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
elif ["${CONFIGURATION}" == "ReleaseDev"] || ["${CONFIGURATION}" == "DebugDev"]; then
${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/iOS/SupportFiles/GoogleService-InfoDev.plist
fi
But Crashlytics still does not work !
Question NR1: How does the run script look like for Crashlytics to work with SPM ?
Question NR2: In particular, how can I improve my run script for making a clear distinction between DEV and PROD environment. (so far I need to do the workaround with CONFIGURATION
).
2
Answers
Here is a working example of Crashlytics in Xcode when used via Swift Package Manager (i.e. not via Cocoapod):
I found the solution - the run Script had a wrong syntax.
Here is the correct one:
Of course,
Debug
,Release
,DebugDev
andReleaseDev
depends on your own naming of your configurations in Xcode.This way, the two configurations DEV and PROD both work with Google Crashlytics. The script makes sure the necessary dSYM files are sent to Google once a crash occurs.
To verify that the script is executed, you can follow the echo print under the
report Navigator
in Xcode (i.e. see screenshot)I am unable to edit the above post. [showing "Suggested edit queue is full"]
So commenting here:
There is an issue in the script here https://stackoverflow.com/a/68460653/3913535
$CONFIGURATION should be in quotes inside the if condition.