UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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

3      

hi,

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,

DMG

3      

@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:

3      

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. :-)

3      

Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.