27

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!

Kai Zheng
  • 6,640
  • 7
  • 43
  • 66

4 Answers4

55

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:

Kai Zheng
  • 6,640
  • 7
  • 43
  • 66
  • 1
    It seems to now be `"${BUILD_DIR%Build/*}SourcePackages/checkouts/Crashlytics/run"` – Ian Dundas Apr 09 '21 at 15:00
  • 2
    ${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run worked for me, Xcode 12.5. OMG THANK YOU – DEVIGNR Jun 17 '21 at 07:22
  • 1
    Now it's "${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run" – Hadi Sep 22 '21 at 18:55
4

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.

Dren
  • 2,017
  • 21
  • 18
1

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.

domi852
  • 497
  • 1
  • 4
  • 13
  • 1
    I got the solution. in Xcode Preferences go to: Xcode -> Preferences -> Locations -> Advanced and select the first option "Unique". Firebase expects the build folder to be located there. – domi852 Jan 10 '22 at 06:40
1

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

Jules
  • 7,568
  • 14
  • 102
  • 186