I was having the same issue as the OP. The course article is not clear at all where should we test that code while working in XCode.
However, I was able to muddle forward using the suggestion from @toastedpitabread.
Disclaimer: The way I did this seems convoluted and too much work to test such a small feature, I’m new to iOS programming but not programming in general, so I’m hoping in time I’ll learn a better way to do this.
So, I created a new file called main.swift, and got that test code there:
However, since the Unit enum is inside the Ingredient struct, the provided code won’t work as is, you’ll have to replace Unit.XYZ with Ingredient.Unit.XYZ as in the picture.
After this, if you try to run the code by pressing the play button, XCode complains that we have another main entry point on the code (with good reason, we’re supposedly working on a SwiftUI app, and XCode creates this for us). So we can just comment the @main annotation on the CookcademyApp.swift file:
Finally, if we try to run this code again, the simulator starts (it won’t do anything noticeable) and the messages appear in the debug console (yay!):
NOTE: Don’t forget to undo everything (like deleting the main.swift file and uncommenting the @main annotation), otherwise your app won’t run correctly after this.
P.S. - If someone knows a better way to do this, please just say so, I would really love to know