Class Library asset catalogs overriding app asset catalogs

JoeMankeJoeManke USMember ✭✭✭✭✭

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?

Best Answers

  • JoeMankeJoeManke US ✭✭✭✭✭
    Accepted Answer

    I ended up just not using asset catalogs for the shared resources.

Answers

  • tokotoko USMember ✭✭

    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

  • JoeMankeJoeManke USMember ✭✭✭✭✭
    Accepted Answer

    I ended up just not using asset catalogs for the shared resources.

  • SaschaMllnerSaschaMllner USMember
    edited November 2017

    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}

  • wjm110wjm110 Member
    edited May 2018

    @SaschaMllner The script appeared to run successfully, but it did not solve the problem.

    var image = UIImage.FromBundle("Image");

    still returns null.

Sign In or Register to comment.