简体   繁体   English

今日扩展中复制的主应用资产目录

[英]Main app assets catalog copied in today extension

When I added a Today Extension my app suddenly gained a lot of weight... so I did a rapid checkup to see where that fat is coming from. 当我添加一个今日扩展我的应用程序突然增加了很多...所以我做了一个快速检查,看看脂肪来自哪里。 It look like the .apex is 13MB, the 'Assets.car' file is the even bigger than the one in my main app (+8MB). 看起来.apex是13MB,'Assets.car'文件甚至比我的主应用程序(+ 8MB)还要大。 The thing is, I use only 1 image in the assets catalog I have in my extension. 问题是,我在扩展程序中的资产目录中只使用了1个图像。

I checked within Xcode, my main app assets catalog is not toggled to be copied with the extension, but it sounds like it is in fact. 我在Xcode中检查过,我的主要应用程序资产目录没有被切换为使用扩展名复制,但听起来确实如此。

Is it normal? 这是正常的吗? Do you know what to do in order to reduce the final .apex size? 你知道怎么做才能减少最终的.apex尺寸吗?

Thanks! 谢谢!

Are you by any chance using Cocoapods ? 你是否有机会使用Cocoapods

There's currently an open issue that causes the Copy Pods Resources run script to locate all assets and compile them into a big archive, which might not be desired for all targets. 目前存在一个未解决的问题 ,导致Copy Pods Resources运行脚本找到所有资产并将它们编译成一个大型存档,这可能不是所有目标都需要的。

Until this is fixed, a simple solution is to add a post_install hook to your Podfile : 直到这个是固定的,一个简单的解决方案是将添加post_install钩到您的Podfile

# Fix broken copy-resources phase per https://github.com/CocoaPods/CocoaPods/issues/1546.
post_install do |installer|
  installer.project.targets.each do |target|
    scriptBaseName = "\"Pods/Target Support Files/#{target.name}/#{target.name}-resources\""
    sh = (<<-EOT)
      if [ -f #{scriptBaseName}.sh ]; then
        if [ ! -f #{scriptBaseName}.sh.bak ]; then
          cp #{scriptBaseName}.sh #{scriptBaseName}.sh.bak;
        fi;
        sed '/WRAPPER_EXTENSION/,/fi\\n/d' #{scriptBaseName}.sh > #{scriptBaseName}.sh.temp;
        sed '/*.xcassets)/,/;;/d' #{scriptBaseName}.sh.temp > #{scriptBaseName}.sh;
        rm #{scriptBaseName}.sh.temp;
      fi;
    EOT
    `#{sh}`
  end
end

Credit for the above code snippet goes to all the helpful people in the issue thread! 以上代码片段的信用额发送给问题线程中的所有有用的人!

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

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