UIDocumentBrowserViewController doesn't call localizedName or honor shouldShowFileExtensions - ios

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.

Related

UnityAds in iOS using wrong game id, and not working

I am using UnityAds in my mobile game, to show a banner and a rewarded video.
In the editor and in Andorid works fine.
However for iOS it doesn't work, i took the logs and i noticed that for iOS is using my android gameid, this i have no idea where it comes from, i searched every file in my project, i never reference the android gameid, just the iOS one.
So it is clearing taking the id not from my initialization but from some sort of cache, anybody has an idea where is taking the gameid from? thanks
Btw
I am using Advertisement package from package manager.
You can open manually Project Folder\ProjectSettings\UnityConnectSettings.asset in text or code editor, then find
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_IosGameId: <---- THIS ONE
m_AndroidGameId:
m_GameIds: {}
m_GameId:
and edit it

QLPreviewController Doesn't Show Document

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.

ReplayKit's RPSystemBroadcastPickerView not showing preferredExtension

I am using RPSystemBroadcastPickerView to show a picker view, from which a user can select a broadcast service to record the screen. Based on documentation, preferredExtension should allow me to set which broadcast extension should the picker show.
The code is super simple:
let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 51, height: 51))
view.addSubview(broadcastPickerView)
broadcastPickerView.preferredExtension = "com.milan.nosal.broadcast-extension"
broadcastPickerView.backgroundColor = .clear
broadcastPickerView.showsMicrophoneButton = false
where "com.milan.nosal.broadcast-extension" is the bundle identifier of the extension I want the picker to offer (I checked its correctness multiple times).
However, when the control is tapped, at first the pop up shows empty selection:
After you close it, and tap the control again, it shows the correct extension. This only happens when the app is installed (or reinstalled), after it shows, then it shows always.
Is this the iOS 12 beta bug, or am I doing something incorrectly? Can I "preregister" the extension to work around this?
EDIT:
After publishing the app, we encountered the same problem with our users, but this time not even tapping the control multiple times helps - the picker is always empty! It seems that the extension is installed correctly, because it can be launched from control center.
Running on official release now.
Note that this is for ANY iOS Version:
I just burned a full day on this. When you add the BroadCast extension, Apple will automatically add the highest possible iOS Version for the deployment target. You need to make sure this isn't higher than your physical device's iOS Version. You won't get any build errors, they just won't show your app in the broadcast extension list.
I think it is the apple's bug, but it was fixed in iOS 12.2 after I tested it.
I have the same issue, looks like Xcode has some issues how to install broadcastExtension with you app. For me, It is related only for Debug mode. To see correct UI, try to enable broadcasting once in old way (control center -> deep touch -> start broadcast), after that in your BroadcastPickerView you will see correct UI (you are pushing iOS to update information about the extension). Cannot reproduce in release mode.
You can find your exactly preferedExtension here:
When you add pickerView.preferredExtension exactly the Bundle Identifier, your app will be showed on the Recording App List. Hope this helps!
If I do not set ".preferredExtension", I see all extensions on the list.
I tested on iOS12 GM.
You add Broadcast Upload Extension into your project and get that Extension Bundle Identifier.
How to create Broadcast Upload Extension into your app?
Go to xcode - File - New - Target - Broadcast Upload Extension
Then Add this line into your app. when you created RPSystemBroadcastPickerView object.
broadCastPicker?.preferredExtension = "com.vikrant.YourApp.Extension"

Xamarin Forms error - 'You MUST call Xamarin.Forms.Init(); prior to using it' - TestFlight (iOS) only

I've seen several other posts on SO and elsewhere about this error (System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it. at Xamarin.Forms.Device.get_PlatformServices), but none of them shed any light on my particular situation.
I've created a Xamarin.Forms application that works great on Android (emulators and device, including when distributed through Google Play), and works fine both on the iPhone simulator and when provisioned to the iPhone. And when I say 'works fine', I mean 'is able to get to the MainPage without error.'
However, when I use Ad-Hoc deployment and upload it to Apple so it can be distributed with TestFlight, the TestFlight-downloaded version shows the splash screen as expected, and then crashes without ever showing the MainPage. In looking at the device logs, the above error appears, and in doing some Internet research, it's become apparent that my AppDelegate needs to have global::Xamarin.Forms.Forms.Init(); as the first line in the FinishedLaunching() method.
So I went to take a look and put that line in that method in that file, and lo and behold, it's already there. This is not unexpected, given the fact that the app works on the sim, and on the iPhone when deployed directly from Visual Studio.
So my question is 'Why does Ad-Hoc deployment fail when all other deployment types do not, and what can I do to overcome this problem and get the app to actually distribute through TestFlight in a runnable fashion?'
I was able to resolve the issue by putting the command (global::Xamarin.Forms.Forms.Init();) first thing in every constructor in every class in the iOS platform-specific services. It's possible that only one was really necessary, but it doesn't seem to have caused any issue to over-deploy that particular command, and in the case that more than one of the services is called before the AppDelegate's FinishedLaunching() method is called, that would seem to be necessary in the first one called, which could potentially vary by program flow, depending on environment and other variables that may be checked.
In .iOS project make sure the line
"global::Xamarin.Forms.Forms.Init();"
is the first line in the event
"public override bool FinishedLaunching(UIApplication app, NSDictionary options)"
in
"AppDelegate.cs" file.
In .UWP VB project make sure the line
"Xamarin.Forms.Forms.Init(e)"
is after the line
"AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed" in
"Protected Overrides Sub OnLaunched(e As Windows.ApplicationModel.Activation.LaunchActivatedEventArgs)" event
in "App.Xaml.vb" file.
In .Android project
"global::Xamarin.Forms.Forms.Init(this, savedInstanceState);"
is after the line
"base.OnCreate(savedInstanceState);"
in "protected override void OnCreate(Bundle savedInstanceState)" event.
Hope this helps.

iOS UIDocumentInteractionController, presentOptionsMenuFromRect fails, but presentOpenInMenuFromRect works

Whenever I try show the UIDocumentInteractionController with the method presentOptionsMenuFromRect no file is attached in the opening app and I get this in the console:
Couldn't get file size for (null): (null)
But if I test with presentOpenInMenuFromRect it works perfectly fine. I also use presentPreviewAnimated with its delegates and this works too. Also tested successfully switching to an UIActivityViewController. The file I try to open is a PDF stored in the local documents directory
let documentInteractionController = UIDocumentInteractionController.init(URL: url)
documentInteractionController.presentOptionsMenuFromRect(self.view.bounds, inView: self.view, animated: true)
Xcode: 7.3.1 (Swift)
iOS: 9.3 tested with simulator and device, deployment target is 8.0
Thanks
This happens because in your code, the UIDocumentInteractionController instance might be being released by reaching the end of a function, while it's needed to let the other app handle the file properly after selecting an option from the menu.
To avoid this problem, we need to store a strong reference to our document interaction controller in a place that will exist for the lifetime of the object's owner (i.e. a global variable) in order to keep it alive.
Note: Apparently, this behavior does not occur with some of the options from the Open In menu nor by sharing with AirDrop.

Resources