When I say other devices I mean about other Mac OS with same or different versions, Big Sur, Monterey, etc. Some it will give the error and a lot of are running ok. I will try simplify the code, using only these properties of the Config, as it is where we get the error whatever property I try to access (the actual struct have a lot of other properties):
struct STInstrumentation: Codable {
var logging: Bool = false
var isServer: Bool = false
var isVerbose: Bool = false
var isVirtualMachine: Bool = false
mutating func reset() {
self = STInstrumentation()
}
}
struct Config {
var logging = false
var isServer = false
var isVerbose = false
var isVirtualMachine = false
}
func getInstrumentation() -> STInstrumentation {
var instrumentation: Instrumentation
// while copying from the real code to here I notice that this local instrumentation isn't initialized...
instrumentation = STInstrumentation.init() // << this line is not present into my code, just put it now
// config var struct is global, but right now I am sending it as parameter
// STInstrumentation() receives more parameters, but only the config will raise the exception
// this error occurs even if before there like the example before
if config.isServer { print("wont print, it will crash") }
instrumentation = STInstrumentation(logging: config.logging, isServer: isServer: config.isServer,
isVerbose: config.isVerbose, isVirtualMachine: config.isVirtualMachine)
return instrumentation
}
var config = Config() // global config var
var Instrumentation: STInstrumentation // global Instrumentation var
Instrumentation = STInstrumentation.init()
// the information to the Config is from a SQLite, no issues here
config.logging = true
config.isServer = true
config.isVerbose = true
config.isVirtualMachine = false;
Instrumentation = getInstrumentation()
// ... from here the program continues with others stuff to do, including the use of the Instrumentation.
The terminal (this software is for terminal) will end with: zsh: trace trap /Applications/MyApplication
I still have to send to my client to him test with that init() but why it didn't crash before? By the way, the crash occurs only when trying to read the config value, this is why I modified to pass as parameter. The code you see here is such as what he has in hands now.
Thank you again and forgive me for my English too.