Xcode FIREBASE crashes - swift

I have recently upgraded to Swift 4.2 and I am not able to run my project anymore since then.
I had hundreds of mistakes which I all fixed, the app starts but crashes as soon as it tries to access data from my database
example code
guard let currentUser = API.User.CURRENT_USER?.uid else {return}
crash: Thread 1: signal SIGABRT
I had my app working for over a year now and thousands of users so the code worked previously quit fine.
I have updated my cocoa pods to the newest point, as my terminal said that firebaseauth requires at least 1.4 cocoa pods.
I have updated and newly installed all pods, I deleted my plist and downloaded it again and put it into the project, all to no avail.
My app is working if you download the old version from the App Store, but I want to update some things and need it to run again
Any advice? I have tried everything I found

For Firebase 4/5 and Swift 4, here's the function call to get the currently authenticated users uid
guard let currentUser = Auth.auth().currentUser?.uid else { return }

Related

Sudden error with Xcode 14 RC: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement

I just downloaded the Xcode 14 release candidate and I started getting the following crashing error on startup (didn't try the other betas). I made no changes in the codebase. CloudKit was working fine before:
[CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement.
Under Certificates, Identifiers & Profiles in the Developer portal, I've verified that push notifications are enabled.
To fix, I tried removing and re-adding the push-notifications entitlement.
I verified that the APS Environment value is in the entitlements .plist.
I switched off automatic signing and then turned it back on again. I cleaned the build and deleted derived data. I also tried switching back to Xcode 13.4.1 and everything started working again - unfortunately, not a solution.
The error occurs right as container.loadPersistentStores is called.
lazy var persistentContainer: NSPersistentCloudKitContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentCloudKitContainer(name: "not_real_name")
guard let description = container.persistentStoreDescriptions.first else {
fatalError("No descriptions found (AppDelegate.persistentContainer)")
}
description.setOption(true as NSObject, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
container.loadPersistentStores(completionHandler: {
(storeDescription, error) in
if let error = error as NSError? {
Is this just an Xcode beta bug (in the release candidate)? Is there a way to work around it?
I also just ran into this error today, on the Xcode 14.0 RC. It was on a basically brand new project so I figured it must be something odd with the new version.
To fix, I just did what the error said:
<key>aps-connection-initiate</key>
<true/>
Added that to the app's Info.plist, then it ran again just fine. Also SwiftUI previews started working again.
If you are facing this in simulator. Go to Device -> Erase all content ad settings.. And reinstall the app.
open .entitlements file
and then add "aps-connection-initiate" key and set the value to true
That worked for me

Firebase Connection Killed

I have integrated Firebase into my iOS project. I have been using Firebase for years across many projects. This specifically is using the Firestore. I can authenticate fine and write to the database. However, after the write is complete, even though it's successful, I receive the following message:
Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: Firebase error. Please ensure that you spelled the name of your Firebase correctly
The bundleID was copied and pasted directly from the app to the Firebase setup. I even deleted the app from Firebase and created it again. I have downloaded the GoogleService-Info.plist and I checked that the bundle there matches the bundle of the app. I can see nothing wrong here and again functionality is working fine.
The only instance I saw of this message browsing around was with a non-US based developer and it was suggested that additional config was required. However, that is not the situation for me. What else might cause this error to be generated?
The error message seems to point towards Realtime Database, despite your interest in Cloud Firestore.
I recommend:
Making sure you're using the latest SDK. Old SDK versions (before mid 2020) might require the Realtime Database URL to be present in the plist file, which isn't always the case anymore.
If step 1 doesn't solve the problem, you can:
Force the creation of a Realtime Database instance in the Firebase console.
Download the updated plist file and add it to your project.
If you end up with the second solution, can you comment with the SDK version you're using, so that I can check for issues in that?

Firebase issue - no response from Realtime database on iPod with iOS 8.3

I'm developing an iOS app written in Swift 3.0 using Xcode 8.2, which supports iOS 8.0 and higher. App's data is stored in Firebase.
I want to listen to database connection changes (app is connected to Firebase or not).
I'm using FIRDatabaseReference's function:
func observe(_ eventType: FIRDataEventType, with block: #escaping (FIRDataSnapshot) -> Swift.Void, withCancel cancelBlock: ((Error) -> Swift.Void)? = nil) -> UInt
to observe changes, but this event always returns false (value of 0). At this time (on Firebase Console), Authentication section related queries are working properly, and Realtime Database related queries are not.
This happens only on iPod 5.1 (5) with iOS 8.3.
I've tested my application on
iPad 2 with iOS 8.4.1
iPod 5.1 (5) with iOS 9.3.5
iPhone 6 with iOS 10.0.1
too. But on these devices it worked well.
Am I doing something wrong? Is there any issue related to iOS version and Firebase SDK?
Thank you!
SOLVED
I left this issue a little bit behind, and after some time, it reappeared on another device.
I'm not sure, if this solves every similar problem, but I figured out, that my token was expired and I get NO response from database. Which problem was caused by a password change of the same user on another device.
Day 1 - I was logged in with an account on two different devices. I changed my password on one of them.
Day 2 - I tried to download some data from Realtime Database section with the other device, but I get NO response, which was really annoying.
After 8 hours Firebase Analytics logs on Xcode console finally helped me figure out the problem. I logged out from the problematic device, and then logged in again.
I was wondering why couldn't I get some kind of 'token_expired'-response from the server, or maybe why couldn't I get logged out from the other devices.

Accessing data from core data when in location background mode

I have a app that get launched in the background mode by location region service , I would like to then display a local notification but I need to access core-data to get info for the notification and to query weather it should show the notification. every thing works but the query wont return any data when in the background , If it is not possible to access core-data at that time is there any other way I can store my data so I can read it while running in the background.
I did get this sort of working I think it is more of a issue with xcode 4.2 which is giving me issues I could access the core data file from the background mode only if I run the app from xcode then after I quit running I must open the app on the phone or simulator by clicking the app icon not the run button in xcode then close the app then the next time a run the app on the phone or sim by clicking the app icon not the run button in xcode then the application will access the core-data database. but local notification now wont work on the simulator unless I run form xcode which will then stop core-data access. I guess Im stuck with not being able to build this app till xcode 4.2 is at standard of xcode 3 where I could just get things to work.
Thanks for the comments I think Ive sorted it out , I did not have icloud on my iphone as its older one and I've been testing on simulator and thats is why Ive had this issue so if any one else has this problem the way to fix it is to start and stop your app in the simulator first as when you stop the app by clicking stop in xcode after running it kill the app the wrong way here is the log "9/02/12 12:46:52 PM Application '*App Name**' exited abnormally with signal 9: Killed SpringBoard[5273]" which then stops the app from accessing core data while in background , Ill send apple a bug report but I dont know if its something they want to fix . PS grate Site helpful thanks to anyone who answers Questions :)

Problem in updating app on iPad

I created an app for iOS 3.2 for the first version 1.0.
Recently I created an updated app for iOS 4.2 with print feature etc. for the second version.
My problem is that, the users are not able to update the app from appstore.
They are facing issues like data loss of version 1.0 app, crashing etc.
Can someone explain me what can be the reason for this?
And, how can I test this thing on my device, as I am not having the version 1.0 app from appstore, but the code for both versions.
Delete your new one on your test device and install the old one. Then build and debug the new one line by line. I had lots of trouble my first time through due to confusion over the update/migration process of core data. If you use core data, chances are your existing customers have an out of date store DB that your new code is crashing on. The store doesn't get wiped in an update if it's in your user's document directory... Only the one in the app bundle. You'll need to handle that reset or tell core data to migrate it to the new model. Of course, all this is speculation since you've given almost no details about the problem, frameworks used, log files, etc.
During a normal install process, data should not be overwritten. NSUserDefaults and files should remain during an upgrade, as long as the user doesn't delete the app first. I assume the crashing occurs after the new version is installed?