Opening unknown filetypes on iPhone/iOS

Hey all,

I'm using .NET MAUI's FilePicker to open a custom binary (assume a MIME type of application/octet-stream, with a .bin extension). FilePicker.Default.PickAsync works fine on all platforms (in my case, Windows, Android, MacCatalyst and iOS). I subsequently create a FileStream with the returned path (with FileMode.Open, FileAccess.Read). This works fine on Windows, Android, and MacCatalyst, but fails on iOS (for my Mac setup, I'm running VS Code on my MacBook and debugging my app on my iPhone 14 Pro attached via USB). On iOS, I wind up with an UnauthorizedAccessException whenever I try and create said FileStream object with the path to the binary file.

Now, if I select a known filetype (say, an XML file) with FilePicker, then the FileStream object gets created successfully on all platforms. Obviously my binary is an unknown type, and I came to understand that, on iOS, I have to explicitly identify unknown file types in Platforms/iOS/Info.plist in order to open them. So I did that as follows:

<key>CFBundleDocumentTypes</key>
<array>
<dict>
	<key>CFBundleTypeName</key>
	<string>CustomBinary</string>
	<key>CFBundleTypeRole</key>
	<string>Editor</string>
	<key>LSHandlerRank</key>
	<string>Owner</string>
	<key>LSItemContentTypes</key>
	<array>
		<string>com.mycompanyname.myappname.bin</string>
	</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
	<key>UTTypeConformsTo</key>
	<array>
		<string>public.data</string>
	</array>
	<key>UTTypeDescription</key>
	<string>CustomBinary</string>
	<key>UTTypeIconFiles</key>
	<array/>
	<key>UTTypeIdentifier</key>
	<string>com.mycompanyname.myappname.bin</string>
	<key>UTTypeTagSpecification</key>
	<dict>
		<key>public.filename-extension</key>
		<array>
			<string>bin</string>
			<string>BIN</string>
		</array>
		<key>public.mime-type</key>
		<array>
			<string>application/octet-stream</string>
		</array>				
	</dict>
</dict>
</array>

Unfortunately, I still get the same exception. I've been spinning my wheels for several days now, and so just wanted to reach out to see if anyone with more iOS insight than I had an idea of how to solve this problem. The binary file itself is on my iPhone itself (i.e., it's in "Files->On My Phone"). Any help is appreciated!

Wes

Opening unknown filetypes on iPhone/iOS
 
 
Q