{ tech }

  • Swift 方法桥接到 ObjC 时报 type cannot be represented

    | /

    工程里 SwiftObjective-C 混编已经是常态,经常遇到 Objective-C 代码去调用 Swift 里的方法。最新的 Swift 需要手动标注 @objc 才能把方法暴露。(印象中似乎在 Swift 2.x 的时代,是默认暴露)

    但经常会遇到 method cannot be marked @objc because the type of the parameter cannot be represented in objective-c 类似的错误,直觉为参数、返回值,无法从 Swift 桥接到 Objective-C,有时候一眼就知道缺了什么,有时候则要思考半天,这里简单整理一下几种常见的情况。

  • Swift构造函数(init)与属性观察器(didSet)

    | /

    最近工程里 SwiftObjective-C 混编的场景越来越多了,大家在编写 Swift 代码时,一般都会用 didSet 来作为 Objective-Csetter 的替代。但最近遇到好几起(自己和其他同事)因为 Swiftinit 里对属性赋值没有触发 didSet,进而导致结果不符合预期的问题,看来还是对 Swift 使用不熟练,这里稍微汇总下。(另外,末尾会附上 ChatGPT3.5 的回答情况)

  • How to Check If Color String Valid

    | /

    We have a project based on ReactNative. Recently, we encountered a problem, that is, when the operation colleague configured the color value, one was missing, and only five were allocated, which led to page confusion and JS errors.

    In addition to increasing restrictions on the configuration platform, we have also taken some inspection measures in the project.

    The problem is, how to check if the color string is valid using JS.

  • Why Should Take "What's New" Seriously

    | /

    For personal APP, it may pay more attention to the writing of “What’s New” to attract more users to download and upgrade.

    If you work for a large company, the content source might be a product manager or operations.

    So how to write What’s New better? We often see some novel serialization or small humor, which is very interesting.

    But in any case, I advise everyone to show your artistic talents on the basis of writing real and updated content.

    Because we have been rejected for violating the "Performance - Accurate Metadata" clause.

  • Why State update doesn't work

    | /

    Recently, some personal apps have begun to try to use SwiftUI.

    Although some simple layouts, SwiftUI is indeed very efficient in development. But in actual development, many problems will be encountered.

    1. The development concept is different from UIKit, which leads to unaccustomed.
    2. Some components only have UIKit and need to be encapsulated.
    3. There will be compatibility issues with different versions of Xcode and operating systems.
    4. Sometimes some writing methods lead to actual effects that do not meet expectations.
    5. And so on.

    I have encountered a situation where the State change does not take effect, and it is also possible that my usage is not completely correct.

  • Quick Fix For Can't add self as subview

    | /

    I believe you can always find a lot of this kind of Crash: Can't add self as subview.

    We also know that we will never write code like add self as subview.

    In fact, in most cases, the push and pop pages with animation and no animation occur at the same time.

    Because we all know that this is often caused by the complexity of the page hierarchy and the unpredictable page jumps. So often choose to shelve this Crash helplessly.

    But we always think about how to eliminate this Crash. Whether it is from the perspective of user experience or from the aspect of Crash rate management.

  • Quickly build VPN from VPS

    | /

    We use VPNs a lot these days, both on a business and personal level.

    As a company, in order to facilitate employees to work remotely, they often provide VPNs based on commercial companies such as Cisco. As an individual, for convenience, most scenarios may also choose a mature third-party VPN provider.

    But sometimes we may already have our own VPS, or a third-party VPN cannot meet our demands in some aspects. At this time, it is also a common choice to build a VPN based on VPS. Of course, there are also many people who simply feel that they are happier with their own hands. XD

  • Extension Version Mismatch

    | /

    When we need to intercept the pushed information and customize the display, we need to use the extension capabilities provided by Apple. It means that our project will become a multi-target project.

    At this time, we may encounter the problem of version mismatch.