When updating images in an Asset Catalog for a Xamarin Forms iOS app, I sometime end up with extra images showing in the image set and sometimes the correct images are not assigned to the correct @1x, @2x etc. I also get this sometimes when I attempt to merge changes to my images between to versions of my project. I have been unable to clean out these images and there is no option to un-assign when you right click on these images in the asset catalog. Even deleting image set from the asset catalog via the Visual Studio IDE did not seem to work correctly as I then started getting some compile time errors that image files could not be found in the Assets.xcasstes folder. Any ideas how to correctly merge / handle this type of situation? I would prefer not to manually re-update the images in the second versiomn (ie branch) of my project.
So using the steps below, I was able to clean things up but it is a very manual process. Still looking for a good way to merge iOS images between branches. The steps below are for VS 2019 on the PC.
FYI - if your project is version controlled, I suggest performing a check in after every change that is made.
IMPORTANT.. - Also - make sure in the folders under Assets.xcassets ensure there is no Images.imageset folder unless you actually use an asset image set named Images. Otherwise delete this folder and ensure the folder / files are not referenced in the iOS.csproj file.
Once you have removed all the entries from images that are no longer part of your asset catalog, save the iOS csproj. Then right mouse button click on the iOS project in your solution and select 'Reload Project'.
You should now be able to re-compile the project with no errors. REMEBER - check-in your project to your version control system frequently and especially at this point.
Now you can go back into you Asset Catalog and re-add the needed image sets.
Everything should work correctly after this point.
So for some reason, I cannot get the XML code I posted above to actually display so I am going to try to post it here.
<ImageAsset Include="Assets.xcassets\config.imageset\config.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\config.imageset\config@2x.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\config.imageset\config@3x.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\config.imageset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\Images.imageset\qrbuttonlight32.png">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\Images.imageset\qrbuttonlight64.png">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\Images.imageset\qrbuttonlight96.png">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
You need to make sure you delete the complete XML tag - in this case it would be the entire ImageAsset XML node for each file in the config imageset.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.