"Cannot find (...) in scope"

Hello! I am a new to programming and developing and I have a question: I tried using Xcode and copied my code from Playgrounds into my Xcode Project. But now it says 50 times "Cannot find (...) in scope." In Playgrounds my code worked. What am I doing wrong? Thank you very much!

Accepted Reply

You should show the code !

Please give at least an example where the error shows. Maybe you forgot some import ? Or you have a var declared out of scope ?

But hard to say without code.

  • I attached it to the post.

Add a Comment

Replies

You should show the code !

Please give at least an example where the error shows. Maybe you forgot some import ? Or you have a var declared out of scope ?

But hard to say without code.

  • I attached it to the post.

Add a Comment

Playgrounds and an actual project are different in syntax. Specifically when you're going to a view controller which you are if you're working in contentView. A view uses SwiftUI which is what you see and interact with (an interface) and classes use Swift. The code for these two are not interchangeable which is why you're getting this error. If you have any questions or specific examples of your code that's getting an error just reply to this response.

  • I attached an image to the post.

Add a Comment

This is the "Choose your story" learning App on Playgrounds. I removed all code from the new Xcode file and copied this in there. Here is the code! Thank you all!