extension UIApplication {
override open var next: UIResponder? {
print("next")
return super.next
}
}
The above code was executed before iOS 13.4, and "next
" is printed before the application(_:, didFinishLaunchingWithOptions:)
method
On iOS 13.4 and the latest iOS 13.4.1, the console does not output next
. If I break the breakpoint on the print()
line, the breakpoint will not be executed
This caused some of my previous code to fail, for example:
import UIKit
public extension UIApplication {
private static let runOnce: Void = {
NothingToSeeHere.harmlessFunction()
}()
override var next: UIResponder? {
// Called before applicationDidFinishLaunching
UIApplication.runOnce
return super.next
}
}
public protocol SelfAware: class {
static func awake()
}
public class NothingToSeeHere {
public static func harmlessFunction() {
let typeCount = Int(objc_getClassList(nil, 0))
let types = UnsafeMutablePointer<AnyClass>.allocate(capacity: typeCount)
let autoreleasingTypes = AutoreleasingUnsafeMutablePointer<AnyClass>(types)
objc_getClassList(autoreleasingTypes, Int32(typeCount))
for index in 0 ..< typeCount {
(types[index] as? SelfAware.Type)?.awake()
}
types.deallocate()
}
}
Why does this happen? Is this a bug in iOS 13.4? Still a feature? I didn't find anything related in the release notes for iOS 13.4 ...
Let me list the situation I tested:
- 13.2 iPhone,
next
method execution, and beforeapplication(_:, didFinishLaunchingWithOptions:)
. - 13.3 Simulator,
next
method execution, and beforeapplication(_:, didFinishLaunchingWithOptions:)
. - 13.4 Simulator,
next
method is not executed. - 13.4 iPhone,
next
method is not executed. - 13.4.1 iPhone,
next
method is not executed.