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

BetterRest autogenerated model class doesn't work after rename (edit: answered)

Forums > SwiftUI

I'm on Project 4 BetterRest of SwiftUI. I changed the name of BetterRest 1.mlmodel to SleepCalculator as shown. I am able to see the class as shown. However, the app won't run as I'm getting a "Use of unresolved identifier 'SleepCalculator' error. I know from past attempts to learning code that renaming classes generally leads to finding where that class was "auto-generated" and changing the code there, since Rename really does not rename everywhere.

I have retyped the code, built the app, etc. Nothing's working... And now changing back to BetterRest_1.mlmodel also doesn't work.

Any ideas?

EDIT: Will leave this up, in case it happens to anyone else. I had to close the project and reopen it. Somehow that made the class "take." XCode shenanigans...

5      

I had the same issue. I closed and re-opened the project as you suggested and now it sees the SleepCalculator() class. Thanks!

2      

My thanks to both of you. Hit the same problem, and the solution works for me too.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out 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.