Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move files in Xcode without causing "Cannot find 'FileName' in Scope"?

Tags:

xcode

I want to make my project more organized, so I created new groups and dragged files into those groups. I am doing all of this in Xcode, not finder or terminal. However, now, Xcode shows "Cannot find 'FileName' in Scope" errors next to references to classes in those files.

How do I solve this problem?

I tried building the project and cleaning the build folder.

like image 254
PerfectFiasco Avatar asked Nov 17 '20 02:11

PerfectFiasco


1 Answers

I ran into the same issue today with Xcode 12.2 and an iOS 14.2 project. I created a file for a new struct, wrote some code in ViewController that created instances of the struct, and then for housecleaning I moved the struct's .swift file. At that point I saw the error "Cannot find [type] in scope."

Product | Clean Build Folder didn't do the trick.

Closing and reopening Xcode worked for me.

I'm not sure if the initial clean helped or not.

There are more detailed answers here, and your particular case may be covered: SwiftUI 2.0 CoreData issues with new project - 'Cannot find type 'Item' in scope'

like image 142
Rethunk Avatar answered Nov 14 '22 13:11

Rethunk