I've been with this problem for a couple of days and I can't find a solution. When I build the app, the code runs smoothly and looks just how I'd like it in Preview, but when I run it in the simulator, it only runs part of the code (I know, because when using breakpoints, those parts they don't run, they are skipped as if they don't exist), at first I thought it was Xcode 13.1, but now I'm using beta 13.2 and it happens exactly the same. I have been looking at forums and similar questions, even following the advice posted on them but it is beyond my understanding. The bad thing is that I don't get any error message and I don't find out why that code is skipping, if it's SwiftUI, Xcode or that I'm useless (Most likely). Thanks for your time.
Hello, well, I am going to tell you about the problem and the "solution" that I have obtained. A few days ago, because I followed one of Apple's tutorials (https://developer.apple.com/tutorials/app-dev-training/displaying-data-in-a-list), I came up with the idea of simplify my code, I wanted to create a list using cards with CHANGING INFORMATION, and to be able to add or remove data easily. Since I'm new to Swift (I've used more C and Python), I didn't know how to do it, so I followed the tutorial above. I had many problems adding the code and Xcode did not stop complaining and "screaming" 😂, once I changed the code to what you see up there more or less (things are missing and there are many others that the program does not use but, for various reasons, I have not erased 😅), and Xcode did the miracle, it did not complain, there was nothing in red and in Preview it looked just the way I wanted, my pain came, when I connected my iPhone to see the result of my work, and I found a blank app, I built it in the simulator and it also happened the same, there was nothing. I spent the next few days researching the problem, desperate, tired, and stymied, I wrote on the forum. I thank the two people who have answered me, their effort and time dedicated to my problem, I really believed that no one was going to appear and I appreciate it very much. After reading the last answer, I gave up and went back to the backup I made before changing anything, but my stubbornness didn't leave me alone and I removed all the code except a rectangle, foreach, and the data.
IN SUMMARY:
FOREACH DOES NOT ACCEPT DATA THAT CHANGES WITH TIME, YOU GIVE IT A FIXED LIST, A STRING, WITH ALREADY KNOWN DATA AND PROCESSES IT. THE PROBLEM IS THAT IF THE FOREACH FUNCTION IS DESIGNED FOR IMMUTABLE DATA IT SHOULD, AT LEAST, GIVE AN ERROR IF THE DATA IS VAR INSTEAD OF LET, XCODE YELLS AT ME AND PUTS EVERYTHING IN RED, HOWEVER IT COMPILES IT BOTH IN THE SIMULATOR AS IN PREVIEW, WITHOUT IMMUTING. AND IF IT'S A BUG AND NOT DESIGNED FOR THAT, PLEASE, PREVIEW SHOULD NOT WORK. THAT I GOT HAPPY AND THEN I CRY. 🤣🤣
Well that's it, thanks for your patience.
Good afternoon.