This profile

  • Topic: Talk to Zhu Li about finding a job and learning methods.
  • Tips: How to clear the cache of startup diagrams How to optimize the SwiftLint process.
  • Interview module: this issue analyzes a GCD deadlock problem.
  • Good blog: Organized several articles related to Swift generics.
  • Adobe Color Wheel Awesome-tips
  • Development tools: Tools for managing Github project Star: OhMyStar.

This topic

@Zhangferry: This is another editor of Fish Weekly: Zhu Li. This name we may be relatively unfamiliar, but his ID should have a lot of people have heard: Pilaf King. Zhu Li is a very experienced iOS developer. In this issue, we had some exchanges with him on the theme of workplace and learning. If you have any other questions for Takeshi, let us know in the comments section.

Zhangferry: Tell me a little about yourself.

Hello, everyone. I am Deng Zhuli from 58.com. Currently, I am mainly responsible for iOS performance optimization and stability construction in the team.

Zhangferry: You have a lot of in-depth research on binary, and you even did a live share on playing binary in the community. Why are you interested in this field? Can you give me some advice on how to learn it well?

My research on binary is far from in-depth, maybe a little bit of exploration in individual areas, but the knowledge involved in binary as a whole is too large to be in-depth. The exploration of binary was largely guided by previous technical projects. I was working on a technical project when I had a problem: “How do I dynamically call static C functions in my project?” At that time, I felt that the research direction should be Mach-O files. Finally, as the research gradually deepened, I had a certain understanding of binary files.

In fact, I don’t have any good suggestions for learning binary related content, because I don’t study this content systematically, but explore it in my spare time based on my own interests. Only when you are interested can you feel the gain in the exploration process, and this is also true in other technical directions. If you are interested in binary file parsing, 58.com will hold an online technology salon recently (the specific time has not been decided yet, it is estimated to be in October), which will mainly introduce how 58.com creates Swift mixed ecosystem within the group. I will take the opportunity of salon to introduce Swift binary parsing.

Zhangferry: As a senior developer, can you tell me what you think is the difference between senior and senior development? What do you think it takes to be a senior developer?

The definitions of senior and senior may differ from company to company. I understand that senior development is more capable than senior development of learning by analogy, or of extracting methodologies from past experience and applying them to other areas. So moving from advanced to senior may require a good understanding of multiple directions. Senior developers should think more about the company and the product, ask more whys and focus more on the afterthought, rather than just doing what the product wants. In addition, the requirements for senior development in communication skills will be higher.

Zhangferry: You have many years of experience as an interviewer, can you briefly summarize what you think is a good candidate and what qualities they should have?

Because team responsibilities may vary, there are some differences in the criteria for hiring from team to team. For example, some teams may attach more importance to the application of RN/Flutter and other technologies, while others attach more importance to the underlying technologies. However, these differences are superficial differences. The best teams focus on deeper things in candidates that may not be able to be replaced in the short term, such as the desire to explore technology, flexibility of thinking, learning ability, ability to work under pressure, responsibility, etc. As far as my team is concerned, technically, we are more concerned with whether the candidate has found the second curve of technical growth. (The second curve is from The Second Curve: Quadratic Growth across the “S-Shaped Curve”. I haven’t read the book, and the graph is similar to the model in my mind, so I quote it here.)

Or through the interview can let us see even if the candidate is still in the growth stage, but after training can have a longer term growth. Many teams recruit in one of two ways: either the candidate is good now or the candidate will be good in the future.

For some large apps with complex scenes, some problems are complicated and difficult to locate, which requires a certain technical foundation, flexible thinking, and even excellent psychological quality. You can take a look at “Work” mentioned in my 2019 year-end summary. I sorted out some problems encountered in daily work and recorded them in the summary, which is also the daily work content and requirements of 58T5 level engineers.

If you’re the boss of a team, you want your people to be able to fight tough battles, not just write about what needs to be done, but to be able to overcome tough situations at critical moments is a sign of team value. If you just look at the above requirements, brush algorithm may not be enough. Therefore, in daily work, we should develop a good habit, ask more why, do more exploration and research and reserve, do not let go of some details.

Getting back to the subject, let’s look at what is encouraged in terms of resumes and interviews:

(1) Project experience (not the apps written here) is more suitable. For example, if the team is currently focusing on package size governance, it’s a plus if you have practices in your resume that are in-depth.

(2) Refreshing technology. Some of the technologies are cutting edge or not widely known, and the candidate has in-depth research in this area. (This indicates that the candidate has found the second curve.)

(3) Experiences that demonstrate their ability to explore and specialize. Having specific events on your resume can show this to a candidate’s advantage. (Have the potential to find the second curve)

(4) Flexible thinking ability. Algorithm or site design is more perfect, consider more complete.

(5) Good pressure resistance. If you can keep calm and think in stressful interview situations without fidgeting and giving up.

(6) It can reflect good study habits. High-quality blog posts, open source code, etc are all pluses. Improvisation may not work, I generally look at content quality and release time density.

(7) Industry vision. Can pay attention to some of the industry trends, to the industry some hot technology more familiar.

(8) Honest and good communication.

(9) Sufficient willingness to join.

(10) Finally, stability, working background, education and other conditions.

Zhangferry: How to keep your enthusiasm for learning, share some of your learning methods with us.

Learning mainly needs to set a broad direction, and then in the concrete implementation of their own do some encouragement. These activities include: writing articles, sharing skills within a team, communicating with others. In the team, I always lead in the number of articles and shares, because writing articles and sharing can prompt me to reconsider and think, which is of great benefit to my growth. You will get a greater sense of accomplishment from external communication, but you need to be more cautious and try to ensure that the content you output is accurate. Once there are obvious mistakes in the content, it is not a big deal to lose your face.

Zhangferry: If you have any idea, you can publicize it with the help of fish weekly.

(1) Please pay more attention to the WBBlades open source project: github.com/wuba/WBBlad… If you feel OK, give me a star to encourage.

(2) 58 main APP, Renrenche, Home Selection and other teams are recruiting. Your resume can be sent to [email protected]. Autumn is here, and I want to make some extra money to fill some clothes.

The development of Tips

How to clear the iOS APP startup screen cache

Edited by FBY Zhan Fei

Whenever I change something in launchscreen.storyboad in my iOS app, I run into a problem:

The system caches the startup image, and even if the application is deleted, it is actually difficult to clear the original cache.

Sometimes I modify launchscreen.storyboad, delete the application and restart it, and it displays the new launchscreen.storyboad, but none of the images referenced in launchscreen.storyboad are displayed, This makes the startup screen look abnormal.

Today, I did some digging in the application’s sandbox and found that the Library folder has a folder called SplashBoard, which is where the startup screen cache is stored.

Therefore, all you need to do to completely clear the application’s startup screen cache is to run the following code inside the application (which has been extended to UIApplication) :

import UIKit

public extension  UIApplication {

    func clearLaunchScreenCache(a) {
        do {
            try FileManager.default.removeItem(atPath: NSHomeDirectory(a)+"/Library/SplashBoard")}catch {
            print("Failed to delete launch screen cache: \(error)")}}}Copy the code

During startup screen development, you can place it in the application initialization code and then disable it without modifying the startup screen.

This technique saved me a lot of time when the launch screen went wrong, and hopefully it saved you some time too.

Used to introduce

UIApplication.shared.clearLaunchScreenCache()
Copy the code
  • The cache directory mentioned in this article is shown below in the sandbox:

  • OC code, create oneUIApplicationCategory
#import <UIKit/UIKit.h>

@interface UIApplication (LaunchScreen)
- (void)clearLaunchScreenCache;
@end
  
#import "UIApplication+LaunchScreen.h"
  
@implementation UIApplication (LaunchScreen)
- (void)clearLaunchScreenCache {
    NSError *error;
    [NSFileManager.defaultManager removeItemAtPath:[NSString stringWithFormat:@"%@/Library/SplashBoard".NSHomeDirectory()] error:&error];
    if (error) {
        NSLog(@"Failed to delete launch screen cache: %@",error); }}@end
Copy the code

OC Usage

#import "UIApplication+LaunchScreen.h"

[UIApplication.sharedApplication clearLaunchScreenCache];
Copy the code

How do I clear the startup screen cache of iOS Apps

Optimized SwiftLint execution

zhangferry

SwiftLint is integrated into many Swift projects for code checking. SwiftLint execution is usually fully checked early in build and currently takes around 12s per Lint on our project. But if you think about it, it’s a waste to have code that doesn’t change being used multiple times by Lint. Git diff: Git diff: Git diff: Git diff: Git diff: Git diff: Git diff: Git diff: Git diff: Git diff With this scheme, lint stays within 2s per session.

Note that SWIFT_LINT will be replaced according to its own integration, and here’s how CocoaPods integrates:

# Run SwiftLint
START_DATE=$(date +"%s")

SWIFT_LINT="${PODS_ROOT}/SwiftLint/swiftlint"

# Run SwiftLint for given filename
run_swiftlint() {
    local filename="The ${1}"
    if [[ "${filename##*.}"= ="swift"]].then
        # ${SWIFT_LINT} autocorrect --path "${filename}"
        ${SWIFT_LINT} lint --path "${filename}"
    fi
}

if [[ -e "${SWIFT_LINT}"]].then
    echo "SwiftLint version: $(${SWIFT_LINT} version)"
    # Run for both staged and unstaged files
    git diff --name-only | while read filename; do run_swiftlint "${filename}"; done
    git diff --cached --name-only | while read filename; do run_swiftlint "${filename}"; done
else
    echo "${SWIFT_LINT} is not installed."
    exit 0
fi

END_DATE=$(date +"%s")

DIFF=$(($END_DATE - $START_DATE))
echo "SwiftLint took $(($DIFF / 60)) minutes and $(($DIFF % 60)) seconds to complete."
Copy the code

Parsing the interview

Edit: Xiao Haiteng of Normal University

This issue resolves a GCD deadlock problem.

Test1 (mainThread) test2 (mainThread)

  func test1(a) {
      DispatchQueue.main.sync { // task1
          print("1")}}func test2(a) {
      print("1")
      let queue = DispatchQueue.init(label: "thread")
      queue.async { // task1
          print("2")
          DispatchQueue.main.sync { // task3
              print("3")
              queue.sync { // task4
                  print("4")}}print("5")}print("6")
      queue.async { // task2
          print("Seven")}print("8")}Copy the code
  1. A deadlock.
    1. MainThread is currently executing test1.
    2. In this case, use sync to submit task1 to the mainQueue for synchronous execution. Task1 will not be returned until the task is completed.
    3. Due to the FIFO queue, task1 must wait for test1 to finish executing on the mainThread, which is blocked by sync, and sync must return. So test1 and Task1 wait in a loop, resulting in a deadlock.
  2. Print 1, 6, 8, 2, 3 and then deadlock.
    1. Create a serialQueue. Submitting a task to a specified queue for asynchronous execution using async returns the task directly and does not block, so print 1, 6, 8 and mainThread finishes executing test2.
    2. Retrieve task1 from serialQueue and place it into a childThread. Task2 will wait for Task1 to complete. Run task1 to print 2.
    3. Submit task3 to mainQueue using sync. Task1 is blocked and waits for task3 to complete.
    4. MainThread is not currently executing a task, so execute task3 and print 3.
    5. Next, use sync to submit task4 to serialQueue. Task3 is blocked and needs to wait for task4 to complete.
    6. ChildThread is executing task1. Therefore, Task4 needs to wait for Task1 to complete.
    7. At this point, Task1 is waiting for Task3, task3 is waiting for Task4, task4 is waiting for Task1. The loop waits, causing a deadlock.

Do not use sync to add tasks to the current serialQueue. Otherwise, the current serialQueue will be locked and deadlock will occur.

Good blog

Swift generic

1, Swift advanced: generic — from public account: Swift community

FBY: Generics are one of Swift’s most powerful features. Much of the Swift standard library is built on generic code. You can create an array of Int values, or an array of String values, or even any other type of array that Swift can create. Similarly, you can create a dictionary that stores any value of a given type, and there is no type restriction.

Swift generic analysis — from nuggets: I am xiong Da

I am Xiong: This article is an easy to understand analysis of what generics are, the application scenarios of generics, generics and other Swift features friction sparks, and finally generics are summarized.

WWDC2018 — Swift Generics — from Nuggets: Keigo Nishino

This article reviews the history of changes to generic support in Swift to learn about the history and features of different versions of generics.

Swift performance optimization (2) — Implementation of protocol and generics — from blog: Chu Quan’s World

This article discusses the basic implementation principle of protocol and generics. It involves the compiler’s performance optimization for Swift. It is highly recommended to read.

5, Swift generics underlying implementation principles – from the blog: The World of Power

@Pilaf King here: this article introduces the underlying principles related to Swift, more dry goods. For example, the function of VWT, what is Type Metadata, Metadata Pattern, etc. You can read the references below if some of the concepts are not clear.

Generics Manifesto — From Github: Apple/Swift

@Zhangferry: Siniang has translated this official note. You can also read the translated version directly: Swift Generic Manifesto. This document describes how to build a comprehensive generic system and the generic features that have been added to the Swift language over time.

Learning materials

Mimosa

Adobe Color Wheel

Address: color.adobe.com/zh/create/c…

From Adobe’s palette site, you can choose from different color schemes such as analogy, split secondary, ternary, and so on to generate color schemes. You can also import photos to extract colors, and auxiliary tools such as the contrast checker can confirm that text and patterns are previewed on the background. Alternatively, you can learn how to match colors or find inspiration through Adobe’s Explore and Trends communities.

Awesome-tips

Address: awesome – tips. Gitbook. IO/ios /

Tips for iOS development, from the Collection of knowledge, have been integrated into gitBook. Although the time is a little bit long, but the articles are relatively high quality, when you encounter problems can be read, speak may have new harvest.

Tools recommended

CoderStar

OhMyStar

Address: ohmystarapp.com/

Software status: Normal version free, Pro version charge

Software Introduction:

To quote the official introduction:

The best way to organise your GitHub Stars. Beautiful and efficient way to manage, explore and share your Github Stars.

Among them, the Pro version adds the function of synchronization between devices, but the software itself also supports the import and export of data, we choose according to their own situation.

About us

IOS Fish weekly, mainly share the experience and lessons encountered in the development process, high-quality blog, high-quality learning materials, practical development tools, etc. The weekly warehouse is here: github.com/zhangferry/… If you have a good content recommendation, you can submit it through the way of issue. You can also apply to be our resident editor to maintain the weekly. Also can pay attention to the public number: iOS growth road, backstage click into the group communication, contact us, get more content.

Phase to recommend

IOS Fishing Weekly 24th issue

IOS Fishing Weekly 23rd issue

IOS Fishing Weekly Twenty-second issue

IOS Fishing Weekly 21st issue