IOS Fishing weekly, mainly to share the experience and lessons encountered in the development process and learning content. Although it is a weekly newspaper, the current way of contributing content has not been stable. If there is less than one issue of subsequent content, it may be postponed to the next week. So I hope you can share your own development tips and bug solving experiences.

The weekly warehouse is here: github.com/zhangferry/… , you can see README to learn how to contribute. Also can pay attention to the public number: iOS growth road, backstage click into the group communication, contact us.

The development of Tips

Development tips included.

Github’s warehouse operation requires token verification

Today, when I accessed Github using an old repository, I received a Deprecation Notice saying that login based on username and password will no longer be supported. The official Notice can be found here.

Currently, there are two ways to access github repositories: username, password and Token.

The username and password is used to access the Git repository using HTTPS.

Token refers to SSH, OAuth, and GitHub App.

Github will no longer accept user names and passwords after August 13, 2021. Affected processes include:

  • Command line access
  • Desktop Application access (Github Desktop is not affected)
  • Other apps or services use user names and passwords to access Github directly

Conditions not affected:

  • The account has dual authentication and SSH access
  • Using GitHub Enterprise Server, no GitHub change notification was received.
  • Other Github apps that do not support user name and password access

Configuration Entitlements

Entitlements is an authorization file used to configure entitlements as to whether an operation is allowed. This file is automatically generated when we add a Capability, and its entity is a plist file that records the added Capability. Packaging Entitlements are placed within the Code Signature section of the MachO file, and the system determines the permissions of the current application based on the values here.

Usually a Target can only have a Entitlements, when if we want to correspond to different bundleId according to different configuration, perhaps due to some restrictions, permissions between them different abilities, then need them to have different entitlements.

We can Copy the original authorization file, rename, and then configure Entitlements in Build Setting > Signing > Code Signing Entitlements just new Entitlements file.

would clobber existing tag

This error is reported when a remote tag is pulled, meaning that the remote tag conflicts with the local tag. The solution is to find the conflicting local tag and delete it.

You can compare git ls-remote -t with git tag -l, or delete the local repository and pull it again.

The Bug

Differences between Swift and OC blocks

Recommended source: Weiminghuaa

Bug phenomenon

When a native interacts with a web, applets, a flutter, etc., it is the method name and data that are passed to the native, so it is often necessary to write a method forward function using performSelector. In OC, it’s okay to pass a block, it’s not okay for Swift, it might blink back at performSelector, it might blink back where the block is executed

The solution

Swift converts the clourse displayed by Swift to an OC block before calling performSelector to pass a parameter

let block : @convention(block) (Any.Bool) - > ()= callback
Copy the code

Stackoverflow.com/questions/2…

Bug explain

The knowledge point is too wide, difficult to understand.

1. At the beginning, I was completely at a loss

2. Under the advice of my friends in the developer group, I wrote the DEMO of OC and SWIFT respectively to confirm that oc was ok and SWIFT had problems

Swift closure and OC block are both closures, but they are different languages and should be implemented in different ways. In most cases, the closure will be implemented in different languages. There is no copy, and the closure is simply destroyed at the end of the function

4. Try to understand the underside of a block and the difference between a closure and a block, and finally find a way to display the transformation

Programming concepts

What is the VPS

VPS is short for Virtual Private Server (Virtual Private Server). It can divide a physical Server into multiple Virtual dedicated servers. Each Virtual Server is isolated from each other and has its own operating system, disk space, and IP address. The VPS is used like a real physical server and can be customized according to user preferences.

Cloud servers are similar to VPS in that they are often used interchangeably, but there are differences. Cloud server is the upgrade to VPS, it is no longer limited to the multiple virtual servers but was isolated from a server, on more advanced clustering technology, independent virtual server on a set of server, each server in the cluster has a mirror of your cloud server, so the cloud server can guarantee the security and stability of the virtual server. But if it’s VPS, the host you’re using goes down and your VPS becomes inaccessible.

What is the Ajax

Ajax, which stands for Asynchronous Javascript And XML, is a technical solution for improving the interactivity of Web application technologies.

Ajax enables asynchronous (without blocking user interaction) data transfer between the browser and the server, and local updates to the content when the data is returned to the browser (the page is not refreshed). This has the benefit of improving responsiveness to user actions without sending unwanted information.

The first well-known Ajax application was Gmail.

Utf-8 is what

Utf-8 (8-bit Unicode Transformation Format) is a Unicode encoding. Unicode is an ISO code that contains all characters and symbols in the world. It stipulates that all characters are represented by two bytes. In this way, it can contain all the characters in the world, but for English characters with only low bytes, it also uses two bytes to represent them. In fact, it causes a certain amount of space waste, so utF-8 encoding form is created. It is dynamic and uses 1-4 characters to represent Unicode encoding content. English characters account for one byte, which is the same as ASCII characters, and Chinese characters account for three bytes.

Utf-8 encoding rules are summarized as follows:

Unicode symbol scope | utf-8 encoding (hexadecimal) | (binary) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0000, 0000-0000, 007 f | 0xxxxxxx 0000 0080-0000 07FF | 110xxxxx 10xxxxxx 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxxCopy the code

Again, the difference between Unicode and UTF-8 is that the former is a character set and the latter is an encoding rule.

Utf-8 is widely used. It is the official recommended encoding in Cocoa programming environments, and utF-8 is used 95% of the time on the web.

The other two encoding rules utF-16 and UTF-32 have minimum lengths of 16 and 32 bits, respectively, which also cause a bit of byte waste, so they are not as widely used as UTF-8.

What is reactive

Reactive Programming is an asynchronous programming paradigm that focuses on data flow and change delivery. The difference between object-oriented and process-oriented programming paradigms is that reactive programming raises the level of abstraction in code, so you can focus only on the interdependent events that define the business logic, rather than getting bogged down in a lot of implementation details.

Many languages have responsive implementation frameworks, OC: ReactiveCocoa, Swift: RxSwift/Combine, JavaScript: RxJS, Java: RxJava

The key to responsiveness is this:

Data flow: Anything can be considered a data flow, a network request, a Click event, user input, variables, etc.

Change transfer: The above data flows alone or in combination produce changes that affect other flows, namely change transfer.

Asynchronous programming: non-blocking, data flows do not interfere with each other.

Example application: Assume a scenario with a timer, pause the timer when the user closes the page and goes back to the background, start the timer when the application comes back to the foreground, and have a place to display the timer time. Here is the code logic implemented with RxSwift:

What is the Catalyst

Background: For a long time in the Apple ecosystem, mobile and PC apps were not universal, and developers had to write code twice and design two SETS of UI before they could create apps for each platform. As a result, iOS apps are flourishing, while macOS apps are miserable.

Mac Catalyst is a solution to this problem. Apple announced it at WWDC in 2011. It allows developers to port iPad apps to macOS, and later iOS apps. The significance of it is that we can develop macOS applications directly using UIKit. SMS and maps on BigSur have been rewritten using Mac Catalyst. Write once, Run Anywhere is apple’s ultimate goal.

Mac Catalyst has been integrated into Xcode (version 11.0 and later). Go to the Platform selection box and select the Mac option. Catalyst is only available on Catalina and later versions.

What is a DSL

The opposite of a DSL is the GPL, which is not an open source license as we know it, but General Purpose Language, which is a General programming Language. The familiar objective-C, Swift, Python, C, and so on.

A DSL is a computer language designed specifically to solve a particular kind of task, and to be efficient in a particular domain by making compromises in expressiveness.

DSLS include external DSLS and internal DSLS. External DSLS include Regex, SQL, HTML&CSS

Internal DSLS include: project configuration built on Ruby, syntax in Podfile, Gemfile, and Fastfile files

Reference: DraVENESS. Me/DSL /

Good blog

1. I quit — from the Nuggets: Obin

Aobing also recorded a video in station B, watching the video may be more infectious.

2. My toy — Lego Rubik’s Cube robot — from Xelz’s Blog

It’s really interesting. It’s cool to have a science and engineering mind and do something concrete and interesting. The general idea is this;

  • The phone connects to the LEGO via Bluetooth
  • LEGO detects the cube and notifies the phone to start scanning
  • After scanning one face, the phone tells LEGO to flip the cube to the next face
  • After the scan is complete, the phone starts calculating the restore steps
  • The phone sends the formula back to the LEGO via Bluetooth
  • LEGO restores the Rubik’s Cube according to the formula

That’s all you need to know about Bitcode — xelz’s Blog

4. Optimization of the first screen opening in seconds of The Hello Travel iOS App — from the official account: Hello Technology team

5, SwiftUI: Interpolation in Text — from the official number: Old Driver Technology Weekly

6, in-depth understanding of MachO data parsing rules — from the public account: iOS growth road

7, MacBook upgrade SSD disk refers to the north — from the public account: iOS growth road

8. Preliminary study of DWARF documents — Extraction of lightweight symbol table — from public account: King Pilaf is here

Learning materials

Can Balkaya

Can Balkaya is a student Challenge winner at WWDC20 and currently writes a column on Medium, often with high quality posts about Swift features. I saw someone translate some of the articles in other places, indicating that it still has some attention, if English is a little better you can directly subscribe to this column.

Tools recommended

Good tools are recommended.

Cleaner for Xcode

Recommended source: Zhangferry

Address: github.com/waylybaye/X…

Software Status: Free open source version, $0.99 AppStore version

Used to introduce

This application can help you remove legacy and obsolete files, which can greatly save disk space. You can do this monthly or weekly.

JSONExport

Pears blossom in spring

Address: github.com/Ahmed-Ali/J…

Software status: Free, open source

Used to introduce

Support JSON files directly exported to the Model type used in development. Support for Java, Objective-C, Swift and other language data models.

For some CoreData and Realm specific formats can also be fully adapted.

Contact us

The third issue of Fishing Weekly

Fishing Weekly Issue 4

The fifth issue of Fishing Week

Fishing Weekly Issue 6

The seventh issue of Fishing Week