Firebase and Google Sign - patching Google's code

iOS   Google   Firebase  

I have a project I've been messing around with for a while and recently I decided to re-write it in Swift. As part of doing this I took a look at the technologies I had employed for the server with the question of 'Should I persist with this?'

The short answer was - No.

I'd previously gone with a roll-your-own approach to my server. Using Node.js, MySQL, Knex and Bluebird promises. All good products and if I ever feel the need to do more javascript, I'll be reaching for them. But this time I really wanted to get someone else to do most of the dirty work for me because I'm lazy.

I hummed and hah'd around for a while and eventually decided to try out Google Firebase because it was free (always important with toy projects), and appeared to have the sorts of functionality I figured I could use.

So I included the Firebase database SDK into my iOS client project following Google's instructions. This worked fine until I attempted to create some data which crashed and burned because Firebase Databases have security enabled by default.

Some reading later and I worked out I needed to add in authentication. Some more reading after that and I figured out Firebase Database can use a wide range of authentication systems, one of which was Google's single sign in solution. AKA Your google Id. This seemed perfect as I've used my Google Id for authentication in the past and it should integrate seamlessly with Firebase Database.


Despite what Google's integration documentation said, combining Firebase Database and Google Sign In in the same project caused the compiler to throw a teeny tiny tantrum and spit out numerous duplicate symbol errors. Indicating that both the Firebase and Google Sign In SDKs had the same classes in them.

I thought 'No, this can't be right. I must have done a boo boo somewhere,' but after a lot more reading concluded - 'No, I'd actually done it right for once' and it was Google who had stuffed up. Supported by this StackOverFlow question.

Basically the answer said:

  1. Copy the GoogleSignInDependencies.framework to a tmp directory.
  2. Extract the binaries for the various architectures.
  3. Extract the individually compiled class binaries.
  4. Remove the duplicate class binaries which clash with the Firebase binaries.
  5. Combine the left over binaries back into a new framework.
  6. Include this new framework in your project.

I had doubts that was the best answer so I popped a question at Google. Who to their credit, emailed me back the next day. The pointed me at the same StackOverFlow question I'd found and suggested that was the best answer they could offer.


Google was telling me to patch their product so it would work the way their instructions said they should in the first place! - Gotta admit, I was a bit gob smacked.

So long story short, I went and followed the StackOverFlow answer, tearing GoogleSingInDependencies apart and re-assembling it. So far, it's worked. I'm no longer getting compilation problems and everything appears to be working, although I've not used much of Firebase's functionality as yet.

There's two points I wanted to cover here.

  1. I'm still surprised a company can put out two products like Firebase and Google Sign In, and recommend to use them together when they know you can't without some relatively advanced skills.
  2. I wrote a script to do all the dirty work of fixing the framework. It works for me, hopefully it will help someone else.

Comments powered by Disqus