Looks good on xcode 13.2
Post
Replies
Boosts
Views
Activity
I also encountered a similar infinite loop on a swizzling method which replaces viewDidAppear to augment additional logging stuff, and it works well until I built the project with Xcode 12 beta 6 on an iOS14 simulator(iPhone 11 pro max).
My project is built with swift UI for demo.
Looks like it only causes problems on a project with SwiftUI on iOS14
Say that we have 1. an ContentView for our swiftUI project 2. an abc_viewDidAppear swizzled function for viewDidAppear which calls abc_viewDidAppear(should be the original viewDidAppear impl after swizzling) inside itself
(void)abc_viewDidAppear:(BOOL)animated {
	if (meet some conditions) {
		/* do some logging stuff	*/
[self abc_viewDidAppear:animated];
		/* do some logging stuff */
} else {
		/* do nothing but call the original viewDidAppear which was swizzled */
[self abc_viewDidAppear:animated];
}
}
When I tracked when my abc_viewDidAppear gets called:
Before iOS14
called by ContentView(actually something like 1234SwiftUI00UIHostingControllerV11Demo22ContentView) -> call the original viewDidAppear
iOS14
called by ContentView -> call the original viewDidAppear
called by an internal swift ui component - ViewList.View?(also a UIViewController) 1234SwiftUI00UIHostingControllerVS14ViewListView_ => this causes an infinite loop by calling abc_viewDidAppear -> abc_viewDidAppear is mine instead of the original viewDidAppear after swizzling