9

I am getting EXC_BAD_ACCESS after including 'Firebase/Auth' in Podfile. This happens without adding any line of firebase code. I am using swift3 on xcode 8 and the resultant pods are -

Installing Firebase (3.8.0)
Installing FirebaseAnalytics (3.5.1)
Installing FirebaseAuth (3.0.6)
Installing FirebaseCore (3.4.4)
Installing FirebaseInstanceID (1.0.8)
Using GTMOAuth2 (1.1.4)
Using GTMSessionFetcher (1.1.7)
Using GoogleAppUtilities (1.1.2)
Installing GoogleInterchangeUtilities (1.2.2)
Using GoogleSignIn (4.0.1)
Using GoogleSymbolUtilities (1.1.2)
Installing GoogleToolboxForMac 2.1.0 (was 2.1.0)
Using Localize-Swift (1.6)
Using ProtocolBuffers-Swift (3.0.6)
Using QorumLogs (0.9)

The error comes in Thread 1 in [UIViewController(FIRAScreenClassName) fira_viewDidAppear:]:

This happens only if the pod target is itself a framework which is embedded in an app eventually.

I do have Google analytics as well. Is it because ARC is not enabled? How do I do that on xcode-8? Any other options to try?

adarsh
  • 1,070
  • 1
  • 7
  • 17

3 Answers3

15

There appears to be a problem in the latest Firebase/Core (3.8.0) release. Even @IBDesignable was crashing with a recursive call to the method signature you mentioned.

You have a couple of options:

  1. In Info.plist (app), set FirebaseAutomaticScreenReportingEnabled to NO (bool). This solved the problem for my running application, but IBDesignable resources caused this error on build:

file:///path/to/project/Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for UIViewController (svZ-78-1Mn): The agent crashed

  1. You may want to temporarily downgrade to 3.7.1, for example,

    pod 'Firebase/Core', '~> 3.7.1'
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    

The rest of the dependencies should take care of themselves when you run pod update.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Cameron
  • 1,142
  • 8
  • 32
  • @adarsh I've spent a considerable amount of time with Firebase support trying to get this issue resolved. They provided a hacky work-around that I'm not satisfied with (involved tweaking linker flags) - though the application would run, Cocoapods would complain and unit test builds wouldn't compile. I finally tried a custom Cocoapod w/ FB dependencies, but that seems unsupported by Cocoapods (I filed here: https://github.com/CocoaPods/CocoaPods/issues/6138). My final resolve pains me, but I will directly include my framework code in the App target until there's a legitimate fix for our issue. – Cameron Nov 06 '16 at 16:24
  • I should also add - the crash was because of the errors mentioned in @alex-d's answer - the "implemented in both". Once that bug is cleared, there are no longer crashes. This is why the Firebase support suggested manually modifying linker flags. Technically it works, but seemed like too much of a hack, not to mention the unit test builds breaking still wasn't addressed. – Cameron Nov 06 '16 at 16:26
  • I agree the basic issue seems to be because of 'duplicate dependency' created because of the framework-target. However, I don't see how customer apps always depending on the framework targets, (as @alex-d suggested), is a clean solution. That said, it means this is fundamentally a cocoapods/ios issue than that of firebase. – adarsh Nov 07 '16 at 13:01
  • 1
    How dare they add such feature "AutomaticScreenReporting" and setting it by default to YES ????? – Lena Bru Nov 08 '16 at 01:06
  • I received some indication from the Cocoapods team that there is likely an issue with the podspec /module map. This whole thing is messy. – Cameron Nov 08 '16 at 09:25
  • 1
    I just hate all magic things happening automatically in the background. When invisible things stop working you don't see what's wrong. – Tapani Nov 16 '16 at 16:12
  • 1
    this is still an issue in Firebase/Core 3.11.0 – Zayin Krige Jan 05 '17 at 08:41
1

I am suspecting that the Podfile is not correct. I got into similar problem by adding Firebase dependency into a framework and I ran into the problem like this

objc[12345]: Class FIRAAppEnvironmentUtil is implemented in both /Users/...Build/Products/Debug-iphonesimulator/SomeFramework.framework/SomeFramework (0x105ef7fc8) and /Users/.../CurrentProject.app/CurrentProject (0x105945108). One of the two will be used. Which one is undefined.

As mentioned in this post, you might have duplicate dependencies in different targets which could lead to weird bug like this. Adding Firebase pod into the main target and removing the Firebase pod from the framework fixed the problem for me.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
adbitx
  • 2,019
  • 8
  • 13
  • If the framework depends on the pod, the pod must be in the appropriate target(s). Simply including it in the application target is not sufficient. – Cameron Nov 01 '16 at 15:53
  • I think the customers (apps) should pull the sdks when they consume the frameworks to avoid complicated dependencies. According to this https://github.com/jverkoey/iOS-Framework/issues/46, it seems to be recommended to have the sdks at app level, not framework level. – adbitx Nov 02 '16 at 16:47
1

I made a silly mistake. Never turned on Google under Authentication -> Sign in methods on Firebase

Kavin Varnan
  • 1,989
  • 18
  • 23