Skip to content

Conversation

drasticactions
Copy link
Contributor

files.mp4
image

What does the pull request do?

Implements SaveFilePickerAsync for Avalonia.iOS

What is the current behavior?

Throws an exception saying that Saving Files is unsupported.

What is the updated/expected behavior with this PR?

Allows for saving files on iOS and Mac Catalyst.

How was the solution implemented (if it's not obvious)?

UIDocumentPickerViewController can "export" and "copy" files to a user's device. For it to work, you need to create a temp file that is passed into the picker, set as a copy. The user picks the file name and location to save to. If they follow through, you get an IStorageFile with a URI that can be written to.

It's similar in approach to the MAUI CommunityToolkit implementation, except the file is written to after the fact.

Note that for Read/Write access from outside the App Sandbox, you need to enable

<key>com.apple.security.files.user-selected.read-write</key>
<true/>

in the info.plist.

@@ -16,7 +16,6 @@
<array>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this since DeviceType 3 is used for tvOS, which breaks deployment for iOS.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0057878-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0057884-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0057918-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added the backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch label Aug 1, 2025
@MrJul MrJul added this pull request to the merge queue Aug 2, 2025
Merged via the queue into master with commit cd05ff8 Aug 2, 2025
13 checks passed
@MrJul MrJul deleted the feature/ios-file-picker-save branch August 2, 2025 06:45
MrJul pushed a commit that referenced this pull request Aug 5, 2025
* [iOS] Implement Save File Picker Support

* Delete folder instead

* Use StorageProviderHelpers

* Use FromBytes to create blank file
@MrJul MrJul added backported-11.3.x and removed backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants