I get an infinite loop with Swift when calling super.viewDidLoad () in two nested subclasses

I am working on an iOS application written in Swift. I have a subclass of UITabBarController and then a nested subclass:

class HWTabBarController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() ... } } class MainTabBarController: HWTabBarController { override func viewDidLoad() { super.viewDidLoad() ... } } 

This works fine in the iOS simulator, and even when I debug the application on my iPhone. But it crashes when I archive the application and send it to my phone using TestFlight.

My crash logs populate with this endless loop:

 22 HDWR 0x00145e10 @objc HDWR.MainTabBarController.viewDidLoad (HDWR.MainTabBarController)() -> () (MainTabBarController.swift:16) 23 HDWR 0x00262867 NRMA__voidParamHandler 24 HDWR 0x0014ea00 HDWR.HWTabBarController.viewDidLoad (HDWR.HWTabBarController)() -> () (HWTabBarController.swift:24) 25 HDWR 0x00145e10 @objc HDWR.MainTabBarController.viewDidLoad (HDWR.MainTabBarController)() -> () (MainTabBarController.swift:16) 26 HDWR 0x00262867 NRMA__voidParamHandler 27 HDWR 0x0014ea00 HDWR.HWTabBarController.viewDidLoad (HDWR.HWTabBarController)() -> () (HWTabBarController.swift:24) 28 HDWR 0x00145e10 @objc HDWR.MainTabBarController.viewDidLoad (HDWR.MainTabBarController)() -> () (MainTabBarController.swift:16) 29 HDWR 0x00262867 NRMA__voidParamHandler 30 HDWR 0x0014ea00 HDWR.HWTabBarController.viewDidLoad (HDWR.HWTabBarController)() -> () (HWTabBarController.swift:24) 31 HDWR 0x00145e10 @objc HDWR.MainTabBarController.viewDidLoad (HDWR.MainTabBarController)() -> () (MainTabBarController.swift:16) 32 HDWR 0x00262867 NRMA__voidParamHandler 33 HDWR 0x0014ea00 HDWR.HWTabBarController.viewDidLoad (HDWR.HWTabBarController)() -> () (HWTabBarController.swift:24) 

What is the voidParamHandler and why did it return to MainTabBarController.viewDidLoad ?

Am I doing something wrong here? Or is this a bug in Swift?

+5
source share
3 answers

Are you using a new relic in your application? (I guess from all of these NRMA__voidParamHandler links that you have.) I had this exact problem. I disabled the new relic SDK and the files downloaded from Testflight stopped crashing. I have not reported a bug yet, but you / I / we probably should.

+5
source

with the addition of a quick search for all the nice dynamic functions of objective-c. To bring this functionality back, you need to add the “dynamic” declaration flag to all methods that use the New Relic tools.

Like this:

 class HWTabBarController: UITabBarController { override dynamic func viewDidLoad() { super.viewDidLoad() ... } } class MainTabBarController: HWTabBarController { override dynamic func viewDidLoad() { super.viewDidLoad() ... } } 

More on which features include here: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/getting-started/enabling-swift-interaction-traces

+5
source

I just downloaded the repo, signed it in my profile, and everything seemed to work the way you programmed it. There is no endless loop, no glitches. This is also through a test flight. It makes me think that you have some errors somewhere in your system. I suggest doing a few things ...

  • Clearing build cmd + alt + shift + k && & uninstalling the application on your phone.
  • Closing Xcode and then deleting the received data. (If you have not already done so, before I can expand on how to do this.)
  • Register it as a new application on a test flight, if necessary.

My idea is that this will help when you delete your derived data, but I would do all this so that you know that everything is clean. Again, I did not encounter this problem at any stage: simulator, direct installation from Xcode or downloading via test flight.

Also make sure that the packet identifier is registered correctly, and that everything is fine on the server side in the test flight. I can’t imagine why this will cause a loop, but this is a strange situation, so let's see what happens .: ^)

0
source

Source: https://habr.com/ru/post/1206919/


All Articles