Post

Replies

Boosts

Views

Activity

Reply to Newbie and getting a error with struct data access
Print the config is all there, no issues! > Config(logging: false, isServer: false, isVerbose: false, isVirtualMachine: false, isVip: false, endpoint: "gateway.xxxx.com", endpoint_scheme: "https", endpoint_path: "/api/receiver", endpoint_port: 5500, isApple: true) I just sent another binary now instead of try: if config.isVirtualMachine { print("config.isVirtualMachine") } which crash here - this line is an attempt to the client help me to debug, i create a new global var configisVirtualMachine: Bool = false and I am setting its value and gonna try to use it instead of the config property value.. I am getting out of options here :(
Nov ’22
Reply to Newbie and getting a error with struct data access
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.
Nov ’22
Reply to Newbie and getting a error with struct data access
Hi Claude, thanks a lot for the reply!!! I already had tried that way you show, without the constructor, simply: var config = Config() Same thing! So I moved to the implicit init construct. Well in my code I have a function that output to another struct (Instrumentation) such: func getInstrumentation() -> Instrumentation { var instrumentation: STInstrumentation /* do some simple stuff here like declare other vars ... put the need values to function and one of that information is, eg., isVirtualMachine, but this data comes from the Config .... so it will crash right here whatever use/call it do >>> */ if config.isVirtualMachine { do something } // will crash here if this is the 1st line instrumentation.isVirtualMachine = config.isVirtualMachine // **this is the actual line in my code where it crashes:(** } That "if config" is just an example, the real code uses the line below, the only way I had to search for this error was doing that, as in my computer it won't raise any error and I cant make remote debug (I don't even know if Swift does that). I am telling that line crashes but any attempt to read any of the config properties will make it fail. EDIT: I made a change and sent to the client to him a try (waiting for the answer), I change the function declaration to func getInstrumentation(configInformation: STConfig) -> STInstrumentation and now I am passing the config as parameter. Hope it can fix. Anyway fixed or not I really can't understand why with some devices it works.
Nov ’22