-->

Integrate Fabric/Crashlytics via CocoaPods

2019-01-31 05:18发布

问题:

I try to integrate Fabric/Crashlytics via CocoaPods, my Podfile looks like this:

pod 'Fabric/Core', '1.2'
pod 'Fabric/Crashlytics', '1.2'

But when I try to build my app, the build fails and I get a Shell Script Invocation Error that the run script isn't found:

.../Script-F8D74CB61AB5D7A50013D134.sh: line 2: ./Fabric.framework/run: No such file or directory

Is it possible to install Fabric only using CocoaPods?

回答1:

Fabric now supports installation with CocoaPods: http://docs.fabric.io/ios/fabric/cocoapods.html

If you are just looking for Crashlytics you can use these two pods:

pod 'Fabric'
pod 'Crashlytics'

Along with adding the following build phase script (note: In case the path to your repo contains spaces, you will need the quotes):

"${PODS_ROOT}"/Fabric/run <API Key> <Build Secret>

If you are looking to use TwitterKit you will need to include:

pod 'TwitterKit'


回答2:

Same problem for me was fixed by changing the line from:

./Pods/Fabric/Fabric.framework/run YOUR_API_KEY YOUR_BUILD_SECRET

to:

../Pods/Fabric/Fabric.framework/run YOUR_API_KEY YOUR_BUILD_SECRET

In other words, just prepend an extra '.' to designate that the 'Pods' directory is a sibling rather than a child of the build directory. YMMV.



回答3:

I had the same problem, use the $PODS_ROOT environment variable which points to your Pods folder; be sure to quote it in case you have spaces in your path; so instead of

./Pods/Fabric/Fabric.framework/run YOUR_API_KEY YOUR_BUILD_SECRET

use

"$PODS_ROOT"/Fabric/Fabric.framework/run YOUR_API_KEY YOUR_BUILD_SECRET



回答4:

Try:

  1. Remove Fabric and Crashlytics in podfile.

  2. pod install

  3. Add Fabric and Crashlytics to podfile again

  4. pod install

  5. Add Run script like above answer.

Hope it help.



回答5:

macOS Sierra, Swift 3

change

${PODS_ROOT}/Fabric/run

to

"${PODS_ROOT}/Fabric/run"


回答6:

I had to use a different path in Xcode 7 using CocoaPods 0.39:

${SRCROOT}/Pods/Fabric/Fabric.framework/run <key> <secret>

podfile:

pod 'Crashlytics'
pod 'Fabric'

I also just updated Fabric to 3.4.1, and that path ^ changed slightly to Fabric/run. Make sure you check the bits after ${SRCROOT} carefully and compare it to what the Fabric app recommends. See the changelog for 3.4.1 for details.



回答7:

in

Fabric (1.6.7)

You should change path from

"${PODS_ROOT}/Fabric/Fabric.framework/run" YOUR_API_KEY YOUR_BUILD_SECRET

to

"${PODS_ROOT}/Fabric/run"  YOUR_API_KEY YOUR_BUILD_SECRET


回答8:

The path to the script that is executed during the build phase is different when you use Cocoapods. The github page on https://github.com/bpoplauschi/CrashlyticsFramework advises to use ./Pods/CrashlyticsFramework/Crashlytics.framework/run however, I found I had to use ./Pods/Fabric/Fabric.framework/run for my installation. Anyways you will have to dig through the Pods directory to find what you are looking for.



回答9:

If you relied on something specific to the older Podspecs and can't update to the official libraries yet, you can add

source 'https://github.com/orta/FabricSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'

To the top of your Podfile, and it will look for the older -unofficial- versions before the new ones. See the FabricSpecs repo for more details.



回答10:

For my project, this worked:

"${PODS_ROOT}/Fabric/Fabric.framework/run" YOUR_API_KEY YOUR_BUILD_SECRET


回答11:

If you update to Fabric & Crashlytics from older version:

  1. If you have any data in your info.plist file by the key Fabric, make sure to delete all that info along with the key.
  2. Use simple "${PODS_ROOT}/Fabric/run" script. Don't add any API_KEY and BUILD_SECRET

That worked for me, hope this helps.



回答12:

Typically I would recommend not going against the grain and using the Fabric App for installation. Its hands down the simplest integration tool I've ever seen given the complexity they are providing.

That being said, since you're dead set on using Cocoapods, the only way to get things going would be the following

  1. Run the Crashlytics App installer to the point where they give you the build phase script.
  2. Copy the script
  3. Undo the installation
  4. Install via Cocoapods
  5. Add the copied script to your buildphase


回答13:

I have meet this issue before. Here is my solution. to add the execution mode for the run file automatically before your run the script.

In the Build Phase -> Run Script add following line:

chmod +x ./Pods/CrashlyticsFramework/Crashlytics.framework/run

./Pods/CrashlyticsFramework/Crashlytics.framework/run YOUR_API_KEY YOUR_BUILD_SECRET


回答14:

Delete podfile.lock and manifest.lock, then re-run podfile install, then continue from there using the "easy" configure app from Fabric.

There are some very nice screen-shot slide-show demos on Fabric.io's site. I found them with Google - don't see where they are accessible from the site.

FYI, if you're having issues, it's not you :). Basically (as of August 3rd), every step of the Fabric onboard process is potentially broken.

  • If you're lucky, you might have no issues.
  • If you're not, :( you might have issues to resolve at every step, including signing up for the service which can put you in an endless sign-up loop, and so on from there.

Hopefully these will all get fixed soon.

Warning: most of the answers you will find via a search will be outdated, because apparently fabric.io changed a lot on July 15th, but if you scroll down anything you find on stack/o, you might find a newer answer.



回答15:

Make sure to uninstall pod 'Answers', '~> 1.3' from your pods if you are using Fabric in your project before.



回答16:

As mentioned in the official documentation, just update your pods repo

pod repo update