I had written a function below which is inside Framework A:
open func invokeTracking(key: String, bundle: Bundle? = Bundle.main) {
let qos = DispatchQoS.QoSClass.default
DispatchQueue.global(qos: qos).async {
self.invokeAsyncTracking(key: String, bundle: bundle)
}
And I am calling this in an Xcode project in multiple places and also from other frameworks.
In Xcode project:
override func viewDidLoad() {
super.viewDidLoad()
HelperClass.invokeTracking(key: "Camino", bundle: Bundle? = Bundle.main)
}
Similarly calling it from Framework B
func callMainTracking() {
super.viewDidLoad()
HelperClass.invokeTracking(key: "Carthage", bundle: Bundle? = Bundle.main)
}
This is working fine and has worked for almost a year. Recently I added another additional default parameter to the invoke tracking method like this so as not to affect the existing method calls like below. And I am trying to set the value of this parameter of a global variable:
open func invokeTracking(key: String, bundle: Bundle? = Bundle.main, conventDict: [String: Any] = [:]) {
mainDict = conventDict
let qos = DispatchQoS.QoSClass.default
DispatchQueue.global(qos: qos).async {
self.invokeAsyncTracking(key: String, bundle: bundle)
}
The app is crashing in the main thread on the line mainDict = conventDict
when trying to access that default parameter. If I do it inside the async its crashing in that async thread. But this crash is happening only when it's called from Framework B and not when its called from the Xcode project. Also this crash is happening only on the device.
I have tried the following to resolve this:
- Tried to declare default parameter as optional and using if let to unwrap it.
- Tried with different data types.
- Tried by changing arguments order.
And the only way it does not crash is if I send a value for this default parameter from Framework B while calling this method.
func callMainTracking() {
super.viewDidLoad()
HelperClass.invokeTracking(key: "Carthage", bundle: Bundle? = Bundle.main, conventDict: ["test": "123"])
}
But this defeats the purpose of a usage of a default parameter. Im new to debugging Xcode crashes so any help would be appreciated.
I used the Instruments and tried to find a Zombie but there wasnt one. The app simply just crashed and no zombie process was detected.