Recently, the new version submitted by App was rejected due to crash review. Please record the process of solving the problem.

1. Try to reproduce

The apple email said that there was a crash on iOS15.1 iPad devices, with several crashlog-xxx. TXT files attached. Usually, Apple will attach a screenshot of the corresponding page. This time, there is only a.txt file, so it may be that the crash happened after the App was installed and opened. First let’s try to reproduce it, and if we can reproduce it, that’s easy. The results can’t be repeated… That can only be solved by parsing the.txt file.

2. Parse the file

Most of the methods found on the web are resolved by using Xcode’s symbolicatecrash tool. Later, I found that you can directly open Xcode to locate the specific code. First change the.txt file suffix to.crash, right mouse select Xcode to open

Then select the corresponding project

Open it and go directly to the code in question

3. Solve problems

Once the code is located, the next task is to solve it. This code logic is to add a timestamp at the end of the network request UA to determine whether the request is valid and prevent crawlers. SecItemDelete((__bridge CFDictionaryRef)publicKey); In this case, a search for iOS15.1 SecItemDelete crash does not yield useful information. First of all, it is not 100% sure that the crash was caused by this logic, but the backend students told this logic that the backend was not enabled yet, so they annotated this code and submitted it for review.

The next day, the new version approved, as expected is the problem of this code logic. But what’s the problem?

4. Track your source

In the process of researching, an article that caught my attention called “Solving inexplicably Logged out apps on iOS 15” said that starting with iOS 15, the system might decide to “warm up” your APP before the user actually tries to open it, This may increase the probability that protected data will be accessed when you think it should be unavailable. To verify, change the code logic and commit a new version again.

internal func uaToken(a) -> String {
    if UIApplication.shared.isProtectedDataAvailable {
        let key = "xxxx"
        let time = ("\(Date().timeIntervalSince1970 * 1000)" as NSString).integerValue
        return RSA.encryptString("\(time)", publicKey: key)
    } else {
        return ""}}Copy the code

The second day also passed the audit, finally solved the problem.