Eric Duffett
Eric Duffett

Reputation: 1684

Upgraded Firebase - Now Getting Swift Compile Error

I upgraded Firebase yesterday and now am having a very unusual problem. When I run the simulator, I get a swift compile error "Segmentation fault: 11" The are hundreds of lines of code describing the error, but they are absolutely no help. From the error, the only thing I see that might be giving clues is at the bottom. It says:

  1. While loading members for 'ProfileTableViewController' at <invalid loc>
  2. While deserializing decl #101 (PATTERN_BINDING_DECL)
  3. While deserializing decl #2 (VAR_DECL)

Oddly, the errors I just typed above are not consistent. The view controller mentioned rotates between the three view controllers where I am using Firebase.

To try to solve the problem, I commented out all of the code in the ProfileTableViewController class, but I still got an error referencing that view controller. The only code running in the view controller was:

  import UIKit
  import Firebase
  import FirebaseDatabase

(I'm also using FirebaseAuth in other view controllers).

What does work to fix the problem is to hit "clean", restart xcode, clean again on launch and then run the program. Everything will work fine unless I make any changes to the code in the program. Even if all I do is add a comment, the error will reappear.

I don't want to have to close xcode and restart every time I write a couple lines of code, and I am worried that I will run into problems when uploading to the app store.

I am using XCode 7.3.1 and my deployment target is 9.3

Any insight you can give is greatly appreciated! Thank you!

Upvotes: 25

Views: 4830

Answers (8)

RawKnee
RawKnee

Reputation: 323

I also had this problem with Firebase.

Xcode would complain on particular class. Just like your "ProfileTableViewController" What I did to solve this was: Comment all Firebase related imports in that class -> Clean -> Build (Obviously got some errors) -> Uncomment -> Clean -> Build succeeded

Upvotes: 1

TommyF
TommyF

Reputation: 343

In your podfile you can try to uncomment use_frameworks!

use_frameworks!
pod 'Firebase'
pod 'Firebase/Database'
pod 'Firebase/Auth'

Then run 'pod update' in the terminal. Restart your Xcode project.

This did it for me after struggling for two days with the Segmentation fault 11

Upvotes: 3

gasho
gasho

Reputation: 1931

The problem for me occurred when I was explicitly setting the types of the completion block parameters for setValue.

FIRDatabase.database().reference(withPath: "test").childByAutoId().setValue("test1") { (error: Error?, ref: FIRDatabaseReference) in }

Everything works fine when the types for error and ref are removed.

Upvotes: 0

Grambo
Grambo

Reputation: 949

I figured out a different solution that worked for me. I had a few custom functions that returned Firebase-specific variables like FIRUser to files that didn't have import Firebase or import FirebaseAuth at the top. I like keeping my data service methods in a separate file, so I just changed the functions so that they returned Strings, such as FIRUser.uid, instead. This FINALLY got rid of the compiler warnings/crashes for good.

Upvotes: 0

Zaid Pathan
Zaid Pathan

Reputation: 16820

Deleting DerivedData and ModuleCache, then Clean>Build worked for me.

Upvotes: 1

JPetric
JPetric

Reputation: 3918

I was also pulling my hair out with this issue for some time. I tried Eric Duffett's answer but without luck.

I figured out it was an issue with the FirebaseAuth. What I did was this:

  1. Remove FirebaseAuth from Podfile
  2. Update pods with pod update
  3. Download Firebase frameworks from their site (at the bottom)
  4. Follow README file to import FirebaseAuth manually in the project (need to import FirebaseAuth.framework and GoogleNetworkingUtilities.framework)
  5. Clean - Build and no more segmentation fault 11 error

Hope this will help someone.

Upvotes: 4

Seppo
Seppo

Reputation: 585

This is/was really driving me berserk.

This code causes the aforementioned crash:

func ref() -> FIRStorageReference {
    return FIRStorage.storage().reference()
}

If I just use it in a function everything works:

FIRStorage.storage().reference().dataWithMaxSize(...

Took hours to figure this out. The error message points to somewhere else. This was probably the most frustrating debugging experience in my entire career.

Upvotes: 3

Eric Duffett
Eric Duffett

Reputation: 1684

I was able to figure it out! My Cocoa Pods were not up to date. As soon as I went back and installed the latest Cocoa Pods in the terminal, then updated the podfile for this app, this error disappeared.

Process:

Open terminal

  sudo gem install cocoapods

(Cocoapods update) In terminal navigate to app folder, then:

  open -a xcode podfile

If needed, make changes in podfile. I didn't need to make any changes. Save and exit.

In terminal

  pod update

Open the .xcworkspace file and ta da!

Upvotes: 20

Related Questions