<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>素问 - iOS技术</title><link>https://suwenclub.cn/</link><description>做一件事，做到极致</description><item><title>Quick tip: clearing your app’s launch screen cache on iOS</title><link>https://suwenclub.cn/?id=25</link><description>&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;Every time I’ve had to change something in the launch screen on any of my iOS apps, I’ve faced an issue: the system caches launch images and is really bad at clearing said cache, even after the app has been deleted.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;Sometimes I’d change the launch screen storyboard, delete the app and re-launch, and it would show the new storyboard, but any images referenced in the storyboard wouldn’t show up, making the launch screen appear broken.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;Today, I did some digging into my app’s container and noticed that in the&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;font-size: 15px; border: 1px solid rgb(232, 232, 232); border-radius: 3px; background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); padding: 1px 5px;&quot;&gt;Library&lt;/code&gt;&amp;nbsp;folder there’s a folder named&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;font-size: 15px; border: 1px solid rgb(232, 232, 232); border-radius: 3px; background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); padding: 1px 5px;&quot;&gt;SplashBoard&lt;/code&gt;, which is where the launch screen caches are stored.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;So all you have to do to completely clear your app’s launch screen cache is run this code inside your app (which I’ve conveniently packaged into an extension of&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;font-size: 15px; border: 1px solid rgb(232, 232, 232); border-radius: 3px; background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); padding: 1px 5px;&quot;&gt;UIApplication&lt;/code&gt;):&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-swift&quot;&gt;import&amp;nbsp;UIKit
public&amp;nbsp;extension&amp;nbsp;UIApplication&amp;nbsp;{&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;func&amp;nbsp;clearLaunchScreenCache()&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&amp;nbsp;FileManager.default.removeItem(atPath:&amp;nbsp;NSHomeDirectory()+&amp;quot;/Library/SplashBoard&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;catch&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print(&amp;quot;Failed&amp;nbsp;to&amp;nbsp;delete&amp;nbsp;launch&amp;nbsp;screen&amp;nbsp;cache:&amp;nbsp;\(error)&amp;quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;&lt;em&gt;Note: tested on iOS 13 only&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;You can put it in your app’s initialization code behind an argument flag that you enable during launch screen development, then leave it disabled when you’re not working on your launch screen.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 15px; padding: 0px; color: rgb(17, 17, 17); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; white-space: normal; background-color: rgb(253, 253, 253);&quot;&gt;This trick has saved me a lot of time while messing with launch screens, and I hope it will save you some time as well.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;原文链接：&lt;a href=&quot;https://rambo.codes/ios/quick-tip/2019/12/09/clearing-your-apps-launch-screen-cache-on-ios.html&quot;&gt;https://rambo.codes/ios/quick-tip/2019/12/09/clearing-your-apps-launch-screen-cache-on-ios.html&lt;/a&gt;&lt;/p&gt;</description><pubDate>Mon, 23 Dec 2019 18:45:52 +0800</pubDate></item><item><title>iOS图片内存优化</title><link>https://suwenclub.cn/?id=24</link><description>&lt;p&gt;基于现在iOS11新生成的图片都是&lt;code&gt;HEIF&lt;/code&gt;，该图片使用&lt;code&gt;UIImage(named: name)&lt;/code&gt;已不在那么优雅，图片大小为1.8m大小的，读进手机内存，直接飙升了45M，这是我们不想看到的结果，一个页面有多个这样子的图的话，恐怕就是灾难了。&lt;/p&gt;&lt;p&gt;既然原图不能读入，那么如何可以用更少的内存和CPU来解决呢?&lt;/p&gt;&lt;p&gt;这就要先了解该图片的编码了。&lt;/p&gt;&lt;h2 data-id=&quot;heading-0&quot;&gt;HEIC HEIF&lt;/h2&gt;&lt;blockquote&gt;&lt;p&gt;带有元数据的HEIF的另一种形式。HEIC文件包含一个或多个以“高效图像格式”（HEIF）保存的图像，该格式通常用于在移动设备上存储照片。它可能包含单个图像或图像序列以及描述每个图像的元数据。最常使用文件扩展名“ .heic”，但HEIC文件也可能显示为.HEIF文件&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;code&gt;heic&lt;/code&gt;和&lt;code&gt;heif&lt;/code&gt;是广色域图片的格式，广色域比&lt;code&gt;sRGB&lt;/code&gt;表示范围大25%，在广色域设备中能显示更广的色彩，&lt;code&gt;sRGB 8bit/dept&lt;/code&gt;，广色域达到&lt;code&gt;16bit/dept&lt;/code&gt;。广色域只是在硬件支持的情况下才能显示的。 其实就是苹果搞的一个更高效体积更小效率更高的压缩方式。&lt;/p&gt;&lt;h2 data-id=&quot;heading-1&quot;&gt;加载&lt;/h2&gt;&lt;p&gt;加载&lt;code&gt;image&lt;/code&gt;，只是把&lt;strong&gt;文件信息&lt;/strong&gt;加载到内存中，下一步就是解码。在代码中体现就是&lt;/p&gt;&lt;pre&gt;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;UIImage(contentsOfFile:&amp;nbsp;url.path)&amp;nbsp;或&amp;nbsp;加载图片到内存&amp;nbsp;会常驻内存&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;UIImage(named:&amp;nbsp;name)!&amp;nbsp;复制代码&lt;/pre&gt;&lt;h2 data-id=&quot;heading-2&quot;&gt;解码&lt;/h2&gt;&lt;p&gt;其实是发生在添加到要显示的view上面才会解码&lt;/p&gt;&lt;pre&gt;let&amp;nbsp;imageV&amp;nbsp;=&amp;nbsp;UIImageView.init(image:&amp;nbsp;image)&amp;nbsp;imageV.frame&amp;nbsp;=&amp;nbsp;CGRect(x:&amp;nbsp;50,&amp;nbsp;y:&amp;nbsp;(250&amp;nbsp;*&amp;nbsp;i)&amp;nbsp;+&amp;nbsp;100,&amp;nbsp;width:&amp;nbsp;200,&amp;nbsp;height:&amp;nbsp;200)&amp;nbsp;self.view.addSubview(imageV)&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;最后一行不写，则不会解码。&lt;/p&gt;&lt;h2 data-id=&quot;heading-3&quot;&gt;渲染&lt;/h2&gt;&lt;p&gt;当&lt;code&gt;view&lt;/code&gt;显示出来则是渲染。过程是解码的&lt;code&gt;data buffer&lt;/code&gt; 复制到&lt;code&gt;frame buffer&lt;/code&gt;,硬件从帧缓冲区读取数据显示到屏幕上。&lt;/p&gt;&lt;pre&gt;self.view.addSubview(imageV)&amp;nbsp;复制代码&lt;/pre&gt;&lt;h2 data-id=&quot;heading-4&quot;&gt;内存暴涨原因&lt;/h2&gt;&lt;p&gt;一部分图片加载到内存，在解码过程中出现了内存暴涨问题，今天探究一下原因和解决方案。&lt;/p&gt;&lt;p&gt;首先有请我们准备的素材和设备(6s 64g版本)&lt;/p&gt;&lt;pre&gt;A:jpg&amp;nbsp;20M&amp;nbsp;12000*12000&amp;nbsp;B:jpg&amp;nbsp;2.8M&amp;nbsp;3024*4032&amp;nbsp;C:HEIC&amp;nbsp;1.8M&amp;nbsp;3024*4032&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;素材A&lt;/p&gt;&lt;pre&gt;APP运行内存：13.8M&amp;nbsp;加载Image:&amp;nbsp;240.3M之后稳定到220M&amp;nbsp;CPU：峰值5%，随后降低到0%&amp;nbsp;image占内存：226.5M&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;素材B&lt;/p&gt;&lt;pre&gt;APP运行内存：13.7M&amp;nbsp;加载Image:&amp;nbsp;31.5&amp;nbsp;CPU：峰值5%，随后降低到0%&amp;nbsp;image占内存：17.8M&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;素材C&lt;/p&gt;&lt;pre&gt;APP运行内存：13.8M&amp;nbsp;加载Image:&amp;nbsp;32.3&amp;nbsp;CPU：峰值4%，随后降低到0%&amp;nbsp;image占内存：18.5M&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;我们猜测是否是&lt;code&gt;imageView&lt;/code&gt;的大小影响内存的呢？ &lt;code&gt;size&lt;/code&gt;改为原来的1/10结果运行内存还是和以前一样。&lt;/p&gt;&lt;p&gt;为什么呢？&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;内存大小不是取决于&lt;code&gt;view&lt;/code&gt;的&lt;code&gt;size&lt;/code&gt;，而是原始文件&lt;strong&gt;image size&lt;/strong&gt;。&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;figure&gt;&lt;img class=&quot;lazyload inited loaded&quot; data-src=&quot;https://user-gold-cdn.xitu.io/2019/11/29/16eb5cff5d35a254?imageView2/0/w/1280/h/960/format/webp/ignore-error/1&quot; data-width=&quot;1016&quot; data-height=&quot;542&quot; src=&quot;https://user-gold-cdn.xitu.io/2019/11/29/16eb5cff5d35a254?imageView2/0/w/1280/h/960/format/webp/ignore-error/1&quot;/&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;h3 data-id=&quot;heading-5&quot;&gt;渲染格式&lt;/h3&gt;&lt;h4 data-id=&quot;heading-6&quot;&gt;SRGB&lt;/h4&gt;&lt;p&gt;每个像素4字节&lt;/p&gt;&lt;h4 data-id=&quot;heading-7&quot;&gt;display p3 宽色域&lt;/h4&gt;&lt;p&gt;每个像素8字节，使用机型iphone7 、iphone8、iphone X及以后的设备，不支持该格式的机型无法显示该效果。&lt;/p&gt;&lt;h4 data-id=&quot;heading-8&quot;&gt;亮度和透明度&lt;/h4&gt;&lt;p&gt;每个像素2字节，单一的色调和透明度，只能来显示白色和黑色之间的色值，没有其他颜色。&lt;/p&gt;&lt;h4 data-id=&quot;heading-9&quot;&gt;Alpha 8 Format&lt;/h4&gt;&lt;p&gt;每个像素1字节，用来表示透明度，一般用作蒙版和文字。 相比sRGB容量小了75%，详细 宽色域 容量小了87.5%&lt;/p&gt;&lt;h3 data-id=&quot;heading-10&quot;&gt;渲染图片大小计算&lt;/h3&gt;&lt;p&gt;图片大小 = 图片格式容量 * 像素个数 当我们把大小是20*20使用&lt;code&gt;Alpha 8 format&lt;/code&gt;渲染到20*20的view上面，和40*40的image使用&lt;code&gt;p3&lt;/code&gt;渲染到20*20的view中，后着占用内存是前者的8倍。&lt;/p&gt;&lt;p&gt;使用sRGB色域进行渲染所占用的大小为&lt;/p&gt;&lt;pre&gt;imageWidth*imageHeight*4&amp;nbsp;字节&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;每个像素占用了4字节，每个字节8位，&lt;/p&gt;&lt;p&gt;使用&lt;code&gt;display p3&lt;/code&gt;则每个通道占用16位，那么占用内存大小是&lt;/p&gt;&lt;pre&gt;imageWidth*imageHeight*8&amp;nbsp;字节&amp;nbsp;复制代码&lt;/pre&gt;&lt;h3 data-id=&quot;heading-11&quot;&gt;如何选择正确的图片格式&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;不要主动选择图片格式，让格式选择你。&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;不要再使用&lt;code&gt;UIGraphicsBeginImageContextWithOptions&lt;/code&gt;,该方法总是使用sRGB格式，你想节约内存是不行的，在支持&lt;code&gt;p3&lt;/code&gt;的设备上想绘制出来&lt;code&gt;p3&lt;/code&gt;色域的图片也是不行的。那么使用&lt;code&gt;UIGraphicsImageRenderer&lt;/code&gt;系统可以自动为你选择格式，如果绘制&lt;code&gt;image&lt;/code&gt;，自己再添加单色蒙版，是不需要另外单独分配内存的。&lt;/p&gt;&lt;pre&gt;if&amp;nbsp;let&amp;nbsp;im&amp;nbsp;=&amp;nbsp;imageV&amp;nbsp;{&amp;nbsp;//第二次添加蒙版&amp;nbsp;im.tintColor&amp;nbsp;=&amp;nbsp;UIColor.black&amp;nbsp;}else{&amp;nbsp;//绘制一个红色矩形&amp;nbsp;let&amp;nbsp;bounds&amp;nbsp;=&amp;nbsp;CGRect(x:&amp;nbsp;0,&amp;nbsp;y:&amp;nbsp;0,&amp;nbsp;width:&amp;nbsp;width,&amp;nbsp;height:&amp;nbsp;height)&amp;nbsp;let&amp;nbsp;renderer&amp;nbsp;=&amp;nbsp;UIGraphicsImageRenderer(bounds:&amp;nbsp;bounds)&amp;nbsp;&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;renderer.image&amp;nbsp;{&amp;nbsp;(coxt)&amp;nbsp;in&amp;nbsp;UIColor.red.setFill()&amp;nbsp;let&amp;nbsp;path&amp;nbsp;=&amp;nbsp;UIBezierPath(roundedRect:&amp;nbsp;bounds,&amp;nbsp;cornerRadius:&amp;nbsp;20)&amp;nbsp;path.addClip()&amp;nbsp;UIRectFill(bounds)&amp;nbsp;}&amp;nbsp;imageV&amp;nbsp;=&amp;nbsp;UIImageView(image:&amp;nbsp;image)&amp;nbsp;imageV?.frame&amp;nbsp;=&amp;nbsp;bounds&amp;nbsp;self.view.addSubview(imageV!)&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;&lt;code&gt;UIImage&lt;/code&gt; 直接读出来需要将所有&lt;code&gt;UIImage&lt;/code&gt;的&lt;code&gt;data&lt;/code&gt;全部解码到内存，很耗费内存和性能。为了节省内存和降低CPU使用率，可以采用&lt;strong&gt;下采样&lt;/strong&gt;。&lt;/p&gt;&lt;h3 data-id=&quot;heading-12&quot;&gt;下采样&lt;/h3&gt;&lt;p&gt;当&lt;code&gt;image&lt;/code&gt;素材大小是&lt;code&gt;1000*1000&lt;/code&gt;，但是在手机上显示出来只有&lt;code&gt;200*200&lt;/code&gt;，我们其实是没必要将&lt;code&gt;1000*1000&lt;/code&gt;的数据都解码的，只需要缩小成&lt;code&gt;200*200&lt;/code&gt;的大小即可，这样子节省了内存和CPU，用户感官也没有任何影响。 在&lt;code&gt;UIKit&lt;/code&gt;中使用&lt;code&gt;UIGraphicsImageRenderer&lt;/code&gt;会有瞬间很高的内存和CPU峰值，那么&lt;/p&gt;&lt;h4 data-id=&quot;heading-13&quot;&gt;1.UIKit &amp;nbsp;UIGraphicsImageRenderer&lt;/h4&gt;&lt;p&gt;使用素材A下采样技术，使用&lt;code&gt;UIKit&lt;/code&gt;中的&lt;code&gt;UIGraphicsImageRenderer&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;Memory&amp;nbsp;&amp;nbsp;High:16.4M&amp;nbsp;normal:14.8M&amp;nbsp;CPU:&amp;nbsp;Hight:29%&amp;nbsp;normal:0%&amp;nbsp;复制代码&lt;/pre&gt;&lt;pre&gt;func&amp;nbsp;resizedImage(at&amp;nbsp;url:&amp;nbsp;URL,&amp;nbsp;for&amp;nbsp;size:&amp;nbsp;CGSize)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage?&amp;nbsp;{&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;UIImage(contentsOfFile:&amp;nbsp;url.path)&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;if&amp;nbsp;#available(iOS&amp;nbsp;10.0,&amp;nbsp;*)&amp;nbsp;{&amp;nbsp;let&amp;nbsp;renderer&amp;nbsp;=&amp;nbsp;UIGraphicsImageRenderer(size:&amp;nbsp;size)&amp;nbsp;return&amp;nbsp;renderer.image&amp;nbsp;{&amp;nbsp;(context)&amp;nbsp;in&amp;nbsp;image.draw(in:&amp;nbsp;CGRect(origin:&amp;nbsp;.zero,&amp;nbsp;size:&amp;nbsp;size))&amp;nbsp;}&amp;nbsp;}else{&amp;nbsp;UIGraphicsBeginImageContext(size)&amp;nbsp;image.draw(in:&amp;nbsp;CGRect(origin:&amp;nbsp;.zero,&amp;nbsp;size:&amp;nbsp;size))&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;UIGraphicsGetImageFromCurrentImageContext()&amp;nbsp;UIGraphicsEndImageContext()&amp;nbsp;return&amp;nbsp;image&amp;nbsp;}&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;p&gt;用子线程绘制，会出现CPU略微升高，当&lt;code&gt;image size&lt;/code&gt;大很多的时候会出现内存飙升然后慢慢恢复到&lt;code&gt;normal&lt;/code&gt;。&lt;/p&gt;&lt;h4 data-id=&quot;heading-14&quot;&gt;2.CoreGraphics CGContext上下文绘制缩略图&lt;/h4&gt;&lt;p&gt;使用上下文绘制 &lt;code&gt;cpu&lt;/code&gt; 和内存变化如下,&lt;code&gt;CPU&lt;/code&gt;和内存没有大的变动解决了该问题，也做到省电、顺滑。&lt;/p&gt;&lt;pre&gt;Memory&amp;nbsp;&amp;nbsp;High:42.3M&amp;nbsp;normal:14.1M&amp;nbsp;CPU:&amp;nbsp;Hight:6%&amp;nbsp;normal:0%&amp;nbsp;复制代码&lt;/pre&gt;&lt;pre&gt;func&amp;nbsp;resizedImage2(at&amp;nbsp;url:&amp;nbsp;URL,&amp;nbsp;for&amp;nbsp;size:&amp;nbsp;CGSize)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage?{&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;imageSource&amp;nbsp;=&amp;nbsp;CGImageSourceCreateWithURL(url&amp;nbsp;as&amp;nbsp;NSURL,&amp;nbsp;nil),&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;CGImageSourceCreateImageAtIndex(imageSource,&amp;nbsp;0,&amp;nbsp;nil)&amp;nbsp;else{&amp;nbsp;return&amp;nbsp;nil;&amp;nbsp;}&amp;nbsp;let&amp;nbsp;cxt&amp;nbsp;=&amp;nbsp;CGContext(data:&amp;nbsp;nil,&amp;nbsp;width:&amp;nbsp;Int(size.width),&amp;nbsp;height:&amp;nbsp;Int(size.height),&amp;nbsp;bitsPerComponent:&amp;nbsp;image.bitsPerComponent,&amp;nbsp;bytesPerRow:&amp;nbsp;image.bytesPerRow,&amp;nbsp;space:&amp;nbsp;image.colorSpace&amp;nbsp;??&amp;nbsp;CGColorSpace(name:&amp;nbsp;CGColorSpace.sRGB)!&amp;nbsp;,&amp;nbsp;bitmapInfo:&amp;nbsp;image.bitmapInfo.rawValue)&amp;nbsp;cxt?.interpolationQuality&amp;nbsp;=&amp;nbsp;.high&amp;nbsp;cxt?.draw(image,&amp;nbsp;in:&amp;nbsp;CGRect(origin:&amp;nbsp;.zero,&amp;nbsp;size:&amp;nbsp;size))&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;scaledImage&amp;nbsp;=&amp;nbsp;cxt?.makeImage()&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;let&amp;nbsp;ima&amp;nbsp;=&amp;nbsp;UIImage(cgImage:&amp;nbsp;scaledImage)&amp;nbsp;return&amp;nbsp;ima&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;h4 data-id=&quot;heading-15&quot;&gt;3.ImageIO 创建缩略图&lt;/h4&gt;&lt;p&gt;使用&lt;code&gt;ImageIO&lt;/code&gt; 中创建图像，CPU和内存记录反而更高了，内存也居高不下，时间上基本2s才将图像绘制出来。&lt;/p&gt;&lt;pre&gt;Memory&amp;nbsp;&amp;nbsp;High:320M&amp;nbsp;normal:221M&amp;nbsp;CPU:&amp;nbsp;Hight:73%&amp;nbsp;normal:0%&amp;nbsp;复制代码&lt;/pre&gt;&lt;pre&gt;func&amp;nbsp;resizedImage3(at&amp;nbsp;url:&amp;nbsp;URL,&amp;nbsp;for&amp;nbsp;size:&amp;nbsp;CGSize)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage?{&amp;nbsp;let&amp;nbsp;ops:[CFString:Any]&amp;nbsp;=&amp;nbsp;[kCGImageSourceCreateThumbnailFromImageIfAbsent:true,&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceCreateThumbnailWithTransform:true,&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceShouldCacheImmediately:true,&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceThumbnailMaxPixelSize:max(size.width,&amp;nbsp;size.height)]&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;imageSource&amp;nbsp;=&amp;nbsp;CGImageSourceCreateWithURL(url&amp;nbsp;as&amp;nbsp;NSURL,&amp;nbsp;nil),&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;CGImageSourceCreateImageAtIndex(imageSource,&amp;nbsp;0,&amp;nbsp;ops&amp;nbsp;as&amp;nbsp;CFDictionary)&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil;&amp;nbsp;}&amp;nbsp;let&amp;nbsp;ima&amp;nbsp;=&amp;nbsp;UIImage(cgImage:&amp;nbsp;image)&amp;nbsp;printImageCost(image:&amp;nbsp;ima)&amp;nbsp;return&amp;nbsp;ima&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;h4 data-id=&quot;heading-16&quot;&gt;4.CoreImage 滤镜&lt;/h4&gt;&lt;p&gt;使用滤镜处理反而有点麻烦，在iOS不是专业处理图像的APP中略微臃肿，而且性能不是很好。在重复删除添加操作，第二次出现了APP闪退问题。&lt;/p&gt;&lt;pre&gt;Memory&amp;nbsp;&amp;nbsp;High:1.04G&amp;nbsp;normal:566M&amp;nbsp;CPU:&amp;nbsp;Hight:73%&amp;nbsp;normal:0%&amp;nbsp;复制代码&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;func&amp;nbsp;resizedImage4(at&amp;nbsp;url:&amp;nbsp;URL,&amp;nbsp;for&amp;nbsp;size:&amp;nbsp;CGSize)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage?{&amp;nbsp;let&amp;nbsp;shareContext&amp;nbsp;=&amp;nbsp;CIContext(options:&amp;nbsp;[.useSoftwareRenderer:false])&amp;nbsp;&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;CIImage(contentsOf:&amp;nbsp;url)&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;let&amp;nbsp;fillter&amp;nbsp;=&amp;nbsp;CIFilter(name:&amp;nbsp;&amp;quot;CILanczosScaleTransform&amp;quot;)&amp;nbsp;fillter?.setValue(image,&amp;nbsp;forKey:&amp;nbsp;kCIInputImageKey)&amp;nbsp;fillter?.setValue(1,&amp;nbsp;forKey:&amp;nbsp;kCIInputScaleKey)&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;outPutCIImage&amp;nbsp;=&amp;nbsp;fillter?.outputImage,let&amp;nbsp;outputCGImage&amp;nbsp;=&amp;nbsp;shareContext.createCGImage(outPutCIImage,&amp;nbsp;from:&amp;nbsp;outPutCIImage.extent)&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;return&amp;nbsp;UIImage(cgImage:&amp;nbsp;outputCGImage)&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;h4 data-id=&quot;heading-17&quot;&gt;5.使用 vImage 优化图片渲染&lt;/h4&gt;&lt;p&gt;使用&lt;code&gt;vImage&lt;/code&gt;创建图像性能略低，内存使用较多，步骤麻烦，是我们该舍弃的。在内存只有1G的手机上恐怕要&lt;code&gt;crash&lt;/code&gt;了。&lt;/p&gt;&lt;pre&gt;Memory&amp;nbsp;&amp;nbsp;High:998.7M&amp;nbsp;normal:566M&amp;nbsp;CPU:&amp;nbsp;Hight:78%&amp;nbsp;normal:0%&amp;nbsp;复制代码&lt;/pre&gt;&lt;pre&gt;func&amp;nbsp;resizedImage5(at&amp;nbsp;url:&amp;nbsp;URL,&amp;nbsp;for&amp;nbsp;size:&amp;nbsp;CGSize)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage?&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;解码源图像&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;imageSource&amp;nbsp;=&amp;nbsp;CGImageSourceCreateWithURL(url&amp;nbsp;as&amp;nbsp;NSURL,&amp;nbsp;nil),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;image&amp;nbsp;=&amp;nbsp;CGImageSourceCreateImageAtIndex(imageSource,&amp;nbsp;0,&amp;nbsp;nil),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;properties&amp;nbsp;=&amp;nbsp;CGImageSourceCopyPropertiesAtIndex(imageSource,&amp;nbsp;0,&amp;nbsp;nil)&amp;nbsp;as?&amp;nbsp;[CFString:&amp;nbsp;Any],&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;imageWidth&amp;nbsp;=&amp;nbsp;properties[kCGImagePropertyPixelWidth]&amp;nbsp;as?&amp;nbsp;vImagePixelCount,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;imageHeight&amp;nbsp;=&amp;nbsp;properties[kCGImagePropertyPixelHeight]&amp;nbsp;as?&amp;nbsp;vImagePixelCount&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;定义图像格式&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;format&amp;nbsp;=&amp;nbsp;vImage_CGImageFormat(bitsPerComponent:&amp;nbsp;8,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bitsPerPixel:&amp;nbsp;32,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;colorSpace:&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bitmapInfo:&amp;nbsp;CGBitmapInfo(rawValue:&amp;nbsp;CGImageAlphaInfo.first.rawValue),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;version:&amp;nbsp;0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;decode:&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;renderingIntent:&amp;nbsp;.defaultIntent)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;error:&amp;nbsp;vImage_Error&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;创建并初始化源缓冲区&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;sourceBuffer&amp;nbsp;=&amp;nbsp;vImage_Buffer()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;defer&amp;nbsp;{&amp;nbsp;sourceBuffer.data.deallocate()&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error&amp;nbsp;=&amp;nbsp;vImageBuffer_InitWithCGImage(&amp;amp;sourceBuffer,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;format,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;image,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImage_Flags(kvImageNoFlags))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;guard&amp;nbsp;error&amp;nbsp;==&amp;nbsp;kvImageNoError&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;创建并初始化目标缓冲区&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;destinationBuffer&amp;nbsp;=&amp;nbsp;vImage_Buffer()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error&amp;nbsp;=&amp;nbsp;vImageBuffer_Init(&amp;amp;destinationBuffer,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImagePixelCount(size.height),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImagePixelCount(size.width),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;format.bitsPerPixel,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImage_Flags(kvImageNoFlags))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;guard&amp;nbsp;error&amp;nbsp;==&amp;nbsp;kvImageNoError&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;优化缩放图像&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error&amp;nbsp;=&amp;nbsp;vImageScale_ARGB8888(&amp;amp;sourceBuffer,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;destinationBuffer,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImage_Flags(kvImageHighQualityResampling))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;guard&amp;nbsp;error&amp;nbsp;==&amp;nbsp;kvImageNoError&amp;nbsp;else&amp;nbsp;{&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;从目标缓冲区创建一个&amp;nbsp;CGImage&amp;nbsp;对象&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;guard&amp;nbsp;let&amp;nbsp;resizedImage&amp;nbsp;=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImageCreateCGImageFromBuffer(&amp;amp;destinationBuffer,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;format,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vImage_Flags(kvImageNoAllocate),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;error)?.takeRetainedValue(),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error&amp;nbsp;==&amp;nbsp;kvImageNoError&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;nil&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;UIImage(cgImage:&amp;nbsp;resizedImage)&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;h3 data-id=&quot;heading-18&quot;&gt;内存优化&lt;/h3&gt;&lt;p&gt;图片解码后加载在内存中的数据需要在恰当的时机删除掉，在合适的时机添加上，也是保持低内存使用率的手段。&lt;/p&gt;&lt;p&gt;在用户拨打电话或者进入到其他APP中可以先删除掉大图片，等回来的时候再次添加也是不错的选择。&lt;/p&gt;&lt;pre&gt;#&amp;nbsp;1&amp;nbsp;NotificationCenter.default.addObserver(forName:&amp;nbsp;UIApplication.didEnterBackgroundNotification,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;object:&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;queue:&amp;nbsp;.main)&amp;nbsp;{[weak&amp;nbsp;self]&amp;nbsp;(note)&amp;nbsp;in&amp;nbsp;self?.unloadImage()&amp;nbsp;}&amp;nbsp;NotificationCenter.default.addObserver(forName:&amp;nbsp;UIApplication.willEnterForegroundNotification,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;object:&amp;nbsp;nil,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;queue:&amp;nbsp;.main)&amp;nbsp;{[weak&amp;nbsp;self]&amp;nbsp;(note)&amp;nbsp;in&amp;nbsp;self?.loadImage()&amp;nbsp;}&amp;nbsp;#&amp;nbsp;2&amp;nbsp;override&amp;nbsp;func&amp;nbsp;viewWillAppear(_&amp;nbsp;animated:&amp;nbsp;Bool)&amp;nbsp;{&amp;nbsp;super.viewWillAppear(animated)&amp;nbsp;self.loadImage()&amp;nbsp;}&amp;nbsp;override&amp;nbsp;func&amp;nbsp;viewWillDisappear(_&amp;nbsp;animated:&amp;nbsp;Bool)&amp;nbsp;{&amp;nbsp;super.viewWillDisappear(animated)&amp;nbsp;self.unloadImage()&amp;nbsp;}&amp;nbsp;复制代码&lt;/pre&gt;&lt;h2 data-id=&quot;heading-19&quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/ifgyong/demo/tree/master/Swift/test-image-%E4%BC%98%E5%8C%96&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;DemoCode download from github&lt;/a&gt;&lt;/h2&gt;&lt;h3 data-id=&quot;heading-20&quot;&gt;总结&lt;/h3&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;基于性能综合考虑方法1是最简单最合适的&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;使用滤镜和&lt;code&gt;vImage&lt;/code&gt;略微复杂点，平时开发过程中可以不用考虑了。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;图片解码缓存和图片大小有关，适当的下采样是不错的选择。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-id=&quot;heading-21&quot;&gt;参考&lt;/h3&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://developer.apple.com/videos/play/wwdc2018/416&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;session 2018 416 iOS Memory Deep Dive&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://developer.apple.com/videos/play/wwdc2018/219&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;219_image_and_graphics_best_practices&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/ifgyong/iOSDataFactory&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;WWDC 中文字幕下载&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://juejin.im/post/5daaf8b3f265da5b6f074c98#heading-1&quot; rel=&quot;&quot;&gt;swift gg 图像优化&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/ifgyong/iOSDataFactory&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;学习资料下载git&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/ifgyong/demo/tree/master/Swift/test-image-%E4%BC%98%E5%8C%96&quot; rel=&quot;nofollow noopener noreferrer&quot;&gt;demo code git&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;作者：fgyong&lt;br/&gt;链接：https://juejin.im/post/5ddc8258518825734f2b8eb2&lt;br/&gt;来源：掘金&lt;br/&gt;著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Mon, 23 Dec 2019 17:33:19 +0800</pubDate></item><item><title>头条 穿山甲广告 错误码列表</title><link>https://suwenclub.cn/?id=23</link><description>&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;08223c&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;20000&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;0f5f76&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;成功&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;238abe&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;20001&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;b9845d&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;没有合适的广告返回而导致的请求没有填充，偶尔出现属于正常情况。如果出现情况较多或者必现的话，请先检查一下广告尺寸是否填写正确，是否有使用模拟器测试广告，单个设备是否一天请求了大量广告但没有展示或者展示数极低等。排查以上问题依然没有结论可以联系技术支持同学或者提交工单（包含代码位和出现概率以及请求时间）相关同学查明后会做出回复。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;b95ce2&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40000&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;90d0dd&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;http content type错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;0453d7&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40001&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;b6345a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;http request pb错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;73fb0f&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40002&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;e53817&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;source_type=‘app’, 请求app不能为空&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;40ec53&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40003&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;cf6cb5&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;source_type=‘wap’, 请求wap不能为空&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;2f8992&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40004&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;17ed42&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;广告位不能为空&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;dbfddc&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40005&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a8e7ee&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;广告位尺寸不能为空&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ea3eab&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40006&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;104a4c&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;广告位ID不合法，例如，位数不对或者输入的广告位ID错误。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d6552a&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40007&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ebcc6e&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;广告数量错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;3ace8c&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40008&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d94a5b&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;图片尺寸错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d0e4e6&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40009&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;97ce0b&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体ID不合法&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;84a52f&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40010&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;59e14e&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体类型不合法&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;9526e8&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40011&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a098d5&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;广告类型不合法&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;85aa3f&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40013&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;7a444e&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;代码位ID是开屏代码位，但是adType不是开屏&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ce37a9&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40014&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;2b0f46&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;redirect参数不正确&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;3c02cc&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40015&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;c23e16&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体请求里的字段上传的不正确或不完整，需要整改，请关注站内信的整改通知。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d5f276&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40016&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;c81887&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;代码位ID 与应用ID 不匹配或者应用ID 缺失。初始化时需要填写appid，且在activity中需要填写代码位ID。媒体要确保这两个ID填写正确且匹配。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;787067&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40017&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;81017f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体接入类型不合法 API/SDK&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;1da829&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40018&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;dfb8b4&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体在平台上录入的包名与项目里的包名不一致。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;446c10&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40019&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;16cc98&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体在平台上申请的代码位广告类型和代码中使用的广告类型接口不一致。例如平台上是开屏的广告类型，但是代码中请求的接口是banner或者其他非开屏的广告类型，如果不太清楚不同代码位类型对应的接口，麻烦去查询SDK包里的对接文档。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;3bf8b0&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40020&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;8756a1&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;开发注册新上线广告位超出日请求量限制&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;3c35c9&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40021&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;6f8c57&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;apk签名SHA1值与媒体平台录入的SHA1不一致&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d3b02a&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40022&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a92bc2&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;媒体在平台上申请的代码位“是否原生”属性与代码中使用的接口不匹配。例如：&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;d19ed9&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;1. 媒体在平台上选择的是个性化模板banner广告的话，Android代码中请参考BannerExpressActivity进行调用；iOS代码中请参考BUDExpressBannerViewController进行调用。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;71f7e5&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;2. 媒体在平台上选择的是个性化模板插屏广告的话，代码中请参考InteractionExpressActivity进行调用；iOS代码位中请参考BUDExpressInterstitialViewController进行调用。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;31190b&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;PS：模板广告会带有express字样标识。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;e1a8c6&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40023&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;1c0822&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;os字段填的不对&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a1d2a0&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40024&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;58f707&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;sdk 版本过低不返回广告&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;9bc9cb&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40025&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;e6a828&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;渲染异常，分为两种情况：&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;617211&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;1.Android版本，媒体使用了非该应用所属账号下的SDK版本导致，请媒体到该代码位所属账号下工具-文档下载展示的SDK版本去进行接入。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;98370a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;2.iOS版本，媒体使用2100之前的版本可能渲染异常，请媒体更新到最新版本接入即可解决该问题。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a12c36&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40026&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;b463b7&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;使用海外ip请求国内服务器导致，请确认使用的是国内ip请求广告。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;bbbe3d&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40028&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;21faa2&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;ios老设备（涉及设备 iPad 4G/iPad 3G/iPhone 5/iPhone 5C/iPad Mini 1G/iPad 2G/iPhone 4S）被屏蔽，会不返回广告。在2310版本后放开了限制，媒体可以更新到2310或者之后的版本。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;dcebd5&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;40029&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a2d87a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;两种情况：&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;89b67a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;1. SDK版本低：您使用的sdk版本不得低于2.5.0.0，麻烦升级到平台最新版本sdk。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;feca50&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;2. 接口使用错误：创建的代码位类型是模板渲染/非模板渲染，但是请求方法是非模板渲染/模板渲染的方法。解决办法：使用模板渲染的方法去请求模板渲染类型或者使用非模板渲染的方法去请求非模板类型的广告，如果代码位在平台上是模板渲染，可以参考文档中个性化模板XX广告的部分，demo中参考带有express部分的代码。如果代码位不是模板渲染，则不要调用含有express字样的接口。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;83ab0c&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;参考文档：https://partner.oceanengine.com/doc?id=5de4cc6d78c8690012a90aa5&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;558424&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;50001&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;2c8cbb&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;服务器错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;4a8fda&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;60001&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;58b15b&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;show event处理错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;7c22c6&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;60002&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;38d9fe&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;click event处理错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;541517&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;60007&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;5b2b2f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;激励视频验证服务器异常或处理失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ca6c26&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-1&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;acebfa&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;数据解析失败。客户端代码问题的合集，可先排查以下情况：&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;43a00e&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;1.媒体在子线程调用了show。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;6243fc&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;2.注册点击事件时viewgroup传空。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;6cceca&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;3.媒体在onFeedLoaded回调里的业务逻辑发生了异常，导致SDK走到了onError回调中。 排查以上问题依然没有结论可以联系技术支持同学或者提交工单（包含代码位和出现概率以及请求时间）&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;05ab2d&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-2&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;b9012a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;网络错误&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;c50475&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-3&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;e0c5c2&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;解析数据没有ad&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;9812de&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-4&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;de05d1&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;返回数据缺少必要字段&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;878771&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-5&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;049ec1&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;bannerAd加载图片失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;674ad2&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-6&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;93d444&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;插屏广告图片加载失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;47f5dc&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-7&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;15b56f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;开屏广告图片加载失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;785409&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-8&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;fad355&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;频繁请求&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;9e274f&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-9&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;68e209&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;请求实体为空&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;37a7ea&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-10&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;a47103&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;缓存解析失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;39af63&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-11&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ccc42f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;缓存过期&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;8cc29d&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;-12&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;743b8e&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;缓存中没有开屏广告&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;065bc6&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;101&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;02153f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;渲染结果数据解析失败&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;177afc&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;102&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;95d9ab&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;未匹配到主模板：主模板没有下载到本地导致。偶发在首次请求广告时属于正常情况。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;5a16e1&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;103&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;757439&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;未匹配到子模板：偶发在接入初期，没有匹配到模板导致。待sdk将模板下载成功后不会出现。&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;c1a7be&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;104&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;40e31f&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;物料数据异常&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;f7424b&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;105&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;f4e154&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;模版数据解析异常&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;2f88f4&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;106&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;3ed726&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;渲染异常&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;ce123b&quot; class=&quot;css-1jf2azw&quot; style=&quot;box-sizing: border-box; font-size: 16px; font-family: PingFangSC-Medium, PingFangSC; color: rgb(34, 34, 34); line-height: 23px; padding-bottom: 24px;&quot;&gt;107&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: rgba(0, 0, 0, 0.65); font-family: PingFangSC-Regular, PingFangSC; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div id=&quot;33340a&quot; style=&quot;box-sizing: border-box; line-height: 24px; padding-bottom: 16px; color: rgb(102, 102, 102);&quot;&gt;模板渲染超时未回调，可能原因有1. 网络原因或者2. 硬件原因，因此导致渲染失败，可以更换手机或者网络环境测试。&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Wed, 11 Dec 2019 16:56:16 +0800</pubDate></item><item><title>国内外8000多个电视台一网打尽，这个开源项目要火！</title><link>https://suwenclub.cn/?id=22</link><description>&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;平常猿妹都是和大家分享一些Github上和程序员相关的项目，比如编程面试相关的，或者是一些好用的框架等，今天，猿妹要和大家介绍一个休闲娱乐型的项目，程序员也不能整天就是写Bug，你说是不是？&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;今天介绍的是一个可以看电视的开源项目，国内外8000多个电视台随便你挑选，互联网协议电视（IPTV）是通过互联网协议（IP）网络传送电视内容的方法。它可以很好的适应当今网络飞速发展的趋势。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048984364621.jpeg&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-isloading=&quot;1&quot; data-bd-imgshare-binded=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;目前，已经登上Github Trending 周榜第四名，标星10781,1314个Fork（Github地址：https://github.com/iptv-org/iptv）&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;使用方法也很简单，首先，你需要安装一个可以M3U播放列表的开源软件，下载地址：https://www.videolan.org/vlc/download-windows.html。你也可以直接将想应的视频链接粘贴到具有支持M3U播放列表的任何播放器。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048985825529.jpeg&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;你也可以改用以下播放列表之一：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot; style=&quot;list-style-type: none;&quot;&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;https://iptv-org.github.io/iptv/index.country.m3u （按地区分组）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;https://iptv-org.github.io/iptv/index.category.m3u （按类别分组）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;https://iptv-org.github.io/iptv/index.language.m3u （按语言分组）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;按类别播放列表&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048985311358.png&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;按语言播放列表&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048986145690.png&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;按类别播放列表&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048986804344.png&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;下面，我们以中国（https://iptv-org.github.io/iptv/countries/cn.m3u）为例演示一遍。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: justify; background-color: rgb(255, 255, 255);&quot;&gt;如果你已经下载好了VLC，你只要打开运行，点击媒体-打开网络串流，输入以上地址，就可以查看中国2000多个频道：&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048987841940.jpeg&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;稍等片刻，你就可以看到2200多个中国频道在你面前一列铺开，你只要选择自己想看的频道就可以了：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048987699626.png&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;下面我们一起来看看效果，先来看看CCTV-1的效果：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048987631995.jpeg&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;这个画质高清度，猿妹觉得还是可以的，再来看看东南卫视：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; text-align: center; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//image/20191211/1576048988410148.jpeg&quot; alt=&quot;å›½å†…å¤–8000å¤šä¸ªç”µè§†å°ä¸€ç½‘æ‰“å°½ï¼Œè¿™ä¸ªå¼€æºé¡¹ç›®è¦ç«ï¼&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: none; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px 0px 15px; border: 0px; outline: 0px; list-style: none; font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 16px; color: rgb(51, 51, 51); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-size: 15px;&quot;&gt;整体觉得如何呢？国外的频道就不一一演示了，如果你对它感兴趣，可以自己尝试。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;&quot;&gt;本文来自&lt;/span&gt;&lt;a href=&quot;https://mp.weixin.qq.com/s?__biz=MzA3NzA2MDMyNA==&amp;mid=2650353031&amp;idx=1&amp;sn=925e9dbed78787eeab74674fd20bc5e0&amp;chksm=875a4c0cb02dc51a3e1510bf8cd63fc5fe05918da7aff65001fc5f7078999e5601600a6688c4&amp;mpshare=1&amp;&quot; style=&quot;box-sizing: border-box; background-color: rgb(255, 255, 255); color: rgb(42, 42, 42); margin: 0px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; white-space: normal;&quot;&gt;&amp;nbsp;开源最前线&amp;nbsp;&lt;/a&gt;&lt;span style=&quot;color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;&quot;&gt;，作者 猿妹&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 11 Dec 2019 15:43:41 +0800</pubDate></item><item><title>iOS证书签名机制&amp;amp;重签名&amp;amp;防止重签名</title><link>https://suwenclub.cn/?id=21</link><description>&lt;h2 data-id=&quot;heading-0&quot; id=&quot;cocoachina0&quot; style=&quot;box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;iOS签名机制&lt;/h2&gt;&lt;h3 data-id=&quot;heading-1&quot; id=&quot;cocoachina1&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;概念&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;相比安卓系统随便从哪里下载都能运行，系统安全存在许多隐患，例如盗版软件、病毒入侵、静默安装等等。苹果为了控制手机上的所有应用必须是经过授权的，规定正规应用只能在AppStore下载，同时对于调试阶段的安装、灰度测试和企业分发，苹果使用双重签名机制来控制应用权限并使其不被滥用。先介绍一些概念便于后续的理解。&lt;/p&gt;&lt;h4 data-id=&quot;heading-2&quot; id=&quot;cocoachina2&quot; style=&quot;box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;非对称加密&lt;/h4&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;非对称加密则两份密钥，分别是公钥和私钥，用公钥加密的数据，要用私钥才能解密，用私钥加密的数据，要用公钥才能解密。正常情况下，公钥可以对外公开，而私钥需私密保存。我们常用&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;公钥加密私钥解密&lt;/span&gt;的方式来进行加密防止数据明文传输，用&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;私钥加密公钥解密&lt;/span&gt;的方式来签名确保数据的完整性防止被篡改。&lt;/p&gt;&lt;h4 data-id=&quot;heading-3&quot; id=&quot;cocoachina3&quot; style=&quot;box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;数字摘要&lt;/h4&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;将任意长度的源文本通过Hash函数计算得到一窜固定长度的文本，要保证不同源文本计算得到的值各不相同，且不能被反推得到源文本。常用的Hash算法有MD5和SHA。&lt;/p&gt;&lt;h4 data-id=&quot;heading-4&quot; id=&quot;cocoachina4&quot; style=&quot;box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;数字签名&lt;/h4&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;又称公钥数字签名，是非对称加密与数字摘要的结合，用于验证数据的完整性及不可抵赖性。发送方用接收方的公钥对摘要进行加密后和报文一起发送，接受方接受后用相同的Hash算法对报文进行摘要计算，接着用自己的私钥解密得到发送方的摘要，如果两个摘要相同则接收方就能确认该报文是对方发出的且未被篡改。&lt;/p&gt;&lt;h4 data-id=&quot;heading-5&quot; id=&quot;cocoachina5&quot; style=&quot;box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;其他&lt;/h4&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//20191211/1576049725126335.png&quot; title=&quot;1576049725126335.png&quot; alt=&quot;image.png&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;/p&gt;&lt;h3 data-id=&quot;heading-6&quot; id=&quot;cocoachina6&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;AppStore签名&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;将App提交审核后，苹果会用官方的私钥对我们提交的App重签名，用户下载到手机后，iOS设备内置的公钥会对App进行验证，验证成功即可正常使用。&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;所以App上传到AppStore后，就跟我们本地的证书/Provisioning Profile 都没有关系了，无论是否过期或被废除，都不会影响 AppStore 上的安装包。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;figure style=&quot;box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//20191211/1576049732640575.png&quot; title=&quot;1576049732640575.png&quot; alt=&quot;image.png&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;figcaption style=&quot;box-sizing: border-box;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;h3 data-id=&quot;heading-7&quot; id=&quot;cocoachina7&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Xcode安装&amp;amp;Adhoc&amp;amp;In-House&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;对于非AppStore安装的应用苹果采用了双重签名的方式，用到了两对密钥，Mac电脑密钥对L，苹果官方密钥对A。&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot; style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;我们在进行开发时，会从Mac的keychain 里的 “从证书颁发机构请求证书生成”CertificateSigningRequest(含有Mac的公钥L信息)文件上传到苹果后台，苹果会用其私钥A对公钥L签名，并生成一份包含公钥L信息和苹果签名信息的开发/发布证书cer，当我们将cer下载到Mac后，keychain会把CertificateSigningRequest和证书关联起来。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;在苹果后台配置AppID,可用设备IDs(企业证书不需要)和Entitlements,用这些额外信息和证书再用私钥A签名，最后苹果将证书+额外信息+签名组成一个Provisioning Profile文件(mobileprovision后缀)，下载到Mac上。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;在Mac上编译完一个App后，Mac会用私钥L对App签名，并将Provisioning Profile文件也打包到App中，文件名为 embedded.mobileprovision。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;安装时，苹果通过内置在手机中的公钥A验证embedded.mobileprovision中的签名是否正确，接着验证证书中的签名是否正确。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;&quot;&gt;确保了 embedded.mobileprovision 里的数据都是苹果授权以后，就可以取出里面的数据，做各种验证，包括用公钥 L 验证APP签名，验证设备 ID 是否在 ID 列表上，验证证书是否过期，AppID 是否对应得上，权限开关是否跟 APP 里的 Entitlements 对应等等。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;如果别的 Mac 也要编译签名这个 App，可以将私钥导出给其他 Mac 用，在 keychain 里导出私钥，就会存成.p12 文件，其他 Mac 导入了这个私钥后便可用同一套苹果证书及Provisioning Profile文件。 In-House安装不限制设备ID数。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;figure style=&quot;box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//20191211/1576049745202896.png&quot; title=&quot;1576049745202896.png&quot; alt=&quot;image.png&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;figcaption style=&quot;box-sizing: border-box;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;h2 data-id=&quot;heading-8&quot; id=&quot;cocoachina8&quot; style=&quot;box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;重签名&lt;/h2&gt;&lt;h3 data-id=&quot;heading-9&quot; id=&quot;cocoachina9&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;完全重签名&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;重签是把已发布/未发布的包重新签名为自己的证书和签名，关键就是替换ipa内的证书和描述文件。主要通过&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;codesign&lt;/span&gt;命令完成。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;0 查看ipa包是否加壳，只有未加壳的包才可以重签名。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;$&amp;nbsp;otool&amp;nbsp;-l&amp;nbsp;「Mach-O文件」&amp;nbsp;|&amp;nbsp;grep&amp;nbsp;crypt
//&amp;nbsp;输出cryptid为0代表已经砸壳，即解密，为1或者2表示以第1类或者第2类加密方案加密。复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;1.1 查看本地证书列表并记录下要用来签名的证书名，例如&amp;quot;iPhone Distribution: XXXXX (XXX)&amp;quot;。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;$&amp;nbsp;security&amp;nbsp;find-identity&amp;nbsp;-v&amp;nbsp;-p&amp;nbsp;codesigning复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;1.2 新建Xcode工程，用1.1证书编译后生成新App，将App包里&lt;code style=&quot;box-sizing: border-box;&quot;&gt;embedded.mobileprovision&lt;/code&gt;文件取出替换ipa包中的文件。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;2.1 删除ipa包内部可被重签名的插件（PlugIns目录下）。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;2.2 将ipa包内的所有Framework重签名（Frameworks目录下）。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;$&amp;nbsp;codesign&amp;nbsp;-fs&amp;nbsp;&amp;quot;iPhone&amp;nbsp;Distribution:&amp;nbsp;XXXXX&amp;nbsp;(XXX)&amp;quot;&amp;nbsp;&amp;nbsp;xxx.framework复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;2.3 查看Mach-O文件是否有系统权限，若没有则添加权限。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;$&amp;nbsp;chmod&amp;nbsp;+x&amp;nbsp;「Mach-O文件」复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;3.1 将ipa包内info.plist的BundleId修改为1.1中工程的BundleId。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;3.2 用命令查看embedded.mobileprovision文件，找到其中的entitlements字段，并且复制entitlements字段和其中的内容。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;$&amp;nbsp;security&amp;nbsp;cms&amp;nbsp;-D&amp;nbsp;-i&amp;nbsp;「embedded文件路径」复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;3.3 新建entitlements.plist文件，将复制内容拷贝到文件中，然后将entitlements.plist复制到ipa的同级目录下。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;3.4 对App进行重签名，并压缩成新的ipa包。&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;//重签名
$&amp;nbsp;codesign&amp;nbsp;-fs&amp;nbsp;&amp;quot;iPhone&amp;nbsp;Distribution:&amp;nbsp;XXXXX&amp;nbsp;(XXX)&amp;quot;&amp;nbsp;--no-strict&amp;nbsp;--entitlements=entitlements.plist

//压缩ipa包
$&amp;nbsp;zip&amp;nbsp;-r&amp;nbsp;「输出的文件名(.ipa)」&amp;nbsp;Payload/复制代码&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;4 将ipa包安装到手机，若能同时存在两个应用且能正常运行则表示重签名成功。&lt;/p&gt;&lt;h3 data-id=&quot;heading-10&quot; id=&quot;cocoachina10&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Shell脚本重签名&lt;/h3&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;#&amp;nbsp;${SRCROOT}&amp;nbsp;它是工程文件所在的目录
TEMP_PATH=&amp;quot;${SRCROOT}/Temp&amp;quot;
#资源文件夹，我们提前在工程目录下新建一个APP文件夹，里面放ipa包
ASSETS_PATH=&amp;quot;${SRCROOT}/APP&amp;quot;
#目标ipa包路径
TARGET_IPA_PATH=&amp;quot;${ASSETS_PATH}/*.ipa&amp;quot;
#清空Temp文件夹
rm&amp;nbsp;-rf&amp;nbsp;&amp;quot;${SRCROOT}/Temp&amp;quot;
mkdir&amp;nbsp;-p&amp;nbsp;&amp;quot;${SRCROOT}/Temp&amp;quot;

#----------------------------------------
#&amp;nbsp;1.&amp;nbsp;解压IPA到Temp下
unzip&amp;nbsp;-oqq&amp;nbsp;&amp;quot;$TARGET_IPA_PATH&amp;quot;&amp;nbsp;-d&amp;nbsp;&amp;quot;$TEMP_PATH&amp;quot;
#&amp;nbsp;拿到解压的临时的APP的路径
TEMP_APP_PATH=$(set&amp;nbsp;--&amp;nbsp;&amp;quot;$TEMP_PATH/Payload/&amp;quot;*.app;echo&amp;nbsp;&amp;quot;$1&amp;quot;)
#&amp;nbsp;echo&amp;nbsp;&amp;quot;路径是:$TEMP_APP_PATH&amp;quot;

#----------------------------------------
#&amp;nbsp;2.&amp;nbsp;将解压出来的.app拷贝进入工程下
#&amp;nbsp;BUILT_PRODUCTS_DIR&amp;nbsp;工程生成的APP包的路径
#&amp;nbsp;TARGET_NAME&amp;nbsp;target名称
TARGET_APP_PATH=&amp;quot;$BUILT_PRODUCTS_DIR/$TARGET_NAME.app&amp;quot;
echo&amp;nbsp;&amp;quot;app路径:$TARGET_APP_PATH&amp;quot;

rm&amp;nbsp;-rf&amp;nbsp;&amp;quot;$TARGET_APP_PATH&amp;quot;
mkdir&amp;nbsp;-p&amp;nbsp;&amp;quot;$TARGET_APP_PATH&amp;quot;
cp&amp;nbsp;-rf&amp;nbsp;&amp;quot;$TEMP_APP_PATH/&amp;quot;&amp;nbsp;&amp;quot;$TARGET_APP_PATH&amp;quot;

#----------------------------------------
#&amp;nbsp;3.&amp;nbsp;删除extension和WatchAPP.个人证书没法签名Extention
rm&amp;nbsp;-rf&amp;nbsp;&amp;quot;$TARGET_APP_PATH/PlugIns&amp;quot;
rm&amp;nbsp;-rf&amp;nbsp;&amp;quot;$TARGET_APP_PATH/Watch&amp;quot;

#----------------------------------------
#&amp;nbsp;4.&amp;nbsp;更新info.plist文件&amp;nbsp;CFBundleIdentifier
#&amp;nbsp;&amp;nbsp;设置:&amp;quot;Set&amp;nbsp;:&amp;nbsp;KEY&amp;nbsp;Value&amp;quot;&amp;nbsp;&amp;quot;目标文件路径&amp;quot;
/usr/libexec/PlistBuddy&amp;nbsp;-c&amp;nbsp;&amp;quot;Set&amp;nbsp;:CFBundleIdentifier&amp;nbsp;$PRODUCT_BUNDLE_IDENTIFIER&amp;quot;&amp;nbsp;&amp;quot;$TARGET_APP_PATH/Info.plist&amp;quot;
#----------------------------------------

#&amp;nbsp;5.&amp;nbsp;给MachO文件上执行权限
#&amp;nbsp;拿到MachO文件的路径
APP_BINARY=`plutil&amp;nbsp;-convert&amp;nbsp;xml1&amp;nbsp;-o&amp;nbsp;-&amp;nbsp;$TARGET_APP_PATH/Info.plist|grep&amp;nbsp;-A1&amp;nbsp;Exec|tail&amp;nbsp;-n1|cut&amp;nbsp;-f2&amp;nbsp;-d\&amp;gt;|cut&amp;nbsp;-f1&amp;nbsp;-d\&amp;lt;`
#上可执行权限
chmod&amp;nbsp;+x&amp;nbsp;&amp;quot;$TARGET_APP_PATH/$APP_BINARY&amp;quot;

#----------------------------------------
#&amp;nbsp;6.&amp;nbsp;重签名第三方&amp;nbsp;FrameWorks
TARGET_APP_FRAMEWORKS_PATH=&amp;quot;$TARGET_APP_PATH/Frameworks&amp;quot;
if&amp;nbsp;[&amp;nbsp;-d&amp;nbsp;&amp;quot;$TARGET_APP_FRAMEWORKS_PATH&amp;quot;&amp;nbsp;];
then
for&amp;nbsp;FRAMEWORK&amp;nbsp;in&amp;nbsp;&amp;quot;$TARGET_APP_FRAMEWORKS_PATH/&amp;quot;*
do

#&amp;nbsp;签名
/usr/bin/codesign&amp;nbsp;--force&amp;nbsp;--sign&amp;nbsp;&amp;quot;$EXPANDED_CODE_SIGN_IDENTITY&amp;quot;&amp;nbsp;&amp;quot;$FRAMEWORK&amp;quot;
done
fi复制代码&lt;/pre&gt;&lt;h2 data-id=&quot;heading-11&quot; style=&quot;box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;如何防止应用被重签名&lt;/h2&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;内容来源于「iOS安全防护之重签名防护和sysctl反调试」。&lt;/p&gt;&lt;h3 data-id=&quot;heading-12&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;校验描述文件信息&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;可以在启动时校验描述文件信息与打包时是否一致。例如判断组织单位:&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;先记录证书中的组织单位信息。&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;figure style=&quot;box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://api.cocoachina.com/uploads//20191211/1576049805655746.png&quot; title=&quot;1576049805655746.png&quot; alt=&quot;image.png&quot; data-bd-imgshare-binded=&quot;1&quot; data-isloading=&quot;1&quot; style=&quot;box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;&quot;/&gt;&lt;figcaption style=&quot;box-sizing: border-box;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;span style=&quot;color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 15px; background-color: #FFFFFF;&quot;&gt;在启动时检测是否一致。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;void&amp;nbsp;&amp;nbsp;checkCodesign(NSString&amp;nbsp;*id){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;描述文件路径
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSString&amp;nbsp;*embeddedPath&amp;nbsp;=&amp;nbsp;[[NSBundle&amp;nbsp;mainBundle]&amp;nbsp;pathForResource:@&amp;quot;embedded&amp;quot;&amp;nbsp;ofType:@&amp;quot;mobileprovision&amp;quot;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;读取application-identifier&amp;nbsp;&amp;nbsp;注意描述文件的编码要使用:NSASCIIStringEncoding
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSString&amp;nbsp;*embeddedProvisioning&amp;nbsp;=&amp;nbsp;[NSString&amp;nbsp;stringWithContentsOfFile:embeddedPath&amp;nbsp;encoding:NSASCIIStringEncoding&amp;nbsp;error:nil];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSArray&amp;nbsp;*embeddedProvisioningLines&amp;nbsp;=&amp;nbsp;[embeddedProvisioning&amp;nbsp;componentsSeparatedByCharactersInSet:[NSCharacterSet&amp;nbsp;newlineCharacterSet]];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&amp;nbsp;(int&amp;nbsp;i&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;embeddedProvisioningLines.count;&amp;nbsp;i++)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;([embeddedProvisioningLines[i]&amp;nbsp;rangeOfString:@&amp;quot;application-identifier&amp;quot;].location&amp;nbsp;!=&amp;nbsp;NSNotFound)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSInteger&amp;nbsp;fromPosition&amp;nbsp;=&amp;nbsp;[embeddedProvisioningLines[i+1]&amp;nbsp;rangeOfString:@&amp;quot;&amp;quot;].location+8;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSInteger&amp;nbsp;toPosition&amp;nbsp;=&amp;nbsp;[embeddedProvisioningLines[i+1]&amp;nbsp;rangeOfString:@&amp;quot;&amp;quot;].location;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSRange&amp;nbsp;range;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;range.location&amp;nbsp;=&amp;nbsp;fromPosition;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;range.length&amp;nbsp;=&amp;nbsp;toPosition&amp;nbsp;-&amp;nbsp;fromPosition;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSString&amp;nbsp;*fullIdentifier&amp;nbsp;=&amp;nbsp;[embeddedProvisioningLines[i+1]&amp;nbsp;substringWithRange:range];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSArray&amp;nbsp;*identifierComponents&amp;nbsp;=&amp;nbsp;[fullIdentifier&amp;nbsp;componentsSeparatedByString:@&amp;quot;.&amp;quot;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSString&amp;nbsp;*appIdentifier&amp;nbsp;=&amp;nbsp;[identifierComponents&amp;nbsp;firstObject];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;对比签名ID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(![appIdentifier&amp;nbsp;isEqual:id])&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//exit
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;asm(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;mov&amp;nbsp;X0,#0\n&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;mov&amp;nbsp;w16,#1\n&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;svc&amp;nbsp;#0x80&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}复制代码&lt;/pre&gt;&lt;h3 data-id=&quot;heading-13&quot; style=&quot;box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;sysctl检测是否被调试&lt;/h3&gt;&lt;pre style=&quot;box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;&quot;&gt;#import&amp;nbsp;bool&amp;nbsp;checkDebugger(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//控制码
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&amp;nbsp;name[4];//放字节码-查询信息
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name[0]&amp;nbsp;=&amp;nbsp;CTL_KERN;//内核查看
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name[1]&amp;nbsp;=&amp;nbsp;KERN_PROC;//查询进程
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name[2]&amp;nbsp;=&amp;nbsp;KERN_PROC_PID;&amp;nbsp;//通过进程id查进程
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name[3]&amp;nbsp;=&amp;nbsp;getpid();//拿到自己进程的id
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//查询结果
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;struct&amp;nbsp;kinfo_proc&amp;nbsp;info;//进程查询信息结果
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_t&amp;nbsp;info_size&amp;nbsp;=&amp;nbsp;sizeof(info);//结构体大小
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&amp;nbsp;error&amp;nbsp;=&amp;nbsp;sysctl(name,&amp;nbsp;sizeof(name)/sizeof(*name),&amp;nbsp;&amp;amp;info,&amp;nbsp;&amp;amp;info_size,&amp;nbsp;0,&amp;nbsp;0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;assert(error&amp;nbsp;==&amp;nbsp;0);//0就是没有错误
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//结果解析&amp;nbsp;p_flag的第12位为1就是有调试
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//p_flag&amp;nbsp;与&amp;nbsp;P_TRACED&amp;nbsp;=0&amp;nbsp;就是有调试
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;((info.kp_proc.p_flag&amp;nbsp;&amp;amp;&amp;nbsp;P_TRACED)&amp;nbsp;!=0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
...
...
//检测异常时退出
if&amp;nbsp;(checkDebugger())&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;asm(&amp;quot;mov&amp;nbsp;X0,#0\n&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;mov&amp;nbsp;w16,#1\n&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;svc&amp;nbsp;#0x80&amp;quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
...复制代码&lt;/pre&gt;&lt;h2 data-id=&quot;heading-14&quot; style=&quot;box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;参考链接&lt;/h2&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://blog.cnbang.net/tech/3386/&quot; rel=&quot;nofollow noopener noreferrer&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;&quot;&gt;iOS App 签名的原理&lt;/a&gt;&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://juejin.im/post/5c7e796351882532cd57adc4&quot; rel=&quot;&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;&quot;&gt;iOS逆向(3)-APP重签名&lt;/a&gt;&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.jianshu.com/p/248d3d2c323c&quot; rel=&quot;nofollow noopener noreferrer&quot; style=&quot;box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;&quot;&gt;iOS安全防护之重签名防护和sysctl反调试&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;&quot;&gt;本文来自&lt;/span&gt;&lt;a href=&quot;https://juejin.im/post/5de4acc7518825766e7a8489&quot; style=&quot;box-sizing: border-box; background-color: rgb(255, 255, 255); color: rgb(42, 42, 42); margin: 0px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; white-space: normal;&quot;&gt;&amp;nbsp;juejin&amp;nbsp;&lt;/a&gt;&lt;span style=&quot;color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;&quot;&gt;，作者 SimonYe&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 11 Dec 2019 15:42:23 +0800</pubDate></item><item><title>CocoaPods指定版本号带~&amp;gt;与不带的区别</title><link>https://suwenclub.cn/?id=20</link><description>&lt;div&gt;&lt;div&gt;&lt;h5&gt;带~&amp;gt; 是指定一个范围的版本号&lt;/h5&gt;&lt;h6&gt;~&amp;gt; 大于等于指定的版本号，小于高一位的版本号&lt;/h6&gt;&lt;p&gt;eg：&lt;br/&gt;~&amp;gt; 0.1.x &amp;nbsp;0.2以下 0.1.x以上(包括0.1.x)&lt;br/&gt;~&amp;gt; 0.1 &amp;nbsp;1以下 0.1以上(包括0.1)&lt;/p&gt;&lt;p&gt;pod &amp;#39;AFNetworking&amp;#39;, &amp;#39;~&amp;gt; 1.0&amp;#39; 版本号可以是1.0，可以是1.1，1.9，但必须小于2&lt;/p&gt;&lt;h5&gt;不带~&amp;gt; 是指定固定的版本号&lt;/h5&gt;&lt;p&gt;pod &amp;#39;AFNetworking&amp;#39;, &amp;#39;1.0&amp;#39; // 版本号指定为1.0&lt;/p&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;作者：ChancePro&lt;br/&gt;链接：https://www.jianshu.com/p/68e6f6deaf98&lt;br/&gt;来源：简书&lt;br/&gt;著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Wed, 11 Dec 2019 14:43:21 +0800</pubDate></item><item><title>ffmpeg常用基本命令</title><link>https://suwenclub.cn/?id=19</link><description>&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;1.分离视频音频流&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;input_file&amp;nbsp;-vcodec&amp;nbsp;copy&amp;nbsp;-an&amp;nbsp;output_file_video　　//分离视频流
ffmpeg&amp;nbsp;-i&amp;nbsp;input_file&amp;nbsp;-acodec&amp;nbsp;copy&amp;nbsp;-vn&amp;nbsp;output_file_audio　　//分离音频流&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;2.视频解复用&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–i&amp;nbsp;test.mp4&amp;nbsp;–vcodec&amp;nbsp;copy&amp;nbsp;–an&amp;nbsp;–f&amp;nbsp;m4v&amp;nbsp;test.264ffmpeg&amp;nbsp;–i&amp;nbsp;test.avi&amp;nbsp;–vcodec&amp;nbsp;copy&amp;nbsp;–an&amp;nbsp;–f&amp;nbsp;m4v&amp;nbsp;test.264&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;3.视频转码&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–i&amp;nbsp;test.mp4&amp;nbsp;–vcodec&amp;nbsp;h264&amp;nbsp;–s&amp;nbsp;352*278&amp;nbsp;–an&amp;nbsp;–f&amp;nbsp;m4v&amp;nbsp;test.264&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//转码为码流原始文件
ffmpeg&amp;nbsp;–i&amp;nbsp;test.mp4&amp;nbsp;–vcodec&amp;nbsp;h264&amp;nbsp;–bf&amp;nbsp;0&amp;nbsp;–g&amp;nbsp;25&amp;nbsp;–s&amp;nbsp;352*278&amp;nbsp;–an&amp;nbsp;–f&amp;nbsp;m4v&amp;nbsp;test.264&amp;nbsp;&amp;nbsp;//转码为码流原始文件
ffmpeg&amp;nbsp;–i&amp;nbsp;test.avi&amp;nbsp;-vcodec&amp;nbsp;mpeg4&amp;nbsp;–vtag&amp;nbsp;xvid&amp;nbsp;–qsame&amp;nbsp;test_xvid.avi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//转码为封装文件//-bf&amp;nbsp;B帧数目控制，-g&amp;nbsp;关键帧间隔控制，-s&amp;nbsp;分辨率控制&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;4.视频封装&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–i&amp;nbsp;video_file&amp;nbsp;–i&amp;nbsp;audio_file&amp;nbsp;–vcodec&amp;nbsp;copy&amp;nbsp;–acodec&amp;nbsp;copy&amp;nbsp;output_file&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;5.视频剪切&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–i&amp;nbsp;test.avi&amp;nbsp;–r&amp;nbsp;1&amp;nbsp;–f&amp;nbsp;image2&amp;nbsp;image-%3d.jpeg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//提取图片
ffmpeg&amp;nbsp;-ss&amp;nbsp;0:1:30&amp;nbsp;-t&amp;nbsp;0:0:20&amp;nbsp;-i&amp;nbsp;input.avi&amp;nbsp;-vcodec&amp;nbsp;copy&amp;nbsp;-acodec&amp;nbsp;copy&amp;nbsp;output.avi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//剪切视频//-r&amp;nbsp;提取图像的频率，-ss&amp;nbsp;开始时间，-t&amp;nbsp;持续时间&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;6.视频录制&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–i&amp;nbsp;rtsp://192.168.3.205:5555/test&amp;nbsp;–vcodec&amp;nbsp;copy&amp;nbsp;out.avi&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;7.YUV序列播放&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffplay&amp;nbsp;-f&amp;nbsp;rawvideo&amp;nbsp;-video_size&amp;nbsp;1920x1080&amp;nbsp;input.yuv&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;8.YUV序列转AVI&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;box-sizing: border-box; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); padding: 5px; overflow: auto; margin: 5px 0px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important; font-size: 12px !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;ffmpeg&amp;nbsp;–s&amp;nbsp;w*h&amp;nbsp;–pix_fmt&amp;nbsp;yuv420p&amp;nbsp;–i&amp;nbsp;input.yuv&amp;nbsp;–vcodec&amp;nbsp;mpeg4&amp;nbsp;output.avi&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;常用参数说明：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;主要参数：&lt;/strong&gt;&amp;nbsp;-i 设定输入流 -f 设定输出格式 -ss 开始时间&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;视频参数：&lt;/strong&gt;&amp;nbsp;-b 设定视频流量，默认为200Kbit/s -r 设定帧速率，默认为25 -s 设定画面的宽与高 -aspect 设定画面的比例 -vn 不处理视频 -vcodec 设定视频编解码器，未设定时则使用与输入流相同的编解码器&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;音频参数：&lt;/strong&gt;&amp;nbsp;-ar 设定采样率 -ac 设定声音的Channel数 -acodec 设定声音编解码器，未设定时则使用与输入流相同的编解码器 -an 不处理音频&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;----------------------------------------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;0.压缩转码mp4文件&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -i input.avi -s 640x480 output.avi&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -i input.avi -strict -2 -s vga output.avi&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;1、将文件当做直播送至live&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-re&amp;nbsp;-i&amp;nbsp;localFile.mp4&amp;nbsp;-c&amp;nbsp;copy&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;rtmp://server/live/streamName&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;2、将直播媒体保存至本地文件&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;rtmp://server/live/streamName&amp;nbsp;-c&amp;nbsp;copy&amp;nbsp;dump.flv&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;3、将其中一个直播流，视频改用h264压缩，音频不变，送至另外一个直播服务流&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;rtmp://server/live/originalStream&amp;nbsp;-c:a&amp;nbsp;copy&amp;nbsp;-c:v&amp;nbsp;libx264&amp;nbsp;-vpre&amp;nbsp;slow&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;rtmp://server/live/h264Stream&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;4、将其中一个直播流，视频改用h264压缩，音频改用faac压缩，送至另外一个直播服务流&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;rtmp://server/live/originalStream&amp;nbsp;-c:a&amp;nbsp;libfaac&amp;nbsp;-ar&amp;nbsp;44100&amp;nbsp;-ab&amp;nbsp;48k&amp;nbsp;-c:v&amp;nbsp;libx264&amp;nbsp;-vpre&amp;nbsp;slow&amp;nbsp;-vpre&amp;nbsp;baseline&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;rtmp://server/live/h264Stream&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;5、将其中一个直播流，视频不变，音频改用faac压缩，送至另外一个直播服务流&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;rtmp://server/live/originalStream&amp;nbsp;-acodec&amp;nbsp;libfaac&amp;nbsp;-ar&amp;nbsp;44100&amp;nbsp;-ab&amp;nbsp;48k&amp;nbsp;-vcodec&amp;nbsp;copy&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;rtmp://server/live/h264_AAC_Stream&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;6、将一个高清流，复制为几个不同视频清晰度的流重新发布，其中音频不变&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-re&amp;nbsp;-i&amp;nbsp;rtmp://server/live/high_FMLE_stream&amp;nbsp;-acodec&amp;nbsp;copy&amp;nbsp;-vcodec&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;640×360&amp;nbsp;-b&amp;nbsp;500k&amp;nbsp;-vpre&amp;nbsp;medium&amp;nbsp;-vpre&amp;nbsp;baseline&amp;nbsp;rtmp://server/live/baseline_500k&amp;nbsp;-acodec&amp;nbsp;copy&amp;nbsp;-vcodec&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;480×272&amp;nbsp;-b&amp;nbsp;300k&amp;nbsp;-vpre&amp;nbsp;medium&amp;nbsp;-vpre&amp;nbsp;baseline&amp;nbsp;rtmp://server/live/baseline_300k&amp;nbsp;-acodec&amp;nbsp;copy&amp;nbsp;-vcodec&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;320×200&amp;nbsp;-b&amp;nbsp;150k&amp;nbsp;-vpre&amp;nbsp;medium&amp;nbsp;-vpre&amp;nbsp;baseline&amp;nbsp;rtmp://server/live/baseline_150k&amp;nbsp;-acodec&amp;nbsp;libfaac&amp;nbsp;-vn&amp;nbsp;-ab&amp;nbsp;48k&amp;nbsp;rtmp://server/live/audio_only_AAC_48k&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;7、功能一样，只是采用-x264opts选项&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-re&amp;nbsp;-i&amp;nbsp;rtmp://server/live/high_FMLE_stream&amp;nbsp;-c:a&amp;nbsp;copy&amp;nbsp;-c:v&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;640×360&amp;nbsp;-x264opts&amp;nbsp;bitrate=500:profile=baseline:preset=slow&amp;nbsp;rtmp://server/live/baseline_500k&amp;nbsp;-c:a&amp;nbsp;copy&amp;nbsp;-c:v&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;480×272&amp;nbsp;-x264opts&amp;nbsp;bitrate=300:profile=baseline:preset=slow&amp;nbsp;rtmp://server/live/baseline_300k&amp;nbsp;-c:a&amp;nbsp;copy&amp;nbsp;-c:v&amp;nbsp;x264lib&amp;nbsp;-s&amp;nbsp;320×200&amp;nbsp;-x264opts&amp;nbsp;bitrate=150:profile=baseline:preset=slow&amp;nbsp;rtmp://server/live/baseline_150k&amp;nbsp;-c:a&amp;nbsp;libfaac&amp;nbsp;-vn&amp;nbsp;-b:a&amp;nbsp;48k&amp;nbsp;rtmp://server/live/audio_only_AAC_48k&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;8、将当前&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;摄像头&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;及音频通过DSSHOW&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;采集&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;，视频h264、音频faac压缩后发布&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-r&amp;nbsp;25&amp;nbsp;-f&amp;nbsp;dshow&amp;nbsp;-s&amp;nbsp;640×480&amp;nbsp;-i&amp;nbsp;video=”video&amp;nbsp;source&amp;nbsp;name”:audio=”audio&amp;nbsp;source&amp;nbsp;name”&amp;nbsp;-vcodec&amp;nbsp;libx264&amp;nbsp;-b&amp;nbsp;600k&amp;nbsp;-vpre&amp;nbsp;slow&amp;nbsp;-acodec&amp;nbsp;libfaac&amp;nbsp;-ab&amp;nbsp;128k&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;rtmp://server/application/stream_name&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;9、将一个JPG&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;图片&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;经过h264压缩循环输出为mp4视频&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg.exe&amp;nbsp;-i&amp;nbsp;INPUT.jpg&amp;nbsp;-an&amp;nbsp;-vcodec&amp;nbsp;libx264&amp;nbsp;-coder&amp;nbsp;1&amp;nbsp;-flags&amp;nbsp;+loop&amp;nbsp;-cmp&amp;nbsp;+chroma&amp;nbsp;-subq&amp;nbsp;10&amp;nbsp;-qcomp&amp;nbsp;0.6&amp;nbsp;-qmin&amp;nbsp;10&amp;nbsp;-qmax&amp;nbsp;51&amp;nbsp;-qdiff&amp;nbsp;4&amp;nbsp;-flags2&amp;nbsp;+dct8x8&amp;nbsp;-trellis&amp;nbsp;2&amp;nbsp;-partitions&amp;nbsp;+parti8x8+parti4x4&amp;nbsp;-crf&amp;nbsp;24&amp;nbsp;-threads&amp;nbsp;0&amp;nbsp;-r&amp;nbsp;25&amp;nbsp;-g&amp;nbsp;25&amp;nbsp;-y&amp;nbsp;OUTPUT.mp4&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #444444; line-height: 22.39px; font-family: Verdanna, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span class=&quot;t_tag&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; line-height: 22.39px;&quot;&gt;10、将普通流视频改用h264压缩，音频不变，送至高清流服务(新版本FMS live=1)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre name=&quot;code&quot; class=&quot;plain&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; color: rgb(75, 75, 75); font-size: 13px; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg&amp;nbsp;-i&amp;nbsp;rtmp://server/live/originalStream&amp;nbsp;-c:a&amp;nbsp;copy&amp;nbsp;-c:v&amp;nbsp;libx264&amp;nbsp;-vpre&amp;nbsp;slow&amp;nbsp;-f&amp;nbsp;flv&amp;nbsp;“rtmp://server/live/h264Stream&amp;nbsp;live=1〃&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;----------------------------------------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;------------------------------------------------------------------------&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;1.采集usb摄像头视频命令：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -t 20 -f vfwcap -i 0 -r 8 -f mp4 cap1111.mp4&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;./ffmpeg -t 10 -f vfwcap -i 0 -r 8 -f mp4 cap.mp4&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;box-sizing: border-box; color: #339966;&quot;&gt;具体说明如下：我们采集10秒，采集设备为vfwcap类型设备，第0个vfwcap采集设备（如果系统有多个vfw的视频采集设备，可以通过-i num来选择），每秒8帧，输出方式为文件，格式为mp4。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;2.最简单的抓屏：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -f gdigrab -i desktop out.mpg&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;3.从屏幕的（10,20）点处开始，抓取640x480的屏幕，设定帧率为5 ：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -f gdigrab -framerate 5 -offset_x 10 -offset_y 20 -video_size 640x480 -i desktop out.mpg&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;4.ffmpeg从视频中生成gif图片：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;ffmpeg -i capx.mp4 -t 10 -s 320x240 -pix_fmt rgb24 jidu1.gif&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;5.ffmpeg将图片转换为视频：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px auto; color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;a href=&quot;http://blog.sina.com.cn/s/blog_40d73279010113c2.html&quot; style=&quot;box-sizing: border-box; color: rgb(52, 104, 164);&quot;&gt;http://blog.sina.com.cn/s/blog_40d73279010113c2.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Wed, 11 Dec 2019 13:43:46 +0800</pubDate></item><item><title>Xcode11 打包IPA上传App Store失败解决办法 xcrun altool密钥上传</title><link>https://suwenclub.cn/?id=18</link><description>&lt;div&gt;&lt;div&gt;&lt;h4&gt;缘由&lt;/h4&gt;&lt;p&gt;Xcode更新11之后，不再包含&lt;code&gt;Application Loader&lt;/code&gt;。听说为了更好的支持ipadOS、macOS、iOS统一管理，推荐使用&lt;code&gt;xcodebuild&lt;/code&gt; 或 &lt;code&gt;xcrun altool&lt;/code&gt;从&lt;code&gt;Organizer&lt;/code&gt;或命令行上传应用程序。详情见Xcode更新日志(29008875)说明。&lt;/p&gt;&lt;p&gt;本人在更新Xcode11之后使用&lt;code&gt;Organizer&lt;/code&gt;上传应用一直出现失败，于是改用&lt;code&gt;xcrun altool&lt;/code&gt;进行验证和上传应用，用了之后发现 ~真香。。。&lt;/p&gt;&lt;h4&gt;如何使用&lt;code&gt;xcrun altool&lt;/code&gt;&lt;/h4&gt;&lt;p&gt;废话不多说，&lt;code&gt;xcrun altool&lt;/code&gt;之前可以使用开发者账号和密码进行-登录-验证-上传。但听说不行了，现在需要用密钥的方式，用到的2个命令如下：&lt;/p&gt;&lt;p&gt;验证: &lt;code&gt;xcrun altool --validate-app -f xxx.ipa -t ios --apiKey xxx --apiIssuer xxx --verbose&lt;/code&gt;&lt;/p&gt;&lt;p&gt;上传: &lt;code&gt;xcrun altool --upload-app -f xxx.ipa -t ios --apiKey xxx --apiIssuer xxx --verbose&lt;/code&gt;&lt;/p&gt;&lt;p&gt;2个命令分别对应 验证IPA 和 上传IPA，都需要使用3个参数&lt;code&gt;ipa路径&lt;/code&gt;、&lt;code&gt;apiKey&lt;/code&gt;、&lt;code&gt;apiIssuer&lt;/code&gt;&lt;/p&gt;&lt;h6&gt;一：路径不用说了，可以使用&lt;code&gt;xcodebuild&lt;/code&gt;打包或用&lt;code&gt;Organizer&lt;/code&gt;Export导出App store包。&lt;/h6&gt;&lt;h6&gt;二：&lt;code&gt;apiKey&lt;/code&gt;和&lt;code&gt;apiIssuer&lt;/code&gt;需要去开发者官网-用户和访问-密钥-去新增。如下图流程&lt;/h6&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;选择密钥&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;div class=&quot;image-package&quot;&gt;&lt;div class=&quot;image-container&quot; style=&quot;max-width: 464px; max-height: 103px;&quot;&gt;&lt;div class=&quot;image-container-fill&quot; style=&quot;padding-bottom: 22.2%;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;image-view&quot; data-width=&quot;464&quot; data-height=&quot;103&quot;&gt;&lt;img data-original-src=&quot;//upload-images.jianshu.io/upload_images/1176193-bb0898342e0a09d6.png&quot; data-original-width=&quot;464&quot; data-original-height=&quot;103&quot; data-original-format=&quot;image/png&quot; data-original-filesize=&quot;8572&quot; data-image-index=&quot;0&quot; style=&quot;cursor: zoom-in;&quot; class=&quot;&quot; src=&quot;//upload-images.jianshu.io/upload_images/1176193-bb0898342e0a09d6.png?imageMogr2/auto-orient/strip|imageView2/2/w/464/format/webp&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;image-caption&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;新增一个密钥，名称和访问者可以自由填写&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;div class=&quot;image-package&quot;&gt;&lt;div class=&quot;image-container&quot; style=&quot;max-width: 605px; max-height: 323px;&quot;&gt;&lt;div class=&quot;image-container-fill&quot; style=&quot;padding-bottom: 53.39%;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;image-view&quot; data-width=&quot;605&quot; data-height=&quot;323&quot;&gt;&lt;img data-original-src=&quot;//upload-images.jianshu.io/upload_images/1176193-21f2f50741fb66c2.png&quot; data-original-width=&quot;605&quot; data-original-height=&quot;323&quot; data-original-format=&quot;image/png&quot; data-original-filesize=&quot;17016&quot; data-image-index=&quot;1&quot; style=&quot;cursor: zoom-in;&quot; class=&quot;&quot; src=&quot;//upload-images.jianshu.io/upload_images/1176193-21f2f50741fb66c2.png?imageMogr2/auto-orient/strip|imageView2/2/w/605/format/webp&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;image-caption&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;生成完成后，IssuerID就是&lt;code&gt;apiIssuer&lt;/code&gt;，密钥ID就是&lt;code&gt;apiKey&lt;/code&gt;，并且还有一个API密钥可以下载(&lt;img class=&quot;math-inline&quot; src=&quot;https://math.jianshu.com/math?formula=%5Ccolor%7Bred%7D%7B%E6%B3%A8%E6%84%8F%EF%BC%9A%E6%AD%A4%E5%AF%86%E9%92%A5%E6%96%87%E4%BB%B6%E5%8F%AA%E8%83%BD%E4%B8%8B%E8%BD%BD%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%A6%A5%E5%96%84%E4%BF%9D%E5%AD%98%7D&quot; alt=&quot;\color{red}{注意：此密钥文件只能下载一次，妥善保存}&quot; mathimg=&quot;1&quot;/&gt;)&lt;br/&gt;&lt;/p&gt;&lt;div class=&quot;image-package&quot;&gt;&lt;div class=&quot;image-container&quot; style=&quot;max-width: 700px; max-height: 369px;&quot;&gt;&lt;div class=&quot;image-container-fill&quot; style=&quot;padding-bottom: 19.5%;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;image-view&quot; data-width=&quot;1892&quot; data-height=&quot;369&quot;&gt;&lt;img data-original-src=&quot;//upload-images.jianshu.io/upload_images/1176193-47275c42aafaed6a.png&quot; data-original-width=&quot;1892&quot; data-original-height=&quot;369&quot; data-original-format=&quot;image/png&quot; data-original-filesize=&quot;58512&quot; data-image-index=&quot;2&quot; style=&quot;cursor: zoom-in;&quot; class=&quot;&quot; src=&quot;//upload-images.jianshu.io/upload_images/1176193-47275c42aafaed6a.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;image-caption&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h6&gt;三：到这一步先别急执行命令，执行了也会出错，按照&lt;code&gt;xcrun altool&lt;/code&gt;官方文档说明&lt;/h6&gt;&lt;div class=&quot;_2Uzcx_&quot;&gt;&lt;button class=&quot;VJbwyy&quot; type=&quot;button&quot; aria-label=&quot;复制代码&quot;&gt;&lt;em aria-label=&quot;icon: copy&quot; class=&quot;anticon anticon-copy&quot;&gt;&lt;svg viewbox=&quot;64 64 896 896&quot; focusable=&quot;false&quot; class=&quot;&quot; data-icon=&quot;copy&quot; width=&quot;1em&quot; height=&quot;1em&quot; fill=&quot;currentColor&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/em&gt;&lt;/button&gt;&lt;pre class=&quot;line-numbers  language-csharp&quot;&gt;apiKey.&amp;nbsp;Required&amp;nbsp;for&amp;nbsp;JWT&amp;nbsp;authentication&amp;nbsp;while&amp;nbsp;using&amp;nbsp;validation,&amp;nbsp;upload,&amp;nbsp;and&amp;nbsp;notarization.This&amp;nbsp;option&amp;nbsp;will&amp;nbsp;search&amp;nbsp;the&amp;nbsp;following&amp;nbsp;directories&amp;nbsp;in&amp;nbsp;sequence&amp;nbsp;for&amp;nbsp;a&amp;nbsp;private&amp;nbsp;key&amp;nbsp;file
with&amp;nbsp;the&amp;nbsp;name&amp;nbsp;of&amp;nbsp;&amp;#39;AuthKey_&amp;lt;api_key&amp;gt;.p8&amp;#39;:&amp;nbsp;&amp;nbsp;&amp;#39;./private_keys&amp;#39;,&amp;nbsp;&amp;#39;~/private_keys&amp;#39;,&amp;nbsp;&amp;#39;~/.private_keys&amp;#39;,and&amp;nbsp;&amp;#39;~/.appstoreconnect/private_keys&amp;#39;.&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;我们需要把刚才下载好的密钥文件放到这里面的其中一个文件夹里，它会按顺序去查找。我自己是在用户目录下&lt;code&gt;/Users/payne/private_keys&lt;/code&gt;新建了个private_keys文件夹，并把密钥文件放进去的。&lt;/p&gt;&lt;h6&gt;四：接下来把参数替换上去，可以尝试进行验证和上传了。&lt;/h6&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;div class=&quot;image-package&quot;&gt;&lt;div class=&quot;image-container&quot; style=&quot;max-width: 700px; max-height: 556px;&quot;&gt;&lt;div class=&quot;image-container-fill&quot; style=&quot;padding-bottom: 79.3%;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;image-view&quot; data-width=&quot;1140&quot; data-height=&quot;904&quot;&gt;&lt;img data-original-src=&quot;//upload-images.jianshu.io/upload_images/1176193-4187bd1822389829.png&quot; data-original-width=&quot;1140&quot; data-original-height=&quot;904&quot; data-original-format=&quot;image/png&quot; data-original-filesize=&quot;1292236&quot; data-image-index=&quot;3&quot; style=&quot;cursor: zoom-in;&quot; class=&quot;&quot; src=&quot;//upload-images.jianshu.io/upload_images/1176193-4187bd1822389829.png?imageMogr2/auto-orient/strip|imageView2/2/w/1140/format/webp&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;image-caption&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;br/&gt;等到提示&lt;code&gt;No errors uploading&lt;/code&gt;时就代表上传成功了，可以去开发者中心-活动里面查看一下是否有构建版本&lt;br/&gt;&lt;div class=&quot;image-package&quot;&gt;&lt;div class=&quot;image-container&quot; style=&quot;max-width: 700px; max-height: 524px;&quot;&gt;&lt;div class=&quot;image-container-fill&quot; style=&quot;padding-bottom: 44.330000000000005%;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;image-view&quot; data-width=&quot;1182&quot; data-height=&quot;524&quot;&gt;&lt;img data-original-src=&quot;//upload-images.jianshu.io/upload_images/1176193-1a474a75b23edb36.png&quot; data-original-width=&quot;1182&quot; data-original-height=&quot;524&quot; data-original-format=&quot;image/png&quot; data-original-filesize=&quot;56648&quot; data-image-index=&quot;4&quot; style=&quot;cursor: zoom-in;&quot; class=&quot;&quot; src=&quot;//upload-images.jianshu.io/upload_images/1176193-1a474a75b23edb36.png?imageMogr2/auto-orient/strip|imageView2/2/w/1182/format/webp&quot;/&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;image-caption&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;h6&gt;五：OK，已经有了，到这里就大功告成了。是不是真香。。。&lt;/h6&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;作者：老坛泡菜&lt;br/&gt;链接：https://www.jianshu.com/p/52a1b9a42afa&lt;br/&gt;来源：简书&lt;br/&gt;著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sun, 08 Dec 2019 22:09:20 +0800</pubDate></item><item><title>iOS多线程编程：线程同步总结</title><link>https://suwenclub.cn/?id=17</link><description>&lt;p&gt;1：原子操作 - OSAtomic系列函数&lt;br/&gt;&lt;/p&gt;&lt;p&gt;iOS平台下的原子操作函数都以OSAtomic开头，使用时需要包含头文件&amp;lt;libkern/OSBase.h&amp;gt;。不同线程如果通过原子操作函数对同一变量进行操作，可以保证一个线程的操作不会影响到其他线程内对此变量的操作，因为这些操作都是原子式的。因为原子操作只能对内置类型进行操作，所以原子操作能够同步的线程只能位于同一个进程的地址空间内。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;2：锁 - NSLock系列对象&lt;/p&gt;&lt;p&gt;iOS平台下的锁对象为NSLock对象，进入锁通过调用lock函数，解锁调用unlock函数（因为iOS中大部分的线程同步类都继承自NSLocking协议，所以其加锁/解锁的操作基本都为lock/unlock函数），同一个NSLock对象成功调用lock函数后，在其显式unlock之前任何线程都不能再对此NSLock对象加锁，以达到互斥访问的目的。除了lock函数，对NSLock加锁的函数还包括tryLock以及lockBeforeDate函数，lock函数在成功加锁之间会一直阻塞，而tryLock会尝试加锁，如果不成功，不会阻塞，而是直接返回NO，lockBeforeDate则是阻塞到传入的NSDate日期为止。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;除了NSLock，iOS还提供了NSRecursive、NSConditionLock类型的锁类型。NSRecursive与NSLock最大的区别就是NSRecursive是可重入的，也就是说一个线程可以对一个NSRecursive对象多次调用lock，只要解锁时调用相同次数的unlock函数便可。NSConditionLock是一种带有条件的锁对象，除了基本的lock与unlock函数，还提供了lockWithCondition以及unlockWithCondition，这两个函数接收整型类型的数据作为参数，只有当一个unlockWithCondition对象被调用时，对应的lockWithCondition才会正常返回。这种机制在需几多个线程顺序化的完成某个任务时比较有用，例程如下：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;//线程A&lt;/p&gt;&lt;p&gt;id condLock = [[NSConditionLock alloc] initWithCondition:NO_DATA];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;while(true)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; [condLock lock];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /* Add data to the queue. */&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; [condLock unlockWithCondition:HAS_DATA];&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;//线程B&lt;/p&gt;&lt;p&gt;while (true)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; [condLock lockWhenCondition:HAS_DATA];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /* Remove data from the queue. */&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; [condLock unlockWithCondition:(isEmpty ? NO_DATA : HAS_DATA)];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; // Process the data locally.&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;除了显示的生成NSLock系列对象，还可以通过将代码放到@synchronized内来达到同步的目的，一段放入其内的代码，不同的线程是不能重入的例如：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;- (void)myMethod:(id)anObj&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; @synchronized(anObj)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //此处代码在同一时刻只能有一个线程执行.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;NSLock系列对象都是可以具名的，也就是说，这些对象可以用于不同进程内部的线程的同步。&lt;/p&gt;&lt;p&gt;3：事件 - NSCondtion&lt;/p&gt;&lt;p&gt;NSConditon类型提供了wait与signal函数，分别代表了等待事件的操作以及触发事件的操作。除了wait函数，NSCondition还提供了waitUntilDate函数，其功能与NSLock中的lockBeforeDate大致相同，简要来说就是提供了一个带超时的wait函数。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;虽然NSCondition与Windows环境下Event类型所完成的功能大致类似，但对一个熟悉Event类型的开发人员来说，NSConditon的行为会有点奇怪：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;第一点：因为遵循NSLocking协议，所以NSCondition在触发与等待过程的前后要分别调用lock与unlock函数，前面提到过，当一个遵循NSLocking协议的对象调用lock后，其他的对此对象的lock调用都会阻塞。那么，如果两个线程A和B，A要触发事件，B接收事件，B线程在调用lock后，通过调用wait函数进入等待事件触发的状态，那么，A线程岂不是再也没有机会对这个事件进行触发了（因为此对象已经被B线程lock）？秘密就在于wait函数的调用，其实，在wait函数内部悄悄的调用了unlock函数，也就是说在调用wati函数后，这个NSCondition对象就处于了无锁的状态，这样A线程就可以对此对象加锁并触发该NSCondition对象。当一个事件被其他线程触发时，在wait函数内部得到此事件被触发的通知，然后对此事件重新调用lock函数，然后函数返回，而在函数外部，看起来好像接收事件的线程从来没有放开NSCondition对象的所有权，B线程直接由阻塞状态进入了触发状态。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;第二点：当有多个线程进入阻塞状态，等待同一个AutoReset的Event对象被触发时，在Windows环境下唤醒哪一个线程是没有固定的顺序的，也就是说操作系统对唤醒哪一个线程不会提供任何的保证。而在iOS平台上，经过笔者测试，其被触发的顺序与，并且只与调用wait函数的顺序相关，与其他（比如线程优先级）条件没有关系。这一点在开发时需要进行额外的考虑。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;第三点：wait函数并不是完全可信的。这一点比较让人蛋疼，也就是说wait返回后，并不代表对应的事件一定被触发了，因此，为了保证线程之间的同步关系，使用NSCondtion时往往需要加入一个额外的变量来对非正常的wait返回进行规避。具体示例代码如下：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;//等待事件触发的线程&lt;/p&gt;&lt;p&gt;[cocoaCondition lock];&lt;/p&gt;&lt;p&gt;while (timeToDoWork &amp;lt;= 0)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; [cocoaCondition wait];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;timeToDoWork--;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;// Do real work here.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;[cocoaCondition unlock];&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;//出发事件的线程&lt;/p&gt;&lt;p&gt;[cocoaCondition lock];&lt;/p&gt;&lt;p&gt;timeToDoWork++;&lt;/p&gt;&lt;p&gt;[cocoaCondition signal];&lt;/p&gt;&lt;p&gt;[cocoaCondition unlock];&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;这个timeToDoWork就是那个额外需要的变量，在NSCondition的使用中，这个变量是必不可少的。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;NSConditon对象也是具名的，也就是说，其可于不同进程内部的线程同步。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;相较于Windows平台下提供的丰富的线程同步机制，iOS下的线程同步机制稍显单薄，但也正是这种简洁简化了其使用。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;参考：iOS Developer Liabray&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;示例代码来源：Thread Programming Guide&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;注：文中所指的线程同步泛指多线程环境下的同步与互斥。&lt;/p&gt;&lt;p&gt;————————————————&lt;/p&gt;&lt;p&gt;版权声明：本文为CSDN博主「lifengzhong」的原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接及本声明。&lt;/p&gt;&lt;p&gt;原文链接：https://blog.csdn.net/lifengzhong/article/details/7487505&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sun, 08 Dec 2019 10:06:56 +0800</pubDate></item><item><title>Optimizing Images</title><link>https://suwenclub.cn/?id=16</link><description>&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;They say the best camera is the one you have with you. If that adage holds any weight, then without question - stem to stern the iPhone is the most important camera on the planet. And our industry shows it, too.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;On a vacation? It didn’t happen if it’s not documented on your Instagram story with several candid shots.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Breaking news? Check Twitter and see what outlets are reporting on by peeping their photos of an event unfolding in real time.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Etcetera.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;But for all of their ubiquity on the platform, the act of showing them in a performant and memory conservative manner can easily turn into a mismanaged endeavor. With a little know how as to what’s happening in UIKit and why in regards to how it treats images, one can gain some massive savings and forgo the unrelenting wrath of jetsam.&lt;/p&gt;&lt;h3 id=&quot;in-theory&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;In Theory&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Pop quiz - how much memory will this 266 kilobyte (and quite dashing) photo of my beautiful daughter require in an iOS app?&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;https://www.swiftjectivec.com/assets/images/baylor.jpg&quot; alt=&quot;Baylor&quot; style=&quot;box-sizing: border-box; max-width: 100%; height: auto; display: block; margin: 32px auto; border-radius: 25px;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Spoiler alert - it’s not 266 kilobytes. It’s not 2.66 megabytes. It’s around&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;14 megabytes&lt;/em&gt;.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Why?&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;iOS essentially derives its memory hit from an image’s&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;dimensions&lt;/em&gt;&amp;nbsp;- whereas the actual file size has much less to do with it. And the dimensions for this photo sit at 1718 pixels wide by 2048 pixels tall. Assuming each pixel will cost us four bytes:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;1718&amp;nbsp;*&amp;nbsp;2048&amp;nbsp;*&amp;nbsp;4&amp;nbsp;/&amp;nbsp;1024&amp;nbsp;/&amp;nbsp;1024&amp;nbsp;=&amp;nbsp;13.42&amp;nbsp;megabytes&amp;nbsp;give&amp;nbsp;or&amp;nbsp;take&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Imagine if you’ve got a table view with a list of users, and each row shows the now pervasive circle avatar of their photo to the left. If you’re thinking things are kosher because each one has been packed up nice and tight from ImageOptim or something similar, that might not be the case. If each one is a conservative 256x256 you could still be taking quite a hit on memory.&lt;/p&gt;&lt;h3 id=&quot;the-rendering-pipeline&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The Rendering Pipeline&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;All that to say - it’s worth knowing what’s going on under the hood. When you load up an image, it’s going to be processed in three steps:&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;1)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Load&lt;/strong&gt;&amp;nbsp;- iOS takes the compressed image and loads (in our example) the 266 kilobyte into memory. Really no worries yet.&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;2)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Decode&lt;/strong&gt;&amp;nbsp;- Now, iOS takes the image and converts into a way the GPU can read and understand. It’s now uncompressed, and it’s here we’re at the 14MB size listed above.&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;3)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Render&lt;/strong&gt;&amp;nbsp;- Just like it sounds, the image data is ready and willing to be rendered any which way. Even if it’s just by a 60 by 60 point image view.&lt;br style=&quot;box-sizing: border-box;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The decoding phase is the big one. Here, iOS has created a buffer - specifically an image buffer, that’s got an in-memory representation of the image. So it stands to reason that this size is intrinsically tied to the proportions of the image itself and not its file size. This paints a clear picture of why the dimensions are so important when it comes to your memory consumption when working with images.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;For&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;in particular, when we give it image data we received from a network hit or some other source, it decodes that data buffer to whatever compression the data says it’s encoded in (think PNG or JPEG). However, it’ll actually hang onto it as well. Since rendering is not a one shot operation, the&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;keeps that image buffer around so it’s only decoding things one time.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Expanding on this idea - one integral buffer for any iOS app is its frame buffer. This is what’s responsible for actually showing your iOS app as it appears on screen since it holds the rendered output of its contents. The display hardware on any iOS device uses this per-pixel information to literally illuminate the very pixels on the physical screen.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;And timing matters here. To get the buttery smooth 60 frames per second scrolling, the frame buffer will need to have UIKit render the app’s window and it’s subsequent subviews into it when their information changes (i.e. assigning an image to an image view). If you do that slow, you drop a frame.&lt;/p&gt;&lt;blockquote style=&quot;box-sizing: border-box; border-left: 6px solid rgb(97, 91, 91); padding: 0.5em 10px; color: rgb(97, 91, 91); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p style=&quot;box-sizing: border-box; display: inline; font-style: italic; margin-top: 8px;&quot;&gt;Think 1/60th of a second is short on time? Pro Motion devices up the ante to 1/120th of a second.&lt;/p&gt;&lt;/blockquote&gt;&lt;h3 id=&quot;size-does-matter&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Size Does Matter&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;We can visualize this process and memory being consumed pretty easily. Using the picture of my daughter, I created a trivial app that shows an image view with that exact image within it:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;let&amp;nbsp;filePath&amp;nbsp;=&amp;nbsp;Bundle.main.path(forResource:&amp;quot;baylor&amp;quot;,&amp;nbsp;ofType:&amp;nbsp;&amp;quot;jpg&amp;quot;)!let&amp;nbsp;url&amp;nbsp;=&amp;nbsp;NSURL(fileURLWithPath:&amp;nbsp;filePath)let&amp;nbsp;fileImage&amp;nbsp;=&amp;nbsp;UIImage(contentsOfFile:&amp;nbsp;filePath)//&amp;nbsp;Image&amp;nbsp;viewlet&amp;nbsp;imageView&amp;nbsp;=&amp;nbsp;UIImageView(image:&amp;nbsp;fileImage)imageView.translatesAutoresizingMaskIntoConstraints&amp;nbsp;=&amp;nbsp;falseimageView.contentMode&amp;nbsp;=&amp;nbsp;.scaleAspectFitimageView.widthAnchor.constraint(equalToConstant:&amp;nbsp;300).isActive&amp;nbsp;=&amp;nbsp;trueimageView.heightAnchor.constraint(equalToConstant:&amp;nbsp;400).isActive&amp;nbsp;=&amp;nbsp;trueview.addSubview(imageView)imageView.centerXAnchor.constraint(equalTo:&amp;nbsp;view.centerXAnchor).isActive&amp;nbsp;=&amp;nbsp;trueimageView.centerYAnchor.constraint(equalTo:&amp;nbsp;view.centerYAnchor).isActive&amp;nbsp;=&amp;nbsp;true&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote style=&quot;box-sizing: border-box; border-left: 6px solid rgb(97, 91, 91); padding: 0.5em 10px; color: rgb(97, 91, 91); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p style=&quot;box-sizing: border-box; display: inline; font-style: italic; margin-top: 8px;&quot;&gt;Mind the force unwraps in production. Here we’re using a simple example scenario.&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Which gives us this:&lt;img src=&quot;https://www.swiftjectivec.com/assets/images/baylorPhone.jpg&quot; alt=&quot;Baylor&quot; style=&quot;box-sizing: border-box; max-width: 100%; height: auto; display: block; margin: 32px auto; border-radius: 25px;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;A quick trip to LLDB shows us the image dimensions we’re working with, even though we’re using a much smaller image view to display it:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;&amp;lt;UIImage:&amp;nbsp;0x600003d41a40&amp;gt;,&amp;nbsp;{1718,&amp;nbsp;2048}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;A remember - that’s in&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;points&lt;/em&gt;. So if I’m on a 3x or 2x device then you could potentially multiply that number even more so. Let’s take a quick trip down&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;vmmap&lt;/code&gt;&amp;nbsp;to see if we can confirm that around 14 megabytes are being used from this one image:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;vmmap&amp;nbsp;--summary&amp;nbsp;baylor.memgraph&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;A few things stick out (truncated for brevity):&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;Physical&amp;nbsp;footprint:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;69.5MPhysical&amp;nbsp;footprint&amp;nbsp;(peak):&amp;nbsp;&amp;nbsp;69.7M&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;We’re sitting at almost 70 megabytes which gives us a nice baseline to confirm any refactor against. If we grep down into Image IO we can likely see some of the cost of our image as well:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;vmmap&amp;nbsp;--summary&amp;nbsp;baylor.memgraph&amp;nbsp;|&amp;nbsp;grep&amp;nbsp;&amp;quot;Image&amp;nbsp;IO&amp;quot;Image&amp;nbsp;IO&amp;nbsp;&amp;nbsp;13.4M&amp;nbsp;&amp;nbsp;&amp;nbsp;13.4M&amp;nbsp;&amp;nbsp;&amp;nbsp;13.4M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0K&amp;nbsp;&amp;nbsp;0K&amp;nbsp;&amp;nbsp;0K&amp;nbsp;&amp;nbsp;&amp;nbsp;0K&amp;nbsp;&amp;nbsp;2&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Ah - there’s about 14 megabytes of dirty memory right there. That’s what our back-of-the-napkin math hypothesized our image would cost. For context, here’s a quick screenshot of Terminal to clearly illustrate what each column means since they were omitted from our greppin’:&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;https://www.swiftjectivec.com/assets/images/vmmap.jpg&quot; alt=&quot;Baylor&quot; style=&quot;box-sizing: border-box; max-width: 100%; height: auto; display: block; margin: 32px auto; border-radius: 25px;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;So clearly, we’re paying the full cost of the image in our 300 x 400 image view at this point. The size of the image can be key, but it’s also not the only thing that matters.&lt;/p&gt;&lt;h3 id=&quot;color-space&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Color Space&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Part of the memory you’ll be requesting for is determined by yet another important factor - the color space. In the example above we made an assumption that likely isn’t the case with most iPhones - that the image was utilizing the sRGB format. The 4 bytes per pixel is figured up by giving one byte for red, blue, green and the alpha component.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;If you’re shooting with a device that supports the wide color format (for example, an iPhone 8+ or iPhone X) then you likely can double the hit across the board. Of course, the reverse is true as well. Metal can use the Alpha 8 format which has only a single channel to its name.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;It can be a lot to manage and think about. This is one reason why you should use&amp;nbsp;&lt;a href=&quot;https://swiftjectivec.com/UIGraphicsImageRenderer&quot; target=&quot;_blank&quot; style=&quot;box-sizing: border-box; color: rgb(112, 162, 249);&quot;&gt;UIGraphicsImageRenderer&lt;/a&gt;&amp;nbsp;instead of&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIGraphicsBeginImageContextWithOptions&lt;/code&gt;. The latter will&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;always&lt;/em&gt;&amp;nbsp;use sRGB which means you could miss the wide format if you&amp;nbsp;&lt;a href=&quot;https://instagram-engineering.com/bringing-wide-color-to-instagram-5a5481802d7d&quot; target=&quot;_blank&quot; style=&quot;box-sizing: border-box; color: rgb(112, 162, 249);&quot;&gt;want it&lt;/a&gt;, or miss out on the savings if you’re going smaller. As of iOS 12,&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIGraphicsImageRenderer&lt;/code&gt;&amp;nbsp;is going to pick the right one for you.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Lest we forget, a lot of images that crop up aren’t really of the photographed variety but rather trivial drawing operations. Not to rehash what I wrote about recently, but in case you missed it:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;let&amp;nbsp;circleSize&amp;nbsp;=&amp;nbsp;CGSize(width:&amp;nbsp;60,&amp;nbsp;height:&amp;nbsp;60)UIGraphicsBeginImageContextWithOptions(circleSize,&amp;nbsp;true,&amp;nbsp;0)//&amp;nbsp;Draw&amp;nbsp;a&amp;nbsp;circlelet&amp;nbsp;ctx&amp;nbsp;=&amp;nbsp;UIGraphicsGetCurrentContext()!UIColor.red.setFill()ctx.setFillColor(UIColor.red.cgColor)ctx.addEllipse(in:&amp;nbsp;CGRect(x:&amp;nbsp;0,&amp;nbsp;y:&amp;nbsp;0,&amp;nbsp;width:&amp;nbsp;circleSize.width,&amp;nbsp;height:&amp;nbsp;circleSize.height))ctx.drawPath(using:&amp;nbsp;.fill)let&amp;nbsp;circleImage&amp;nbsp;=&amp;nbsp;UIGraphicsGetImageFromCurrentImageContext()UIGraphicsEndImageContext()&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;This circle image above is using a 4 byte per pixel format. If you roll with&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIGraphicsImageRenderer&lt;/code&gt;&amp;nbsp;you can potentially open things up for up to a 75% savings by getting 1 byte per pixel by letting the renderer opt into the correct format automatically:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;let&amp;nbsp;circleSize&amp;nbsp;=&amp;nbsp;CGSize(width:&amp;nbsp;60,&amp;nbsp;height:&amp;nbsp;60)let&amp;nbsp;renderer&amp;nbsp;=&amp;nbsp;UIGraphicsImageRenderer(bounds:&amp;nbsp;CGRect(x:&amp;nbsp;0,&amp;nbsp;y:&amp;nbsp;0,&amp;nbsp;width:&amp;nbsp;circleSize.width,&amp;nbsp;height:&amp;nbsp;circleSize.height))let&amp;nbsp;circleImage&amp;nbsp;=&amp;nbsp;renderer.image{&amp;nbsp;ctx&amp;nbsp;in
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UIColor.red.setFill()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ctx.cgContext.setFillColor(UIColor.red.cgColor)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ctx.cgContext.addEllipse(in:&amp;nbsp;CGRect(x:&amp;nbsp;0,&amp;nbsp;y:&amp;nbsp;0,&amp;nbsp;width:&amp;nbsp;circleSize.width,&amp;nbsp;height:&amp;nbsp;circleSize.height))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ctx.cgContext.drawPath(using:&amp;nbsp;.fill)}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 id=&quot;downscaling-vs-downsampling&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Downscaling vs Downsampling&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Moving past simple drawing scenarios - a lot of the issues with images and their impact on memory originate from the typical photos that we associate with the actual art of photography. Think portraits, landscape shots and more.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;It stands to reason that some engineers might assume (and, logically so) that simply downscaling them via&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;will suffice. But it typically won’t due to the reasons above, and it’s also not as performant due to internal coordinate space transforms according to Apple’s Kyle Howarth.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;becomes an issue here primarily because it will decompress the&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;original image&lt;/em&gt;&amp;nbsp;into memory as we discussed when looking at the rendering pipeline. We need a way to reduce the size of our image buffer, ideally.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Thankfully, it’s possible to resize the images at the cost of the actual resized image only, which is what one might assume is happening already when it typically isn’t.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Let’s try dropping down into a lower level API to downsample it instead:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;let&amp;nbsp;imageSource&amp;nbsp;=&amp;nbsp;CGImageSourceCreateWithURL(url,&amp;nbsp;nil)!let&amp;nbsp;options:&amp;nbsp;[NSString:Any]&amp;nbsp;=&amp;nbsp;[kCGImageSourceThumbnailMaxPixelSize:400,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceCreateThumbnailFromImageAlways:true]if&amp;nbsp;let&amp;nbsp;scaledImage&amp;nbsp;=&amp;nbsp;CGImageSourceCreateThumbnailAtIndex(imageSource,&amp;nbsp;0,&amp;nbsp;options&amp;nbsp;as&amp;nbsp;CFDictionary)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;imageView&amp;nbsp;=&amp;nbsp;UIImageView(image:&amp;nbsp;UIImage(cgImage:&amp;nbsp;scaledImage))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.translatesAutoresizingMaskIntoConstraints&amp;nbsp;=&amp;nbsp;false
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.contentMode&amp;nbsp;=&amp;nbsp;.scaleAspectFit
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.widthAnchor.constraint(equalToConstant:&amp;nbsp;300).isActive&amp;nbsp;=&amp;nbsp;true
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.heightAnchor.constraint(equalToConstant:&amp;nbsp;400).isActive&amp;nbsp;=&amp;nbsp;true
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;view.addSubview(imageView)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.centerXAnchor.constraint(equalTo:&amp;nbsp;view.centerXAnchor).isActive&amp;nbsp;=&amp;nbsp;true
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;imageView.centerYAnchor.constraint(equalTo:&amp;nbsp;view.centerYAnchor).isActive&amp;nbsp;=&amp;nbsp;true}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Display wise, we’ve got the exact same result as before. But here, we’re using&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;CGImageSourceCreateThumbnailAtIndex()&lt;/code&gt;&amp;nbsp;instead of just putting the vanilla image into the image view. The source of truth will lie within&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;vmmap&lt;/code&gt;&amp;nbsp;once more to see if our optimizations have paid off (again, truncated for brevity):&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;vmmap&amp;nbsp;-summary&amp;nbsp;baylorOptimized.memgraphPhysical&amp;nbsp;footprint:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;56.3MPhysical&amp;nbsp;footprint&amp;nbsp;(peak):&amp;nbsp;&amp;nbsp;56.7M&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;And the savings have rolled in. If we compare the 69.5M from before to the 56.3M now we get a savings of 13.2M. That’s a&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;huge&lt;/em&gt;&amp;nbsp;savings, almost the whole cost of the image.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Further, you can play around with the many options available to hone things for your use case. In session 219, “Images and Graphics Best Practices” from WWDC 18, Apple engineer Kyle Sluder showed an interesting way to control when decoding happens by using the&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;kCGImageSourceShouldCacheImmediately&lt;/code&gt;&amp;nbsp;flag:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;func&amp;nbsp;downsampleImage(at&amp;nbsp;URL:NSURL,&amp;nbsp;maxSize:Float)&amp;nbsp;-&amp;gt;&amp;nbsp;UIImage{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;sourceOptions&amp;nbsp;=&amp;nbsp;[kCGImageSourceShouldCache:false]&amp;nbsp;as&amp;nbsp;CFDictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;source&amp;nbsp;=&amp;nbsp;CGImageSourceCreateWithURL(URL&amp;nbsp;as&amp;nbsp;CFURL,&amp;nbsp;sourceOptions)!
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;downsampleOptions&amp;nbsp;=&amp;nbsp;[kCGImageSourceCreateThumbnailFromImageAlways:true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceThumbnailMaxPixelSize:maxSize
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceShouldCacheImmediately:true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;kCGImageSourceCreateThumbnailWithTransform:true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&amp;nbsp;as&amp;nbsp;CFDictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let&amp;nbsp;downsampledImage&amp;nbsp;=&amp;nbsp;CGImageSourceCreateThumbnailAtIndex(source,&amp;nbsp;0,&amp;nbsp;downsampleOptions)!
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;UIImage(cgImage:&amp;nbsp;downsampledImage)}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Here Core Graphics won’t bother decoding the image until you specifically ask for the thumbnail. Also, take care to pass&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;kCGImageSourceCreateThumbnailMaxPixelSize&lt;/code&gt;&amp;nbsp;as we’ve done in both examples because if you don’t - you’re getting back a thumbnail which is the same size of the image. From the docs:&lt;/p&gt;&lt;blockquote style=&quot;box-sizing: border-box; border-left: 6px solid rgb(97, 91, 91); padding: 0.5em 10px; color: rgb(97, 91, 91); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p style=&quot;box-sizing: border-box; display: inline; font-style: italic; margin-top: 8px;&quot;&gt;“…if a maximum pixel size isn’t specified, then the thumbnail will be the size of the full image, which probably isn’t what you want.”&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;So what happened? In short, we created a much smaller decoded image buffer than before by putting the shrinking part of equation into a thumbnail. Thinking back on our rendering pipeline, for the first part (the load) we instead passed an image buffer that represented only the size of the image view we’re showing it in instead of reflecting the entire image’s dimensions for the&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;to decode.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Want a TL;DR for this entire article? Look for opportunities to downsample images instead of using&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImage&lt;/code&gt;&amp;nbsp;to downscale them.&lt;/p&gt;&lt;h3 id=&quot;bonus-points&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Bonus Points&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;I personally use this in tandem with the&amp;nbsp;&lt;a href=&quot;https://developer.apple.com/documentation/uikit/uitableviewdatasourceprefetching?language=swift&quot; style=&quot;box-sizing: border-box; color: rgb(112, 162, 249);&quot;&gt;prefetch API&lt;/a&gt;&amp;nbsp;introduced in iOS 11. Remember that we’re inherently introducing spikes in CPU usage since we’re decoding images even if we’re doing it ahead of when the table or collection view might need our cell.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Since iOS is efficient at managing power demand when there is a constant need for it and in this case it’ll likely be intermittent, it’s good to hop on your own queue to tackle something like this. This also moves the decoding to the background, which is another significant win.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Cover your eyes, Objective-C code sample from my side project incoming:&lt;/p&gt;&lt;div class=&quot;language-swift highlighter-rouge&quot; style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;div class=&quot;highlight&quot; style=&quot;box-sizing: border-box; background: rgb(39, 40, 34); color: rgb(248, 248, 242); border-radius: 8px; overflow: auto; margin-top: 32px; margin-bottom: 32px;&quot;&gt;&lt;pre class=&quot;highlight&quot; style=&quot;box-sizing: border-box; white-space: pre-wrap; padding-left: 16px; padding-right: 16px; background-color: rgb(39, 40, 34);&quot;&gt;//&amp;nbsp;Use&amp;nbsp;your&amp;nbsp;own&amp;nbsp;queue&amp;nbsp;instead&amp;nbsp;of&amp;nbsp;a&amp;nbsp;global&amp;nbsp;async&amp;nbsp;one&amp;nbsp;to&amp;nbsp;avoid&amp;nbsp;potential&amp;nbsp;thread&amp;nbsp;explosion-&amp;nbsp;(void)tableView:(UITableView&amp;nbsp;*)tableView&amp;nbsp;prefetchRowsAtIndexPaths:(NSArray&amp;lt;NSIndexPath&amp;nbsp;*&amp;gt;&amp;nbsp;*)indexPaths{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(self.downsampledImage&amp;nbsp;!=&amp;nbsp;nil&amp;nbsp;||&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.listItem.mediaAssetData&amp;nbsp;==&amp;nbsp;nil)&amp;nbsp;return;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NSIndexPath&amp;nbsp;*mediaIndexPath&amp;nbsp;=&amp;nbsp;[NSIndexPath&amp;nbsp;indexPathForRow:0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inSection:SECTION_MEDIA];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;([indexPaths&amp;nbsp;containsObject:mediaIndexPath])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CGFloat&amp;nbsp;scale&amp;nbsp;=&amp;nbsp;tableView.traitCollection.displayScale;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CGFloat&amp;nbsp;maxPixelSize&amp;nbsp;=&amp;nbsp;(tableView.width&amp;nbsp;-&amp;nbsp;SSSpacingJumboMargin)&amp;nbsp;*&amp;nbsp;scale;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dispatch_async(self.downsampleQueue,&amp;nbsp;^{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Downsample
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.downsampledImage&amp;nbsp;=&amp;nbsp;[UIImage&amp;nbsp;downsampledImageFromData:self.listItem.mediaAssetData
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;scale:scale
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;maxPixelSize:maxPixelSize];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dispatch_async(dispatch_get_main_queue(),&amp;nbsp;^&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.listItem.downsampledMediaImage&amp;nbsp;=&amp;nbsp;self.downsampledImage;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote style=&quot;box-sizing: border-box; border-left: 6px solid rgb(97, 91, 91); padding: 0.5em 10px; color: rgb(97, 91, 91); font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p style=&quot;box-sizing: border-box; display: inline; font-style: italic; margin-top: 8px;&quot;&gt;Take care to use asset catalogs for the lion’s share of your raw image assets, since it already manages buffer sizes (and a lot more) for you already.&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;For more inspiration on how to be a first class citizen of all things memory and images, be sure to catch these particularly informative sessions from WWDC 18:&lt;/p&gt;&lt;ul style=&quot;box-sizing: border-box; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://developer.apple.com/videos/play/wwdc2018/416/?time=1074&quot; target=&quot;_blank&quot; style=&quot;box-sizing: border-box; color: rgb(112, 162, 249);&quot;&gt;iOS Memory Deep Dive&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://developer.apple.com/videos/play/wwdc2018/219/&quot; target=&quot;_blank&quot; style=&quot;box-sizing: border-box; color: rgb(112, 162, 249);&quot;&gt;Images and Graphics Best Practices&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;wrapping-up&quot; style=&quot;box-sizing: border-box; color: rgb(97, 91, 91); margin-top: 64px; font-size: 32px; line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 16px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Wrapping Up&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;You don’t know what you don’t know. And in programming, you’re basically signing up for an entire career of always running 10,000 miles an hour just to keep pace with the innovations and change. Which means… there’s going to be a mountain of APIs, frameworks, patterns or optimizations you simply weren’t aware of.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;And that can certainly be true with images. Most of the time, you initialize a&amp;nbsp;&lt;code class=&quot;highlighter-rouge&quot; style=&quot;box-sizing: border-box;&quot;&gt;UIImageView&lt;/code&gt;&amp;nbsp;with some beautiful pixels and move on. I get it, Moore’s Law and whatever. These phones are fast and have gigs of memory, and hey - we put humans on the Moon with a computer that had less than 100 kilobytes of memory.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;But dance with the devil long enough, and he’s bound to rear his horns. Don’t let jetsam pluck you from existence because a selfie took up 1 gigabyte of memory. Hopefully, this knowledge and these techniques can you save you a trip down the crash logs.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 8px; font-family: -apple-system, system-ui, &amp;quot;Segoe UI&amp;quot;, Roboto, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 21px; letter-spacing: -0.063px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Until next time ✌️.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sun, 08 Dec 2019 10:05:45 +0800</pubDate></item></channel></rss>