iCloud UIDocument opening fails after update on iOS 13 - ios

I have a simple UIDocument subclass with overriding load and contents functions.
Before updating on iOS 13 json document was saved in url "/private/var/mobile/Library/Mobile Documents/iCloud~appbundle/Documents/EFB7FCBA96684AC0B101E3CD829E6996.json"
In current iOS version 13.2.2 (after updating) this document does not open:
let cloudDocument: ICloudDocument = ICloudDocument(fileURL: url)
cloudDocument.open { (openSuccess) in
if openSuccess {
success()
} else {
// in my case openSuccess is false
failure()
}
}
Debug information.
After overriding handleError in ICloudDocument
override func handleError(_ error: Error, userInteractionPermitted: Bool) {
print("userInteractionPermitted - \(userInteractionPermitted)")
print(error)
}
in console:
userInteractionPermitted - true
Error Domain=NSCocoaErrorDomain Code=256 "The file “EFB7FCBA96684AC0B101E3CD829E6996” couldn’t be opened." UserInfo={NSURL=file:///private/var/mobile/Library/Mobile%20Documents/iCloud~appbundle/Documents/EFB7FCBA96684AC0B101E3CD829E6996.json}
If I use cloudDocument.read method in ICloudDocument it works well with receiving data from file, but open throws the error.
DocumentState cloudDocument.documentState of document is closed.
File options:
> print(FileManager.default.isWritableFile(atPath: url.path))
true
> print(FileManager.default.isReadableFile(atPath: url.path))
true
URLResourceKeys:
URLResourceKey.ubiquitousItemIsUploadingKey - true
URLResourceKey.ubiquitousItemIsUploadedKey - false
URLResourceKey.ubiquitousItemUploadingErrorKey - nil
URLResourceKey.ubiquitousItemHasUnresolvedConflictsKey - false
URLResourceKey.isUbiquitousItemKey - true
URLResourceKey.ubiquitousItemDownloadingStatusKey - "NSURLUbiquitousItemDownloadingStatusCurrent"
I found one link about this problem without answer
https://forums.developer.apple.com/thread/126889
Any ideas?

Restaring iOS solved this problem. I think that after updating into iOS 13 and migration, system needs additional reload.

Related

EXC_BAD_ACCESS error in swift with getting data from firebase

I am connecting to Firestore from iOS.
But when I ran this code it gave me a EXC_BAD_ACCESS error.
db.collection("chats").document(code).setData(["users":[Constants.User.currentUID!]]) { (err) in
if err != nil{
print("error registering with firebase")
}
else{
//...
}
}
So I went to the scheme editor and enabled the Address Sanitizer.
The error I got was highlighting code and said:
Thread 1: Use of deallocated memory
When I click on code it does show its correct value of QAWQ
What do I do?
EDIT
Under further investigation it is wherever the variable code is used

RPScreenRecorder stopRecording block not getting called

I have searched enough but failed to get a solution.
I am using ReplayKit to record the screen of my app. I have started recording the screen by calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.startRecording() { error in
if let error = error {
self.showScreenRecordingAlert(message: error.localizedDescription)
}
}
When I am pressing the stopRecord button I am calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}
}
But the issue that I am facing is, the program control does not enter inside the stopRecording block.
When I am doing po sharedRecorder.isRecording, it always returns false.
I have done everything I know but failed to get a solution.
If you having this above issue with your code i have found the solution for this.
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}}
Above Block will not call if you running your app on simulator so please use real device to test then above method will call definitely.
Thank you.
Just had this issue running XCode 9.4.1 and building onto iOS 11.4.0. Upgrading the phone to iOS 11.4.1 fixed the bug. I'm not sure if the difference in XCode versions is the root cause or if 11.4.0 was just broken.

Crashed: com.apple.root.default-qos

I have a fairly simple app that parses a RSS feed and shows it's content in a table view. It's available on the App Store. I have Crashlytics crash reporting integrated. I recently received two reports. These are a little difficult to decipher.
This has occurred in an iPhone 6 running iOS 10.2.1.
This is from an iPhone 5 running iOS 10.2.1.
Even though it says it's crashing due to privacy violations, I'm not accessing any services that requires permission in my app.
Also searching on com.apple.root.default-qos lead me to believe that this may have something to do with background threads. The only place where I use a background thread is to parse the RSS feed data.
DispatchQueue.global(qos: .background).async {
guard let data = try? Data(contentsOf: URL) else {
return
}
do {
let xmlDoc = try AEXMLDocument(xml: data)
if let items = xmlDoc.root["channel"]["item"].all {
self.posts.removeAll()
for item in items {
let title = item["title"].value ?? ""
// ...
self.posts.append(jobPost)
}
DispatchQueue.main.async {
self.saveposts(self.posts)
self.posts.sort { $0.publishDate > $1.publishDate }
self.tableView.reloadData()
UIApplication.shared.toggleNetworkActivityIndicator(show: false)
self.toggleUI(enable: true)
if self.refreshControl.isRefreshing { self.refreshControl.endRefreshing() }
}
}
} catch let error as NSError {
print("RSS parsing failed: \(error)")
self.showErrorAlert(error)
UIApplication.shared.toggleNetworkActivityIndicator(show: false)
self.toggleUI(enable: true)
if self.refreshControl.isRefreshing { self.refreshControl.endRefreshing() }
}
}
I tested this code on my iPhone 5 running iOS 9.3.5 and simulators running iOS 10.2 but no crash occurred.
Is there any other way to track down this problem?
I would double check all your permissions. In my case, starting with iOS10 you need permissions to save stuff to the user's camera roll. In my app, I was showing a default share sheet and whenever a user selected "save photo" the app crashed with one of these very not helpful error messages. I added
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Allow you to save charts and graphs from the app to your phone.</string>
to my info.plist, clean & run. And everything the problem was solved.

Firebase Storage not working on iMessage extension

I am trying to integrate Firebase into an iMessage extension.
As a test, I am setting up Firebase and trying to save a local file to Firebase Storage in the viewDidAppear method. The Firebase Real-time Database works fine in the code below, only the storage part does not.
The exact same code works when done in a normal app (i.e. not a iMessage extension).
I get the following error message:
Error Domain=FIRStorageErrorDomain Code=-13000
"An unknown error occurred, please check the server response."
UserInfo={ResponseErrorDomain=NSURLErrorDomain, object=test.jpg,
bucket=myapp.appspot.com, ResponseErrorCode=-995,
`NSLocalizedDescription=An unknown error occurred, please check the server response.
I am doing the following:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
FIRApp.configure()
FIRAuth.auth()?.signInAnonymously { (user, error) in
guard let fileURL = Bundle.main.url(forResource: "test", withExtension:"jpg") else { return }
let storageRef = FIRStorage.storage().reference().child("test.jpg")
storageRef.putFile(fileURL, metadata: nil) { (metaData, error) in //produces error
if error != nil {
print(error.debugDescription)
}
}
FIRDatabase.database().reference().updateChildValues(["someKey" : "someValue"]) // works fine
}
}
I have a suspicion that iMessage extensions may get limited access to the file system (since they live in a different sandbox than the normal app), and thus getting the file wouldn't work. In this case putData works, but putFile doesn't. Solution: always upload and download in memory (putData and dataWithMaxSize:) vs the file system (putFile and writeFile).

Swift - Core Data: destroyPersistentStoreAtURL throwing error

I want an option in my app to reset all of my data. I created a class named CoreDataStack and put all of my core data code in it with this function:
func dropAllData() throws {
try persistentStoreCoordinator.destroyPersistentStoreAtURL(applicationDocumentsDirectory, withType:NSSQLiteStoreType , options: nil)
try addStoreCoordinator(NSSQLiteStoreType, configuration: nil, storeURL: applicationDocumentsDirectory, options: self.options)
}
I then have this function in my AppDelegate:
func dropTables() {
do {
try stack.dropAllData()
} catch {
print(error)
}
}
I've used this function before to delete my data with success, but suddenly I can't delete anything and I keep receiving this error when I call dropTables().
Error Domain=NSCocoaErrorDomain Code=134000 "(null)" UserInfo={NSURL=file:///Users/myname/Library/Developer/CoreSimulator/Devices/59E4B2FB-E0E4-4527-8793-253864A2DE83/data/Containers/Data/Application/33D1C5CF-94B8-4897-A77F-A10DDFEF92D6/Documents/}
I've tried searching for this error and couldn't find anything (or I'm just looking in the wrong places). I also tried deleting the app from the device, reinstalling, and trying again but get the same result. Does anyone know what this error is and why can't delete my database?

Resources