Search code examples
c#iosmaui

How to access MAUI asset file on iOS?


I am embedding files in my MAUI app, and succesfully access it at run-time on Android and Windows, but not on iOs (physical phone). Is there something I am missing or is there a bug I am not aware of ?

I embedd the file to the project lik like so:

  <ItemGroup>
    <MauiAsset Include="Resources\TextFile1.txt" />
  </ItemGroup>

I access it like so:

using (fileStream = await FileSystem.OpenAppPackageFileAsync("Resources/TextFile1.txt"))

Please note that:

var result = Directory.EnumerateFiles(FileSystem.AppDataDirectory);
var result = Directory.EnumerateDirectories(FileSystem.AppDataDirectory);

Return nothing on iOs, and that the splash screen and the icon of my app are replaced with the default one even though they work fine on other platforms.


Solution

  • If you are struggling with a similar issue, like me you probably did not catch this info:

    You need a Mac device if you want to release a MAUI app on IOS.

    You can still work/debug most of your iOS app plugging an iPhone to Windows which is cool but you got to get that Mac eventually.