QLPreviewController Doesn't Show Document - ios

I'm trying to get QLPreviewController to display a pdf document. When the document is saved to the device the file location string (within the documents folder) is recorded. I later create a URL from that file location string with URL (fileURLWithPath: location) and use that as input for a QLPreviewController data source. Up until now, that worked and the quick look would present with the document properly.
Unfortunately, that no longer works. I updated to Xcode 11 (swift 5.1) this morning, and now my QLPreview controller doesn't show the document. It still presents, but with a gray background that says "Document name" and "pdf document." If I click the share button and go to print it, the print preview correctly shows my file (and pushing print does print the correct file in its entirety) so I know the file is there, and is readable. It just won't display in the QLPreviewController for some reason. (This error is also reported on the apple developer forums, but nobody there had any suggestions to fix it other than trying on a non-simulator device which I've already done.)
The debug text from Xcode is as follows:
Could not create FPSandboxingURLWrapper with url: file:///Users/username/Library/Developer/CoreSimulator/Devices/F69CC8ED-C164-4E36-946F-E675C7FC7365/data/Containers/Data/Application/739F1371-1A79-41B1-8FF5-E8ACC0FEA976/Documents/mydoc.pdf, error: Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read for '/Users/username/Library/Developer/CoreSimulator/Devices/F69CC8ED-C164-4E36-946F-E675C7FC7365/data/Containers/Data/Application/739F1371-1A79-41B1-8FF5-E8ACC0FEA976/Documents/mydoc.pdf': Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read for '/Users/username/Library/Developer/CoreSimulator/Devices/F69CC8ED-C164-4E36-946F-E675C7FC7365/data/Containers/Data/Application/739F1371-1A79-41B1-8FF5-E8ACC0FEA976/Documents/mydoc.pdf': Invalid argument}
Something else that might be of note: I was getting similar error messages before in a previous iteration of my code, and I figured out the problem was that I was passing a url from string instead of a fileurlfrompath, and changing to that fixed my problem. I suspect this is just a different problem, but the error messages were similar so I thought id mention it. Any suggestions would be greatly appreciated.

Related

UIDocumentBrowserViewController doesn't call localizedName or honor shouldShowFileExtensions

I am using Xcode 14.2 on macOS Ventura 13.2, working on an iOS app initially created from Xcode's template via New Project > iOS > Document App. I am using Objective-C, not Swift. I am testing in the simulator's "iPad Pro (12.9 in) 6th Generation - iOS 16.2" module.
The template created a UIDocumentBrowserViewController subclass and a UIDocument subclass, which I've been filling in.
I have two problems.
First, the document browser is ignoring its own shouldShowFileExtensions property. I have it set to NO, and I have checked that it is still NO later during runtime; but the browser view still displays filename extensions.
Second, I'd really rather the browser displays the UIDocument.localizedName string instead of the filename. This is a read-only property of UIDocument which is supposedly overridable by the subclass to return whatever string you'd like. My UIDocument subclass's override is never being called.
The override looks like this:
- (NSString*)localizedName
{
return [self projectName];
}
I am not doing anything weird with my subclasses; I've done my best to follow Apple's guidelines and documentation meticulously. My app will create documents that later appear in the browser, and which can be opened again and displayed, so the basics are working; but I have no control over the display name of the documents in the browser.
What am I doing wrong? Thanks in advance for any help.
localizedName is not used by the document browser, or it would have to create a UIDocument for every file in the directories the user visits! This would have a huge performance impact. LocalizedName is only used, as explained in the documentation, to display the document’s name after it is open in error messages and the like.

UIAutomatorviewer throws error

I need your support to remove this error which is keep on coming while I'm using uiautomatorviewer.bat file for inspecting elements. It is working for only static page of an application. When i was taking screenshot of a page where numeric value is display & it is changing dynamically it throws same error again.
Error :
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
Dynamic Page Image
Following things i have already tried but it didn't work :
Stop Appium server in the background.
Disconnected mobile device & connect it back.
Close the uiautomatorviewer.bat file & restart it again.
Please guys help me!!
Thanks in advance.

Error launching 'Watchkit extension" - SPErrorUnknownMessage

Trying to run Watchkit - Notification. Receiving the following error:
Error launching 'Watchkit extension" - SPErrorUnknownMessage
Has anybody else come across this error before or knows what it means? Haven't been able to find anything online about it.
Cheers,
A
I have seen this issue and it was related to an error in the structure of my .apns file - there was a comma missing in the json. Once this was corrected, notifications worked again.
Try looking for errors in the Payload apns file that you are using for this target.
I got this message when I removed the file PushNotificationPayload.apns from the WatchKit Extension in Xcode.
Take a look into the Run-Section the Schema: If the Watch Interface entry shows something like Dynamic/Static Notification, it will likely expect some apns-file as notification payload. If that file is missing (or faulty as for Gavin Potts), you'll get that error.
So either fix the apns file, or change the Watch Interface entry to Main or sth. else.
This error occurs due to PushNotificationPayload.apns. Sometime closing quote may be missing.

Failed to generate disassembly for stack frame because the URL cannot be translated

I have an app which can open a CSV file sent from an email and it display its content within the app in a different format (note that I cannot post the code used to do this).
However, every once in a while (about 2 times out of 3!), when importing a CSV from the email, the app freeze, the code is displayed as if I had a breakpoint in appDelegate, and when I press run in the debugger, the screen in Xcode becomes grey and displays the following message:
Failed to generate disassembly for stack frame because the URL cannot be translated: x-xcode-disassembly://stack_frame?
Does anyone knows what this message is and what could be the reason for it?
Note: I am using Xcode 7, and run the app in a mini iPad with iOS 9. (not simulator)
Thank you.

Fresh SpeakHere example app has error when recording audio in Simulator/Xcode

I can't record audio using the SpeakHere example app from apple. When I run the app in Simulator from within Xcode, it starts up normally, but when I press the record button, the error "Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)" occurs:
The log message about the missing root view controller at app startup is already there BEFORE the above error occurs and it is probably not connected to my problem.
I have downloaded the SpeakHere example project from the linked website (see top of this question), opened the fresh download in Xcode and directly started the app. I did not modify any setting and not any line of code. I've also searched on google and stackoverflow for this problem and didn't find a solution, although this problem must be very general.
I use Xcode Version 4.5.2 (4G2008a) and a MacBook Pro from late 2009 with Mac OS X 10.8.
I've also had a friend try this on his computer and he has the very same problem. He has the same OS and his XCode version is also 4.5.2.
I would now try older Xcode versions, but right now I don't like to download a few gigabytes for a trial'n'error approach on my connection.
Any help appreciated, including reports like "works for me with Xcode version ...". Thanks!
The problem occurs because in the method AQRecorder::StartRecord(CFStringRef inRecordFile), the function CFURLCreateWithString() fails and returns a pointer to nil. This is not detected and later on the code calls CFRelease() on this nil pointer, which causes the EXC_BREAKPOINT.
The purpose of the method CFURLCreateWithString() basically is to take a url string as input and return a pointer to a CFURL object as output. The problem here is that the input is not a url string. Instead, it's simply a path on the local file system without file:/ or the like as prefix. For this reason, this method fails.
The solution is to remove the not-working call to the method CFURLCreateWithString() and instead call a related method, namely CFURLCreateWithFileSystemPath(), which is prepared to take a local file system path and convert it to a CFURL:
In the method AQRecorder::StartRecord(CFStringRef inRecordFile), replace or comment out the line
url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);
and insert
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);
at its place.
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);
The code above made my xcoce 4.6 compile and run in simulator, but it doesnot record my voice from my usb microphone, I test my microphone in the garash band application and sucessfully record and play my voice, and the dbmeter does not move at all, any way when I port it to the real device it work, it just can't record and play voice in my simulator.

Resources