Firebase Crashlytics | Swift Package Manager (SPM) Run Script?

Viewed 6684

I want to add Crashlytics to my app using the Swift package manager.

Now, since the usual way to install Firebase is through CocoaPods, the tutorial on how to set up Crashlytics properly is also adjusted for CocoaPods.

In other words - the run script we should copy from the tutorial is not compatible with SPM, as you can see here:

${PODS_ROOT}/FirebaseCrashlytics/run

So how can I find the file location of Crashlytics using SPM to get the correct run script?

Thanks!

5 Answers

Turns out its inside the DerivedData folder:

~/Library/Developer/Xcode/DerivedData/YOURAPP-.../SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

For your convenience, you can use a build variable to generalize the folder path:

${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run

Finally, your run script should look something like that:

And another quite important thing if a non-default name for the firebase configuration file is used. This flag is needed to denote it:

-gsp ${PROJECT_DIR}/PATH-TO-CONFIG/GoogleService-Info-Dev.plist

Thus final script should look like

${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/PATH-TO-CONFIG/GoogleService-Info-Dev.plist

Where PATH-TO-CONFIG is the path to the firebase configuration file in the project.

Thanks for the suggestions. I'm unable to make this work. I get a crash and the following error message:

/Users/[path-to-my-project]/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

I don't understand why it tries to find the crashlytics script in my Xcode project folder and not in the derived data folder at runtime.

This worked for me, but I had to change Project Settings.

"${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"

enter image description here

enter image description here

Add a package by selecting FileAdd Packages… in Xcode’s menu bar. enter image description here

Search for the Firebase Apple SDK using the repo's URL:

https://github.com/firebase/firebase-ios-sdk.git

Next, set the Dependency Rule to be Up to Next Major Version and specify 8.10.0 as the lower bound.

Then, select Add Package.

Choose the Firebase products that you want installed in your app.

enter image description here

If you've installed FirebaseAnalytics, add the -ObjC option to Other Linker Flags in the Build Settings tab.

enter image description here

Related