[英]How to removed "Unknown" images from Xamarin Forms iOS Asset Catalog
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.在为 Xamarin Forms iOS 应用程序更新资产目录中的图像时,有时我有时会在图像集中显示额外的图像,有时会在图像集中显示正确的图像,有时当@2x 等未分配给我尝试将我的图像更改合并到我的项目版本之间。 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.
即使通过 Visual Studio IDE 从资产目录中删除图像集似乎也无法正常工作,因为我开始收到一些编译时错误,即在 Assets.xcasstes 文件夹中找不到图像文件。 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.
仍在寻找一种在分支之间合并 iOS 图像的好方法。 The steps below are for VS 2019 on the PC.
以下步骤适用于 PC 上的 VS 2019。
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.重要.. - 另外 - 确保在 Assets.xcassets 下的文件夹中确保没有 Images.imageset 文件夹,除非您实际使用名为 Images 的资产图像集。 Otherwise delete this folder and ensure the folder / files are not referenced in the iOS.csproj file.
否则删除此文件夹并确保在 iOS.csproj 文件中未引用该文件夹/文件。
Once you have removed all the entries from images that are no longer part of your asset catalog, save the iOS csproj.从不再属于资产目录的图像中删除所有条目后,请保存 iOS csproj。 Then right mouse button click on the iOS project in your solution and select 'Reload Project'.
然后右键单击解决方案中的 iOS 项目和 select '重新加载项目'。
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.现在您可以将 go 返回到您的资产目录并重新添加所需的图像集。
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.所以由于某种原因,我无法让我在上面发布的 XML 代码实际显示,所以我将尝试将其发布在这里。
<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.您需要确保删除完整的 XML 标记 - 在这种情况下,它将是配置图像集中每个文件的整个 ImageAsset XML 节点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.