Learn Courses My Dashboard

Firebase Rules.. the final step to launch

Hello! I am one step away from launching my first app! I need to implement a method for users to block one another within my app. I think I can make this possible by configuring Firebase Firestore Database rules. As of now I have a method for users to add the user_id of the user they want to block to an array, but I need make it so they now can’t see content from that user.

** Main question*

How can I reference my Firestore Database data within the Rules of my database… I have looked everywhere and watched a lot of YouTube

I’m trying to allow users to block one another through Read conditions.

My app is crashing due to reason -[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x600002164870’

Few hours ago I had the same error during taking my first steps with Firebase. I had no idea how to find solution but after few hours of debugging I noticed that the problem occurs when I had initialized project with Firebase using dependency manager built-in in the Xcode and then I tried to initialize Firestore using CocoaPods. To be more specific, first thing I do was Firebase installation using this one:

Then, I started using CocoaPods like:

$ pod init
$ vim Podfile // adding 'firebase/firestore' dependency or specific line from https://github.com/firebase/firebase-ios-sdk
$ pod install
$ open <ProjectName>.xcworkspace

In the next step, I tried to check basic Firestore operations like creating collection and documents with data and when I run the app - I got similar error. It was an exception during app run.

I think in my case the problematic thing was possible duplicates because of supplying the project with a Firebase (with all dependencies) twice.

So, I removed dependency installed from the Xcode manager. In my Info.plist there is no dependencies:

Then, from the terminal I removed Pods directory and just called an update.

$ rm -rf Pods
$ pod update

All dependencies were re-installed and workspace has been recreated.
Now, after these steps everything works fine.

You should NOT be installing Firebase with Cocoapods and swift package manager. You should only use one

Exactly. That is why I shared this information and described the problem for other people who could make the same mistake in the future :slight_smile:
When I followed your video I decided to do an initial step on my own, based on instruction provided by Firebase. After that, when I noticed a difference, I decided to do it in the same way as is presented in the CWC tutorial. That is why I had two versions installed from different places.

One difference in Firebase between current version and the version from the end of 2020 (when the CWC video was recorded) is presented underneath:

Current version (screen from the official documentation):

Instruction from the video:

Earlier, Firebase proposed to use Pods but now it promotes adding packages via Xcode.