<bdo id='jYjYD'></bdo><ul id='jYjYD'></ul>
<tfoot id='jYjYD'></tfoot>

        <i id='jYjYD'><tr id='jYjYD'><dt id='jYjYD'><q id='jYjYD'><span id='jYjYD'><b id='jYjYD'><form id='jYjYD'><ins id='jYjYD'></ins><ul id='jYjYD'></ul><sub id='jYjYD'></sub></form><legend id='jYjYD'></legend><bdo id='jYjYD'><pre id='jYjYD'><center id='jYjYD'></center></pre></bdo></b><th id='jYjYD'></th></span></q></dt></tr></i><div id='jYjYD'><tfoot id='jYjYD'></tfoot><dl id='jYjYD'><fieldset id='jYjYD'></fieldset></dl></div>
        <legend id='jYjYD'><style id='jYjYD'><dir id='jYjYD'><q id='jYjYD'></q></dir></style></legend>
      1. <small id='jYjYD'></small><noframes id='jYjYD'>

      2. 引用资产目录并从框架中包含它是否会创建重复?

        时间:2023-05-17

      3. <tfoot id='LTp2j'></tfoot>

        <small id='LTp2j'></small><noframes id='LTp2j'>

          <bdo id='LTp2j'></bdo><ul id='LTp2j'></ul>

              <legend id='LTp2j'><style id='LTp2j'><dir id='LTp2j'><q id='LTp2j'></q></dir></style></legend>
                <tbody id='LTp2j'></tbody>

                <i id='LTp2j'><tr id='LTp2j'><dt id='LTp2j'><q id='LTp2j'><span id='LTp2j'><b id='LTp2j'><form id='LTp2j'><ins id='LTp2j'></ins><ul id='LTp2j'></ul><sub id='LTp2j'></sub></form><legend id='LTp2j'></legend><bdo id='LTp2j'><pre id='LTp2j'><center id='LTp2j'></center></pre></bdo></b><th id='LTp2j'></th></span></q></dt></tr></i><div id='LTp2j'><tfoot id='LTp2j'></tfoot><dl id='LTp2j'><fieldset id='LTp2j'></fieldset></dl></div>
                • 本文介绍了引用资产目录并从框架中包含它是否会创建重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  如上所述,

                  在截图中你可以看到:

                  • 带有框架和应用程序以及后台.xcassets的Xcode项目结构

                  • 故事板中唯一图片的使用

                  • 在右下角的Finder中提取的两个Assets.car文件(一次在应用文件夹,一次在框架中)

                  • 最后是左下角提到的第三方工具,显示嵌入的图像

                  结论不幸的是,如果您想避免这种重复,您不能使用 Interface Builder,而是必须以编程方式从框架中检索图像.

                  更多信息

                  就像我的其他答案一样,我建议您看一下这个 WWDC 2018 视频:第 227 节,优化应用资产,https://developer.apple.com/videos/play/wwdc2018/227/

                  As discussed here & here, the only apparent way to host re-usable images in a Framework's .xcassets file, then use those images in the storyboard / XIB of an app, is to manually create a reference to that catalog file directly within the app's project. This puts the assets within the app's main bundle, and avoids this error when trying to use them via Interface Builder:

                  Could not load the "ImageName" image referenced from a nib in the bundle with identifier "BundleName"

                  My question, though, is: Does this lead to duplication of the assets at build-time? Is iOS smart enough not to double-up assets which are both:

                  • Referenced in the app's main bundle and
                  • Included in the bundle of an embedded framework

                  If this does lead to duplication, what other approach can achieve the same result more efficiently? The framework needs to be embedded in the app, because it contains other reusable code, and the assets need to be in the framework's catalog, because they're also used in other apps.

                  解决方案

                  Apple's goal is to minimize the space required for assets, so assets are combined and compressed into one file called 'Assets.car'.

                  However as correctly noted in the comments, the image is included twice in the final .ipa, once in the Assets.car file of the app and once in the Assets.car file of the framework.

                  When you submit to the app store a process called App Thinning is started that creates variants for different actual devices.

                  You can mimic the process locally and with a third-party tools even take a look inside the 'Asset.car' file.

                  I described the whole process in detail in this answer: Pixelated images on iOS10 when building with Xcode 10

                  To test it myself I did the following:

                  • I created a workspace
                  • I added a framework
                  • I added an app
                  • inside the framework I added a 'Media.xcassets'
                  • I reference this Media.xcassets from the app
                  • I added one picture called 'Regensburg.jpg' to Media.xcassets
                  • I use this image in a storyboard

                  There are two Assets.car files, one in the base folder of the app and one in the framework. If you take a look with the third-party tool, you can see that both Assets.car files contain the same image.

                  So finally the image is saved twice in the .ipa file.

                  Conclusion

                  Unfortunately, it looks like if you want to avoid this duplication, you can't refer to it directly in the storyboard, but have to retrieve the image programmatically from the framework.

                  Screenshot

                  In the screenshot you can see:

                  • Xcode project structure with framework and app as well as .xcassets in the background

                  • usage of the only image inside in the storyboard

                  • the two extracted Assets.car files in the Finder in the lower right area (once in the application folder and once in the framework)

                  • finally the mentioned third-party tool in the lower left area which shows the embedded image

                  Conclusion Unfortunately, it looks like if you want to avoid this duplication, you can't use Interface Builder and instead have to retrieve the image programmatically from the framework.

                  More information

                  Like in my other answer I would recommend to take a look at this WWDC 2018 video: Session 227, Optimizing App Assets, https://developer.apple.com/videos/play/wwdc2018/227/

                  这篇关于引用资产目录并从框架中包含它是否会创建重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS8:自定义 Swift 框架访问用 Objective-C 编写的外部框架 下一篇:SwiftUI:可重用跨平台(iOS 和 macOS)视图中的导航栏标题

                  相关文章

                  1. <legend id='umhYT'><style id='umhYT'><dir id='umhYT'><q id='umhYT'></q></dir></style></legend>
                  2. <tfoot id='umhYT'></tfoot>
                      <i id='umhYT'><tr id='umhYT'><dt id='umhYT'><q id='umhYT'><span id='umhYT'><b id='umhYT'><form id='umhYT'><ins id='umhYT'></ins><ul id='umhYT'></ul><sub id='umhYT'></sub></form><legend id='umhYT'></legend><bdo id='umhYT'><pre id='umhYT'><center id='umhYT'></center></pre></bdo></b><th id='umhYT'></th></span></q></dt></tr></i><div id='umhYT'><tfoot id='umhYT'></tfoot><dl id='umhYT'><fieldset id='umhYT'></fieldset></dl></div>

                      <small id='umhYT'></small><noframes id='umhYT'>

                        <bdo id='umhYT'></bdo><ul id='umhYT'></ul>