简体   繁体   English

以编程方式更新 Xcode 资产目录

[英]Programmatically updating Xcode asset catalog

I am developing an app that will use a large number of images (thousands).我正在开发一个将使用大量图像(数千张)的应用程序。 These assets are created in Inkscape then programmatically rendered into 1x and 2x images for iPad and 1x, 2x and 3x for iPhone.这些资产在 Inkscape 中创建,然后以编程方式呈现为 iPad 的 1x 和 2x 图像以及 iPhone 的 1x、2x 和 3x。 This all works well.这一切都很好。

Now I want to move these images into an asset catalog so as to take advantage of thinning.现在我想将这些图像移动到资产目录中,以便利用细化。

Is there a nice way to programmatically add all of these images into an asset catalog or do I just have to do the hard work of generating the catalog file?有没有一种很好的方法可以以编程方式将所有这些图像添加到资产目录中,还是我只需要做生成目录文件的繁重工作?

Since I already have a program to generate the images (and create a matching metadata file) for the project, I have no problem writing code to update catalog;因为我已经有一个程序来为项目生成图像(并创建一个匹配的元数据文件),所以我编写代码来更新目录没有问题; I just want to do it the right way.我只是想以正确的方式去做。

Asset catalogs are just folders with json files that describes the content, you can easily create a shell or a swift script that can generate those files.资产目录只是包含描述内容的 json 文件的文件夹,您可以轻松创建可以生成这些文件的 shell 或 swift 脚本。 Here is an example of a script dealing with asset catalogs (not exactly what you are looking for though) https://github.com/freshOS/AssetChecker这是处理资产目录的脚本示例(虽然不完全是您要查找的内容) https://github.com/freshOS/AssetChecker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM