LAST CHANCE: Save 50% on all my Swift books and bundles! >>

7 compiler errors in working code!

Forums > SwiftUI

I am working through the "Bookworm" chapter in HWS SwiftUI edition - it's using SwiftUI and Core Data.

What I don't understand is that if I select a simulator and tell Xcode to run the app, it builds cleanly, launches the simulator and then runs the app. The app works just fine.

However, shortly after the app starts running, 7 build errors appear in the code! The app meanwhile continues to run perfectly OK! I can't understand how it builds with no errors, runs and then produces errors after launch. Link to screen shot provided.

I have created the Student entity in Bookworm.xcdatamodeld as specified by Paul in the chapter using the id and name attributes.

If I close the app after adding students, close the app, then terminate it in Xcode and re-run it then all student names I had added are retreived. Clearly the app is working fine - but 7 errors!

Weirdly, it's happy with Student.entity(), but complains about Student in the following line of the screenshot. Errors



the link to your screenshot did not come through ... but i have seen this type of problem with projects using Core Data. i think it has to do with what XCode really remembers about the Core Data files it generated for a CD Entity (Swift class).

the recommendation seems to be: do a Clean Build Folder (hold down the option key to do a "really thorough" clean), then quit XCode. starting over again often clears the problem.

if the problem persists, please mention the version of XCode. i have seen this in XCode as late as 11.6 (i think), but i do not have enough experience with Code 12 beta 4 to know if it happens there.

hope that helps,



@BlackTablet, just an FYI...

If you change the dl=0 at the end of a Dropbox link to raw=1 then the image will show up inline on your posts.

Like so:


Thanks to both of you.

@delawaremathguy - I had tried a clean build several times but no luck. Quit and went to bed! Today, opened the project and back came the errors. Did a clean build folder and the errors remained. Then I did a build and they all cleared. I then ran the app and no errors, it launched and everything this time has been fine.

I think you're right and XCode is getting itself confused I don't know if this is because it's the Beta or whether this kind of thing happens with Core Data as I've never used it before.

Thank you for your help.

@roosterboy - great tip which works beautifully as you can see. Thank you very much - that's getting filed in my notebook. :-)


Hacking with Swift is sponsored by Essential Developer.

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.