-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[iOS/MacCatalyst] Use newer API in FilePicker #27521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS/MacCatalyst] Use newer API in FilePicker #27521
Conversation
{ | ||
PickHandler = urls => GetFileResults(urls, tcs) | ||
}; | ||
documentPicker.DidPickDocumentAtUrls += (_, e) => GetFileResults(e.Urls, tcs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hope is that the original issue is fixed by using this API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you checked how OperatingSystem.IsIOS()
is implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OperatingSystem.IsIOS
will return true for an iOS app running on macOS (as it is implemented using compile flags), and can only be used to determine if it is a Catalyst app or an iOS app, not if it is an iOS app on macOS.
But it could be that DidPickDocumentAtUrls
is behaving correctly for iOS apps running on macOS, unlike the documentPicker.PresentationController.Delegate
which is the root cause of the issue today when running iOS MAUI apps on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this is not correct. I updated it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it could be that
DidPickDocumentAtUrls
is behaving correctly for iOS apps running on macOS, unlike thedocumentPicker.PresentationController.Delegate
which is the root cause of the issue today when running iOS MAUI apps on macOS.
Yes, that's what I aim for. It can be tested once there are nugets generated by CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nugets are here: https://dev.azure.com/xamarin/public/_build/results?buildId=134094&view=artifacts&pathAsName=false&type=publishedArtifacts
See "nugets" and click the three dots to download it.
To use the nugets, I believe you need to add Nuget.config
in your root project like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Local nuget packages" value="../LocalNugetPackages" />
</packageSources>
</configuration>
and put the nugets in the LocalNugetPackages
folder and set MauiVersion
in a MAUI .csproj
file:
<MauiVersion>9.0.40-ci.main.25102.1</MauiVersion>
I believe this should work. Don't mind this post, if you know all this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@follesoe Did you have a chance to test this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MartyIX Not yet, but working on our MAUI migration project right now. I will see if I manage to get around to it. Just so many other tasks on my plate 😫
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the nugets will get deleted on the server in one month. So there is some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@follesoe Any chance you had some time to test this? If the PR fixes your issue, then there is a bigger chance that this PR will be accepted.
documentPicker.PresentationController.Delegate = | ||
new UIPresentationControllerDelegate(() => GetFileResults(null, tcs)); | ||
} | ||
if (documentPicker.PresentationController != null && !(OperatingSystem.IsIOSVersionAtLeast(14, 0) && NSProcessInfo.ProcessInfo.IsiOSApplicationOnMac)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to fix #25661
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Description of Change
This is an attempt to use this API in
FilePicker
on iOS and Mac Catalyst.Credits to @datvm and @Khongchai
FTR: I have not been able to reproduce the original issue yet.
Issues Fixed
Fixes #15126
Fixes #25661
Resources