'Xamarin - I can't load images in iPhone but can in Android and iPhone simulator

I am having trouble with images on the iPhone. They work fine on Android (both emulator and actual devices) and on the iPhone simulator. However, on an actual iPhone device, I can’t display images unless they are in the asset catalog. I started with a fresh project and it did display. Then, I added files (that were not used – as the only thing in my App.xaml.cs was a load of the page displaying the images). At some point, the images quit showing up so it appears to be a build error of some sort but I can’t figure it out. Android Emulator:

Android Emulator

iPhone Simulator:

iPhone Simulator

Actual iPhone:

enter image description here

So, for the iPhone, ffImageLoading can load a .svg from my local device but none of the .png files or remote urls. Xamarin.Image can’t load anything.

Any ideas? Is this some sort of build problem? My build settings are:

enter image description here

If I Enable the Mono Interpreter OR I leave out the mtouch options (all that works is Mono interpreter disable and mtouch options set), I get the dreaded “Could not AOT the assembly…” error.

I have tried different Architectures. I have tried different linking behavior. Not sure what else to try.

Any help or thoughts on work-arounds would be greatly appreciated!

Thanks!

Greg

Attached is the source but it's not much to look at.

    Testpage2.xaml
    <ContentPage.Resources>
        <Style x:Key="MyImage" TargetType="Image">
            <Setter Property="WidthRequest" Value="25" />
        </Style>
    </ContentPage.Resources>

    <ContentPage.Content>
        <ScrollView>
            <StackLayout BackgroundColor="Wheat">
                <Label Text="ffImageLoading local resource" TextColor="Red" />
                <ffimageloadingsvg:SvgCachedImage Source="resource://ONEflight.BAJit.App.Images.Buttons.MyProfileButton.svg" Style="{StaticResource MyImage}" />

                <Label Text="URL Image using ffImageLoading" TextColor="Red" />
                <ffimageloading:CachedImage Source="https://ofpublicwebdata.blob.core.windows.net/of-public-data-aircraft-images/9ef83699-d8e8-44d9-ac94-2a26359aac9d.jpg" Style="{StaticResource MyImage}" />

                <Label Text="URL Source in xaml using Xamarin.Image" TextColor="Red" />
                <Image Source="https://ofpublicwebdata.blob.core.windows.net/of-public-data-aircraft-images/9ef83699-d8e8-44d9-ac94-2a26359aac9d.jpg" Style="{StaticResource MyImage}" />

                <Label Text="URL Source as string in Code using Xamarin.Image" TextColor="Red" />
                <Image Source="{Binding UrlStr}" Style="{StaticResource MyImage}" />

                <Label Text="URL downloaded using MemStream in Code using Xamarin.Image" TextColor="Red" />
                <Image Source="{Binding ImageDownloadedToMemStream}" Style="{StaticResource MyImage}" />

                <Label Text="Local png using Xamarin.Image" TextColor="Red" />
                <Image Source="{ex:ImageResource Images.Amenities.pets.png}" Style="{StaticResource MyImage}" />
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
TestViewModel2.cs
        public string UrlStr { get; set; }
        public ImageSource ImageDownloadedToMemStream { get; set; }
        public ImageSource Pets => Resources.PetsIcon;
        public ImageSource URITest { get; set; }

        public TestViewModel2()
        {
            string url = "https://ofpublicwebdata.blob.core.windows.net/of-public-data-aircraft-images/9ef83699-d8e8-44d9-ac94-2a26359aac9d.jpg";

            try
            {
                UrlStr = url;

                MemoryStream ms = new MemoryStream(new WebClient().DownloadData(url));
                ImageDownloadedToMemStream = ImageSource.FromStream(() => ms);

                URITest = ImageSource.FromUri(new Uri(url));
            }
            catch (Exception ex)
            {
                LogWriter.Log("Image Error: " + ex.Message);
            }
        }
App.xaml.cs
MainPage = new NavigationPage(new TestPage2(new TestViewModel2()));


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source