Trouble getting Firebase working

Hi,

I am new to Firebase and I’m trying to get it working.

I followed the documentation and created a new app on the Firebase website and got the plist file. I then got the dependency in my projects list. I then added the initialization to the main init(). when I run I get a Lua error “attempt to index global ‘firebase’ (a nil value)” on the set callback line.

firebase.set_callback(function(self, message_id, message)
		if message_id == firebase.MSG_INITIALIZED then
			firebase.analytics.set_callback(firebase_analytics_callback)
			firebase.analytics.initialize()

			-- log data
			firebase.analytics.log_string("TestEvent", "Test", "Test Good")
		end
	end)
	firebase.initialize()

In my output window I do see these entries:

INFO:Firebase: Registered extension Firebase (null)
INFO:FirebaseAnalytics: Registered extension Firebase Analytics (null)

Any pointers or info would be appreciated.

Thanks,

Tom

1 Like

Hello! :waving_hand::blush:

If you see this output I assume you added library as dependency and fetched it, so this is weird - are you sure you didn’t overwritten “firebase” somewhere by mistake? If not, I will look into this tomorrow :wink: Please send me a repro project if possible :blush:

I made a new mobile project, and just added the dependency and tried accessing it in main.

I got the same error, but I did not add the plist file. If that is not setup correctly would it cause the ‘firebase’ object to be nil?

If so maybe I have something wrong with my plist file?

looking at it I see that the bundle id looks correct. I did see this:

	<key>IS_ANALYTICS_ENABLED</key>
	<false></false>

but that shouldn’t cause the base firebase object to be nil, correct?

Im not sure what else in the plist I should be checking. (if this is even the problem)

Tom

1 Like

Are you testing this on device? The firebase.* namespace is only available on iOS and Android. You can check this before trying to interact with firebase:

function init(self)
    if firebase then
        firebase.set_callback(....)
    else
        print("Firebase is not available")
    end

Oh, I’m so stupid. That’s probably it. :frowning:

Actually I’m running into an new problem: I can’t get my iOS app sent up to TestFlight. It is rejecting it due to the MinimumOSVersion (looks lit it’s set to 11). Looking around online it looks like maybe the minimum version is now 15.

It looks like it’s hard-coded into your builtins. Is there an easy way for me to change that? Or should I make my own?

Tom

Make a copy of Info.plist into your project, make the change and reference your copy in game.project

OK, testing on the correct platform :stuck_out_tongue: it seems to be working. My debug print is showing that it’s setup at least. I now have to figure out what’s going on with firebase. But I am moving forward. Sorry to have you waste time with my stupid mistake.

As to the info.plist: I couldn’t just copy the version from builtins. It has some special tags. presumably so that the build system fills in the correct data from the project file. These tags show up as a malformed plist file. I was able to take the filled in plist out of the app file (right clicking and choosing “Show Package Contents”) and copy and change that.

Again, sorry for wasting your time

Tom

Correct. When we build your game for iOS these tags get replaced with values taken from game.project etc. You can leave them in. It will work.