Member-only story
SwiftUI SceneDelegate: Cannot find ‘ContentView’ in scope.
Creating all new folders group, from the project folder, and copying all files over, next delete all olds folders, and click (Clean Build Folder) from Xcode / Product.
Relaunched the project, it worked!
When those simple annoyances are too frustrating! Yes we have all been there and I was really hoping that Apple would have fixed what is obviously a bug.
Historically I have found Core Data annoying to work with… so for a while now I have been managing the database using Realm. However, with Realm now significantly bloating (553MB) and the Realm Browser app on OSX no longer usable, it was time to visit my old friend. With open arms it tripped me up straight away. I had deleted the cursory Item entity and added a new entity named Person. With that change I was greeted with Cannot find ‘Person’ in scope. As I had deleted Item, even if I added that back in to the code correctly the error was Cannot find ‘Item’ in scope.
This is what worked for me:
- I needed to give Xcode a good clean.
- Clean build folder (shift + command + k)
- Close Xcode completely
- Delete ‘DerivedData’ content (/Library/Developer/Xcode/DerivedData)
- Open Xcode and your project again
- Try to build and run it again
- Deleting derived data
- Run the following command to delete the contents of your DerivedData directory, replacing {your-name}: rm -rf /Users/{your-name}/Library/Developer/Xcode/DerivedData/*
I hope this helps you with this problem! If you want to learn more about SwiftUI, please check out our YouTube channel for other dope SwiftUI tutorials. Also make sure you keep yourself up to date with our upcoming tutorials on Instagram
Thank you for reading this content.