Home:ALL Converter>Is it possible to use asset catalog from an iOS class library in a Xamarin Forms iOS app?

Is it possible to use asset catalog from an iOS class library in a Xamarin Forms iOS app?

Ask Time:2022-05-26T02:47:15         Author:Ieuan Griffiths

Json Formatter

Could not find any answers to this specific problem anywhere online.

I've had to factor a Xamarin forms project as there was a requirement to have multiple android/iOS apps that use the same code. Current set up is:

  • Standard Library
  • Android App 1
  • Android App 2
  • iOS App 1
  • iOS App 2
  • Android Class Library
  • iOS Class Library

For android, the images are in the resources folder in the android class library and the images display fine in the app.

For iOS I have put the images in a Asset Catalog in the iOS class library. These however, do not show in the app. I created an asset catalog in one of the iOS app projects and tested that an image would load from there - and it did. Is it not possible for images to load from an asset catalog in a iOS class library? I have other items in the iOS class library (such as custom renderers, which work fine). If the latter is not possible, is there a different way I keep the images in one place for iOS, without having to change my xaml? This is an existing project, with loads of images already being referenced by name in xaml (e.g. Source="image.png") that are used for both iOS and android. If possible, I don't want to have to maintain an asset catalog per app, although I do know of a way it could be automated, but I want to avoid having to do that if possible.

Using .NET Standard 2.1 and Xamarin Forms 5.0.0.2401

Thanks in advance.

Author:Ieuan Griffiths,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72382775/is-it-possible-to-use-asset-catalog-from-an-ios-class-library-in-a-xamarin-forms
yy