7
votes

I have a Swift - ObjectiveC/C++ project, everything worked fine, until I added CoreData, now every time I modify something, it throws an error:

/.../DerivedData/.../Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/-Swift.h:136:26: Cannot find interface declaration for 'NSManagedObject', superclass of ''; did you mean 'NSManagedObjectModel'?

and

/.../DerivedData/.../Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/-Swift.h:136:26: Attempting to use the forward class 'NSManagedObjectModel' as superclass of ''

Of course, is not the real problem, I already tried to delete everything on DerivedData, and the problem persists.

The fix, is adding in the headers of the -Swift.h file, #import , and then the errors are gone. Until I modify my code.

Anyone knows a real solution for this? its kind of annoying to have to include that lib every time I compile.

Xcode version is: Version 6.3.2 (6D2105)

Edit: The problem occurs in the *-Swift.h file, which is created by Xcode...

Edit2: I had to rewrite an entire class to avoid using ObjectiveC (Except for third party libraries) and the problem is gone, so I think its related to how ObjectiveC tries to handle Swift-based core data classes.

Now I don't have the problem, but could help someone someday

1
Did you find a solution/setting other then re-writing the entire project? as I am also facing the same issue. In my case, I did not created custom classes, rather used the auto generated NSManagedObjectModel. - Jay
No, except for my edited answer inside the question. It still might be related to dependencies... :/ - pojomx

1 Answers

0
votes

That basically means that you need to import the Coredata

#import <CoreData/CoreData.h>