I'm using xcode 16 with swift. I'm trying to call a function in another file. It used to work. Now I'm getting: Cannot find 'detailline' in scope. Detailline is the function I'm calling. I just added variables to the top. I have since deleted them. Please help.
Cannot find 'detailline' in scope
Thanks for the post.
The error "Cannot find 'x' in scope" in Swift typically occurs when the compiler cannot find the declared function you are trying to call. There could be a few reasons for this error, especially after adding and deleting variables.
Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.
Albert Pascual Worldwide Developer Relations.
Thank you. I'll try to create a test project. What are the few reasons it could be?
I got a test project. I don't know how to send a link. Can you help me? Thanks
Is it file/share Email a link I think I need your email.
Did you forget about me?
No one forgot you. But without the code it was just impossible to give an answer.
Now, you've got the answer in the other thread. With the code, it was obvious to find the error. text1 was used in a function that was outside the scope where text1 was declared.
Don't forget to close this thread as well.
I created the test project. Do you want me to send the link?
Should I mail the link to the test project.
I think I solved this one. I just want to make sure I got it right. I put the function right on top of #Preview. No brackets after the function and before #Preview. No errors. Does that sound right?