Kodeco Forums

Firebase Tutorial: Real-time Chat

It seems like every major app out there has a chat feature. This tutorial shows you how to build a chat app with Firebase and MessageKit!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5359-firebase-tutorial-real-time-chat

Hi, I was wondering how can I access the previous version of this tutorial the one that uses JSQMessagesViewController instead of message kit? I’d like to finish that one first then move on to this one, hope you can help me :slight_smile:

yeah!! thank you!!! :relaxed::relaxed::relaxed:

1 Like

JSQMessagesViewController is deprecated :frowning: :sleepy:

I am facing issues while i have downloaded this app’s starter package and try to build this app.

I’m sorry to hear this. What issues are you experiencing?

Unfortunately we have a permanent redirect for the old tutorial to this new one. You might be able to find a cached version on https://archive.org, but we don’t support that tutorial anymore.

Type ‘UIResponder’ has no member ‘keyboardWillShowNotification’
Type ‘UIResponder’ has no member ‘keyboardWillHideNotification’
Type ‘UIResponder’ has no member ‘keyboardFrameEndUserInfoKey’
Type ‘UIResponder’ has no member ‘keyboardAnimationDurationUserInfoKey’
Type ‘UIResponder’ has no member ‘keyboardAnimationCurveUserInfoKey’
Type ‘UIResponder’ has no member ‘keyboardAnimationDurationUserInfoKey’
Type ‘UIResponder’ has no member ‘keyboardAnimationCurveUserInfoKey’
‘LaunchOptionsKey’ is not a member type of ‘UIApplication’
Use of undeclared type ‘MessageData’

It looks like you’re getting those errors because you’re using Xcode 9. Update to Xcode 10 and those errors should go away, also make sure that you run pod install to get the MessageKit and Firebase dependencies.

Hi guys, it looks like there were some breaking changes in MessageKit.
MessageData enum was renamed to MessageKind and changed MessageType’s data property name to kind.

Also associated value for the MessageData.photo was changed from UIImage to new MediaItem protocol
So in order to compile and proceed with the starter project, I changed RWRC/Models/Message.swift, and replaced var type: MessageType with var kind: MessageKind

then temporarily added the UIImage extension, which implements the MediaItem protocol. something like following:

extension UIImage: MediaItem {
  public var url: URL? { return nil }
  public var image: UIImage? { return self }
  public var placeholderImage: UIImage { return self }
  public var size: CGSize { return  CGSize.zero }
}

struct Message: MessageType {
  ...  
  var kind: MessageKind {
  ...
}

Hope it can be helpful :wink:

I just fixed by change to:

NSNotification.Name.UIKeyboardWillShow,
NSNotification.Name.UIKeyboardWillHide,



Thanks for this.

I assume there will be many more breaking changes in MessageKit going forward as well. You won’t run into this issue though by following along with the tutorial sample project and running pod install which will use MessageKit (0.13.1) from the Podfile.lock that this tutorial was written with.

You can of course continue to stay up to date with MessageKit, but it will be some additional work.

These modifications will make the tutorial work with Xcode 9, but I’d recommend using Xcode 10, since that’s what the tutorial was written for.

Hi naturaln0va,

I hope you can help me. I get 61 red errors from MessageKit when I run the code after installing Firebase/Firestore and the podfile in Xcode 10 Beta 5. I specifically installed MessageKit 0.13.1 in the pod file.

Example:
Controllers/MessagesViewController.swift:131:93:
‘UICollectionElementKindSectionFooter’ has been renamed to ‘UICollectionView.elementKindSectionFooter’

I only get the same errors as mubeeanasif01, when I run it as Xcode 9, who posted some days ago.

What should I do?

im using the latest Xcode 10 beta 5 with 50 errors in Starter project


1 Like

got the same problem. Pls help

Hey Guys I just finished up this tutorial. And there were some problems.

First of all with Xcode 10 Beta 5 there are some problems with opening the starter Project. As some people said there are 47-50 compile errors in the MessageKit Pod. This is because MessageKit was written in Swift 4.0 and Xcode 10 Beta 5 tries to compile it in Swift 4.2. In Swift 4.2 there were some changes to the Semantics of the language again.

So to make this work you need to go to your Pods in your left side Navigator in Xcode. Then select under Targets MessageKit. Then select Build Settings in the Top Menu. In Build Settings scroll down all the way to Swift Compiler Language . There you have to set the Swift Language Version from Swift 4.2 to Swift 4 . I have included a Screenshot to show you how this should look and how to find it (look at the highlights).

Another problem is in the uploadImage() function of the ChatViewController .

there is an issue at the completion at the bottom of the function in the Tutorial In : completion(meta?.downloadURL())

downloadURL() was deprecated for CloudStorage 16.0.1. Maybe the Author should update the example code.
Until then you could just use CloudStorage Version 15.0.2 in your Podfile :wink:

Hello @ricen, @gmanog, @tben2010 thanks for your patience. The tutorial has been updated to fix an issue related to how Xcode 10 handles the swift version MessageKit. Please re-download and re-run pod install.

Let me know if you have any other questions!

Thanks for your assistance!

The project have been updated to address this issue with Xcode 10 beta 5. You shouldn’t run into any deprication issues with downloadURL() using FirebaseStorage (2.1.2) which the tutorial uses according to the Podfile.lock.

But most of the developers use beta version of xcode (xcode 10). There should be support for xcode 9 as well