Old driver iOS weekly, just for you to present valuable information.

You can also contribute to the project, if you find valuable information, articles, tools, etc., please send it to us in Issues, we will deal with it as soon as possible. Be sure to include a reason for your recommendation. Suggestions and comments are also welcome to Issues.

WWDC 18 is coming up this week, and we’ll be writing WWDC features on the Nuggets, and the weekly will be closed for a week.

news

Apple Silently Launched Creative Testing in App Store Search Ads

Apple has quietly released Creative Testing for search ads in the App Store. Mobile developers can now test different search ads in the App Store. While this isn’t the A/B test many expected, it gives advertisers more power, and this article explains how to use this new feature in detail.

column

🌟 🐢 Delve into Decodable – Write a JSON parser that goes beyond native

The old driver iOS column of the latest article, take you into Decodable, the article is divided into two parts, the first part of the Decoder abstract, analysis of the native JSONDecoder part of the implementation, the second part with you to define a JSONDecoder, and for native deficiencies, Do some targeted optimization, so that custom Decoder has stronger performance and expansion.

The article

🌟 🐢 Google Swift Style Guide

This is a very practical style guide. It provides a comprehensive and detailed introduction to the specifications and, in some cases, explains why they were chosen. Even if you don’t end up using the specification, it’s useful to see what a specification covers.

Linkedin’s Swift Style Guide is also a relatively complete style guide.

🌟 🐢 Getting started with Core ML: Build a simple image recognition application

Translated from Sai Kambampati’s blog by SwiftGG Translation Team. The article teaches you step by step how to implement a CoreML based image recognizer, and especially thoughtful is that the author provides a series of Demo projects, so that readers can skip some of the preparation steps, improve the efficiency of learning. The full Demo project can be found on Github.

🐢 How to implement automatic App download in App Store

If the App Store is open source, follow these steps to implement automatic downloads, which I’m sure will be easy for most developers:

  1. Enter the App Store and switch TAB to the search screen
  2. Set the search keyword and search
  3. After entering the list page, click App to enter the details page and click Download
  4. Follow the prompts to complete login and download, and jump to the Recommendation Tab after downloading
  5. After entering the recommendation Tab, log out

Unfortunately, the App Store is not open source. This article uses reverse technology to find the API required for the above steps and implements automatic download. It is a good training project for reverse beginners.

🐎 Black Apple Installation Academy

Since Apple uses Intel processors, OS X can be hacked and installed on machines with Intel cpus and some AMD cpus. The result was a whole bunch of non-Apple devices that used Apple’s operating system, known as hacktocks. This repository collects various models of black apple installation methods. We all know that black apple is actually a potentially pirated activity because it violates Apple’s EULA (EULA). So this Github repository is just to install black Apple as a lead, and then introduce and share knowledge about Apple operating system and some of the system installation methods.

🐎 This is the correct way to manage WKWebview cookies

At present, most teams deal with WKWebView cookies in this way: before webView initiates a load URL request each time, the client plugs the cookies into the request head and passes them to the server, and synchronizes the cookies to the front end through JS injection.

In this paper, a new scheme is proposed: when the URL is loaded for the first time, a cookie WebView is preloaded, and the cookie is written to the shared WKProcessPool of the cookie WebView by js injection. Cookie synchronization is implemented when WKWebView is officially loaded.

🐎 Why I built my App with Texture (and you should too)

The author explains how Texture was created, how it compares to UIKit, and how the two frames work in several scenarios, such as stackView, tableView list inversion, etc., thanks to the Flexbox layout. Asynchronous rendering and so on make Texture work better than UIKit in these scenarios.

🐢 RunLoop source code read

Most iOS resumes now say “Understand RunLoop” but only half-understand when asked. RunLoop: RunLoop: RunLoop: RunLoop

  • Why RunLoop?
  • How to make a Thread have only one RunLoop(Thread-specific data)
  • CFRunLoopDoObservers
  • How to make threads sleep and wake up when idle (mach_msg)

🐢 The use of GCD in iOS App causes the lag problem

According to our common cognition, dispatch_async is highly efficient and will not be stuck. Peak found a stuck stack may be related to Dispatch_async in the actual project, and then used TSI to seek technical support from Apple. Explain why dispatch_async sometimes gets stuck through the question and answer format.

🐢 Efficient data compression coding method Protobuf

This article will help readers understand the basic usage and main features of Protocol Buffers, the latest version of Protocol Buffers, and explain the codec process of Protocol buffers. It is a very detailed introduction of Protocol buffers. By reading this article, the reader can understand the following points:

  • The Protocol Buffer uses varint to compress data, and binary data is very compact. Option is also a measure to compress the volume. Therefore, PB has a smaller volume. If it is used for network data transmission, it is bound to consume less network traffic with the same data. But it is not compressed to the limit. Float, double float are not compressed.
  • The Protocol Buffer has fewer {,}, and: symbols than JSON and XML, and is smaller in size. Plus varint compression, gzip compression is even smaller!
  • The Protocol Buffer implements tag-value (tag-length-value) encoding, reducing the use of delimiters and making data storage more compact.
  • Another core value of the Protocol Buffer is that it provides a set of tools, a compilation tool that automates the generation of GET /set code. It simplifies the complexity of multi-language interaction and makes coding and decoding work productive.
  • The Protocol Buffer is not self-describing and the binary data stream cannot be understood without the data description.proto file. This is the advantage, so that the data has a certain “encryption”, is also a disadvantage, data readability is very poor. So Protocol buffers are great for MAKING RPC calls and passing data between internal services.
  • The Protocol Buffer is backward compatible. After updating the data structure, the old version can still be compatible. This is also the problem that the Protocol Buffer was designed to solve at the beginning. The compiler skips new fields if it doesn’t know anything else.

Further reading

Protocol Buffer is used in iOS

Set_allocated_xxx clears mines in Protobuf

Protobuf3 advanced series

Protobuf RPC framework for application practices: Google gRPC

Jot down practice Protobuf experience sharing

🐕 iOS-factor

12-Factor is a well-known collection of methodologies for software as a service (SaaS) applications. Ios-factor took inspiration from this project and refined its methodology for iOS development. This paper expounds this methodology. There are currently eight categories: dependency management, configuration, development and online equivalency, deployment, local preference over remote, backward compatible apis, version numbers, and persistent data.

🐢 Static linking vs dyld3

Optimizing app startup time is an essential part of app development. Allegro’s development engineers summarized their practice of reducing startup time through static link optimization. And encountered the following problems:

  • Xcode8 does not support Swift static linking
  • How to solve the problem of resource file management after static link
  • How to solve the problem of a static library being referenced by multiple libraries

In the second part of the article, Allegro’s developer describes how he used DyLD3 to get around the system’s limitations, and compared the startup speed of DyLD2, DyLD3, and static link using hot and cold startup modes.

🐕 Unnecessary HTTP headers

The authors counted 30 of the most common HTTP headers, many of which are not necessarily used. Examples include Server, X-powered-by, and Via, which have no use but serve as annotations. P3P, Expires, X-frame-options, X-UA-compatible that have a real effect, but aren’t the best way to achieve that effect. X-aspnet-version, x-cache, which is not recognized by any browser outside the standard. Some of the more useful headers are rarely used on websites, such as Content-security-policy and strict-transport-Security for Security, and Link rel=preload for performance.

🐕 Writing self-documenting Swift code

We should make our code and the apis we design as easy to understand as possible, break down complex methods, use unambiguous apis, and create new types or aliases for identifiers. Writing self-explanatory code allows us to focus our comments on architectural design rather than implementation details that often change.

tool

Crunch

PNG image lossless compression tool, provides three convenient ways to use: The CLI, GUI and right click services are based on Google’s Zopfli algorithm like most other compression tools, but Crunch dynamically adjusts compression parameters for different images to achieve the best compression results.

Plus, if you don’t have high compression requirements, but want a versatile CLI compression tool, Leanify is a good choice. It supports compression in more than 20 file formats.

code

KTVVideoProcess

KTVVideoProcess is a video processing framework of Chanbar open Source. The overall design inspiration (Source -> Filter Pipeline -> Output) refers to GPUImage, but it claims to provide higher performance than GPUImage. After a brief communication with the author, we know that the core improvement is the addition of concurrent capability. GPUImage only has a video process queue to execute filter sequentially, without squeezing CPU/GPU performance to the maximum. For the scene of video processing, we need to apply the same set of filter to each frame. If the filter processing time is too long, the frame will be lost. KTVVideoProcess realizes the mechanism of processing multiple frames in parallel for this scenario, which better solves the problem of losing frames in extreme cases.

Is it best to write a completely new framework to improve the performance of the serial filter queue? I have my reservations about that. In general, multi-filter performance problems can be solved by combining filters and optimizing shader algorithm.

After a preliminary look, the current completion degree is not high, the built-in Filter is still relatively few, and there is a lack of common basic Filter such as TwoInputFilter. If it is used, there will inevitably be many scenes that need to be completed by handwriting shader. However, the code of the framework is simple and clear. If you want to learn the internal implementation of GPUImage, you can consider learning from this framework.

The unofficial WWDC app for macOS

The Unofficial WWDC app for macOS, a third-party WWDC app, has been updated to include support for features like iCloud synchronization, Touch Bar and calendar integration. The app is completely open source, and you can check it out on the GitHub project page.

Audio and video

🚧 WWDC 97

WWDC 97 session was released on CD and posted on YouTube. The friend that has nostalgic plot can see.

Recommend two videos:

  • Closing Keynote – Steve Jobs Fireside Chat

    Joe’s chat with the developers, expounded his thinking on technology products, software, charm is still the same.

  • Session 500 – Apple Hardware Roadmap

    According to Apple’s hardware roadmap, Phil Schiller looked exactly the same 20 years ago as he does now. And the now-absent Jonathan Ive (32 minutes).

push

Shenzhen Toutiao R & D center sincerely invites all iOS masters to work together to please their own projects

Pay attention to our

We have opened an official account, which will push messages when each issue is released. Welcome to follow it.

RSS feeds are also supported: github.com/SwiftOldDri… .

The current editor

@No story Zhuo, @Siniang, @Mmoaay, @Xiangerxiansen, @DamonWong, @Msg, @Zhang Jiafu, @Aidenrao, @Parsifal, @Aaaron7, @Fang Qiulong, KYO, TOM510230

instructions

🚧 indicates the need to climb the wall, and 🌟 indicates the editor’s recommendation

Estimated reading time: 🐎 in a short time (1-10 mins); 🐕 medium (10-20 mins); 🐢 slow (20+ mins)