This is for a Xamarin.Forms project, but an iOS specific problem so I thought maybe this was a more appropriate place.
I have two Xamarin.Forms apps, which are to share some pages and functionality. For the actual functionality, I have the first app's Forms project referencing the second app's Forms project. For image resources used by the second app's pages, I have created an iOS Class Library, referenced by both apps' iOS projects. The library contains both BundleResource images, and asset catalogs. However, when I build the first app, its asset catalog resources are missing, while the second app's are present. The non-asset-catalog, BundleResource images for the first app are still present.
Anyone have any tips for resolving this?
I am having the same issue with asset catalogs in shared libraries. The only thing I have tried that works is to create a symlink in each project's directory structure to point to a shared asset catalog folder. You just have to make sure you're not referencing another project with an asset catalog.
This has been a known issue for a while: https://bugzilla.xamarin.com/show_bug.cgi?id=34762
and as noted in the comments on the bug report changing this behavior will not be trivial.
Answers
I am having the same issue with asset catalogs in shared libraries. The only thing I have tried that works is to create a symlink in each project's directory structure to point to a shared asset catalog folder. You just have to make sure you're not referencing another project with an asset catalog.
Did you find a different solution to this?
We are facing probably the same issue:
https://forums.xamarin.com/discussion/99930/xcasset-folder-in-ios-class-library-breaks-uiimage-frombundle-in-main-app#latest
I ended up just not using asset catalogs for the shared resources.
This has been a known issue for a while: https://bugzilla.xamarin.com/show_bug.cgi?id=34762
and as noted in the comments on the bug report changing this behavior will not be trivial.
To fix this issue on our highly modularised project we are using a shell script to gather all assets and patch all existing Asset.car files in the App. project:
gist.github.com/muellnes/74899fcb0ff6dde05d5960b4f9c8bfbe
Consider this workaround quality!
Just add it to your After Build stage in the Custom Commands
${SolutionDir}/Tools/bundle-all-assets.sh -s ${SolutionDir}/src/ -o ${ProjectDir}
@SaschaMllner The script appeared to run successfully, but it did not solve the problem.
var image = UIImage.FromBundle("Image");
still returns null.