Swift 4 project in Xcode 9.2
I'm trying to use Firestore in a project. I've added the libraries and cut and pasted the sample code from the FireStore intro guide. But I'm getting an EXC_BAD_ACCESS and have not been able to figure out why. Here's the code I'm trying to run:
let db = Firestore.firestore()
var ref: DocumentReference? = nil
ref = db.collection("users").addDocument(data: [
"first": "Ada",
"last": "Lovelace",
"born": 1815
]) { err in
if let err = err {
print("Error adding document: \(err)")
} else {
print("Document added with ID: \(ref!.documentID)")
}
}
And here's a screen dump of the error:
ANyone have an idea as to what's going wrong?
Same problem over here. Everything used to work fine untill the last iOS SDK update. If I write data to firestore they are not shown in console, sometimes after a few minutes or a hour.
App crashes on this message every few minutes:
2018-01-09 10:10:17.284630+0100 spontRestaurantAppIos[18971:19308343] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: closeWithFinalState should only be called for a started stream that has an active delegate.'
I've contacted firestore support and this is what I got back:
Upon checking, this a known bug with our iOS SDK. This is now on our radar and our engineers are currently on it.
For any updates, please watch out on our release notes.
So I guess we'll just have to wait... anybody have other suggestions?
Also see this issue in github:
https://github.com/firebase/firebase-ios-sdk/issues/596
In my case, I don't get a error for 4 minutes. Then it crashes with
2018-01-09 21:11:23.584982+1100 Crux[2671:334948] *** Assertion failure in -[FSTWriteStream closeWithFinalState:error:], third_party/firebase/ios/Source/Firestore/Source/Remote/FSTStream.m:348
Still no idea why.
I just figured out that the error was due to the database rules not allowing access. I opened up the rules to allow public read write and it's now working.
Related
Edit3: Okay, it seems like it's an issue with Firebase, someone else tweeted about having the same issue. I also contacted support.
A piece of Swift code that handles creating documents suddenly stopped working. No errors are thrown, Firebase doesn't complain in the log and I can verify from the console that the document is not created, I can verify that the device has a healthy internet connection. I also disabled offline persistence for Firebase just to be sure.
When I try debugging it, the debugger jumps straight over the block that handles errors or successes, never running it (i.e. never finishing the Firestore request?).
Here is the code
func createConversation(){
let conversation : [String : Any] = ["owners" : [
UserProfile().getProfile().uid!],
"seeking" : true,
"timestamp" : Timestamp(date: Date())
]
var ref: DocumentReference? = nil
ref = DB().firestore().collection("Conversations").addDocument(data: conversation){ err in
if let err = err {
print("Error creating a convo: \(err)")
} else {
print("Conversation created with ID: \(ref!.documentID)")
StateMachine().action(a: .seekingStarted(ref!.documentID))
}
print("Conversation Creation finished")
}
let documentID = ref?.documentID
print(ref.debugDescription)
}
I'm not sure how to approach this issue, any ideas?
Edit: Okay, the issue is not limited to this block of code, it looks like Firebase is not communicating with the servers. I've waited for more than 5min for the addDocument to return(with error or success) but that never happened.
I noticed that at the initiation of the App BoringSSL complains a bit but this is not new and I don't have problems with the other Firebase services, they work just fine - reading and creating data with no problems.
Edit2: Apparently I can fetch collections and documents from Firestore, the issue seems to be limited to document/collection creation.
The document creation operation takes a little time, if you place the breakpoint inside the asynchronus completion block you will surely get an error or success.
I found a post that has the same error in the same situation here:
https://groups.google.com/forum/#!topic/audiokit/SmyuzPJQ6wU
Same as this poster - I'm using the source. However, at the end of the post the user does not say what he did to fix the issue.
I'm currently using an unaltered "ExtendingAudioKitUsingSource" example as I need to add some functionality to audiokit. (unaltered outside of using my provisioning profile and adding "let m = AKMicrophone()" in ViewController.swift.
I receive these errors:
2018-08-31 15:16:50.684 ExtendingAudioKit[6800:8850964] 15:16:50.683
ERROR: [0x39058000] AVAudioIONodeImpl.mm:452:
___ZN13AVAudioIOUnit9EnableBusEm_block_invoke: error -10849
2018-08-31 15:16:50.688 ExtendingAudioKit[6800:8850964] ***
Terminating app due to uncaught exception
'com.apple.coreaudio.avfaudio', reason: 'error -10849'
which traces back to line 46 in AKMicrophone.swift to init(): AudioKit.engine.connect(AudioKit.engine.inputNode, to: self.avAudioNode, format: nil)
I've had no issues using AKMicrphone() outside of this project.
I have fixed an AKMicrophone bug in AudioKit v4.5.1 that may have fixed this for you. If not, I'll withdraw this answer, but please check it out and let me know.
I updated firebase and since then my app keeps crashing with the following error
Fetcher delegate class: NRMAURLSessionTaskDelegate Fetcher made an
extra session: GTMSessionFetcher 0x125d53db0 Couldn't assign
delegate.
Fetcher delegate class: NRMAURLSessionTaskDelegate
-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x125d53db0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher
setFetcher:forTask:]: unrecognized selector sent to instance
0x125d53db0'
* First throw call stack: (0x18260ad8c 0x1817c45ec 0x182618098 0x1826105c8 0x1824f641c 0x104637b14 0x104613928 0x10461011c
0x102d9364c 0x102d96bdc 0x102d95140 0x102d92a54 0x102db3f90
0x102db36b0 0x102da0e00 0x105bfd1dc 0x105bfd19c 0x105c0bdfc
0x105c006ac 0x105c0bc20 0x105c006ac 0x105c0cd54 0x105c13e38
0x18222fe70 0x18222fb08) libc++abi.dylib: terminating with uncaught
exception of type NSException
the call that I make and crashes is the following:
let reviewsRef = Database.database().reference()
reviewsRef.child("reviews").queryOrdered(byChild: "timestamp").queryLimited(toLast: count)
I added a debug log and the call is made only once.
It seems the line that the app is crashing is
let ref = Database.database().reference()
Did anything changed regarding configuring Firebase from 4.9 to 5.0 version?
Another update:
It seems to be working on the Xcode simulator but not on device. Device is iPhone 6s with 11.4
Kind of working since on simulator I receive the whole database instead of only the "reviews" that I am requesting
if the rules are:
{
"rules": {
".read": true,
but when I change to:
"rules": {
"reviews": {
".read": true,
I get permission denied(on simulator).It has to do maybe with authentication? I understand that those 2 might be two different issues.
I have no idea why this happened on the first place. But I created a new project in firebase with exact same rules and it worked... for some reason the specific project became corrupt on firebase side.
NRMAURLSessionTaskDelegate indicates usage of New Relic - if it worked on a clean project there might be an incompatibility with Firebase
I'm using:
iOS - Swift 4
Cocoapods 1.4.0
Firebase (5.4.0)
FirebaseCore (5.0.5)
FirebaseStorage (3.0.0)
When I'm running the attached code, my app crashing with signal SIGABRT error at the AppDelegate class and prints libc++abi.dylib: terminating with uncaught exception of type NSException in the console.
I'v tried to run some debugging and what I found is that the problem occurred in the imageReference.delete{ (error) in } method.
*Note that it didn't enter to the block at all, it failed in the method itself and because of that the image is not deleting from Firebase console when I'm calling to the delete method.
My code:
func deleteImage(for url:String){
print(url) // https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/itemsImages%2F225121501531684886976.jpg?alt=media&token=token
let imageReference = Storage.storage().reference(forURL: url)
imageReference.delete { (error) in // Fails here with: libc++abi.dylib: terminating with uncaught exception of type NSException
print("completion") // Not getting to this point
if let error = error{
print(error)
}
}
}
Edit:
After very deep digging I'v understand that my problem is that I'm calling this method via closure at some point of the "events' tree" (I'm calling some function that calling to another function that calling to the delete method from closure) and thats what cause the problem.
Now the question is how can I call it via this closure without make this error? (I can't call it outside of it)
I'd start by asking if you have a strong reference to that image somewhere else ?
Or is the image being used in a UIImage Control?
At the end the problem was with the UITableView itself and not with Firebase.
I didn't update the UITableView's data array correctly and that produced this crashing. I wasn't aware of it because the errors in xCode's console were disabled from some reason (Those answeres helped me to enable it back: #1, #2).
Hope anyone else that will face with wired error like that (without enabled error logs, of course) will be able to use my unpleasant experience and find the solution faster and easier.
I'm developing in Swift using the latest version of Parse from the website. I am attempting to set my cache policy to the NetworkElseCache value, which is displayed below:
let userRelation = User.currentUser()?.relationForKey("friends")
let userQuery = userRelation!.query()
userQuery.cachePolicy = .NetworkElseCache
userQuery.findObjectsInBackgroundWithBlock {
(users, error) -> Void in
print("Success")
}
The error occurs on the line:
userQuery.cachePolicy = .NetworkElseCache
and if the line is removed, the application runs fine, the error produced is:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Method not allowed when Pinning is enabled.'
I really don't have any idea what to do from here, I only started iOS development about a week ago using Parse and Swift, so I'm a bit on the lost side. I don't understand the callstack either, or how it will help me find my problem.
Disable the LocalDataStore in your AppDelegate.m
So comment following line
Parse.enableLocalDatastore() // Comment this line and try
Here's the full explanation from the engineers at Parse. But yes, long story short, if you're using local datastore, you will not be able to also use different cache policies.