Build fails with "cannot find interface declaration for NSManagedObject"

993 views
Skip to first unread message

Mike

unread,
Jun 28, 2011, 8:29:26 AM6/28/11
to RestKit
Hoping someone can help me out with this.

I've followed the README instructions for Xcode 4 explicitly, but when
it comes time to build my application with Restkit included, the build
fails with the error:

"cannot find interface declaration for NSManagedObject"

The error references the file: Reskit/Code/CoreData/NSManagedObject
+ActiveRecord.h

Specifically on this line (near the top of the file):
+ (NSManagedObjectContext*)managedObjectContext;


I've triple-checked, and yes, the CoreData framework is definitely
linked to my project. I've tried rearranging the linked binaries to
make sure that CoreData is loaded first, but still get this error.

Can't seem to find anyone else having this problem in the group. Any
help or advice would be appreciated.

Blake Watters

unread,
Jun 28, 2011, 12:15:38 PM6/28/11
to res...@googlegroups.com
The first thing I would try doing is quitting and restarting Xcode, then deleting the project DerivedData folder via the organizer and trying again. We've seen hours and hours lost due to Xcode weirdness. The NSManagedObject definition should definitely be available as #import <CoreData/CoreData.h> is right above it in the header.
Blake Watters
Two Toasters | CTO

Mike

unread,
Jun 28, 2011, 5:13:38 PM6/28/11
to RestKit
Yeah Xcode 4 can be infuriating at times can't it? I can see that
CoreData is being properly imported, so this error simply doesn't make
sense.

I've tried running through a fresh installation of Restkit, and it
seems this error happens as soon as I add Restkit to the Header Search
Paths for my project.

I'm wondering if XCode is maybe mistaking the Code/CoreData.h file in
the Restkit project for the actual CoreData header? Maybe something to
do with the header search path? My knowledge of XCode 4 just isn't
strong enough yet, but that's one thought I had.

At any rate, I'll try what you suggest and post back if it works.
Thanks for the advice.
>  *Blake Watters*

Blake Watters

unread,
Jun 28, 2011, 7:22:30 PM6/28/11
to res...@googlegroups.com
If not you can send me a project and I'll triage it.
Blake Watters

Mike

unread,
Jun 29, 2011, 6:57:57 AM6/29/11
to RestKit
Thanks a ton for the offer of triage. However, I think I've got it
working now. Took a lot of trial-and-error with Xcode, but I can get
the project to build now, and instantiated my first RKClient (woot!)

Here's what I did in Xcode 4. Not sure if all of it is necessary or
not, but there's secret sauce in here somewhere:

* Quit Xcode and restart it

* Delete the Derived Data for the project

* In the Build Settings for the Project, remove Restkit-related
entries for both Library Search Paths and Header Search Paths.

* Open the Build Settings for the Target

* Under Header Search Paths, add the path to the Restkit Build
directory: "$(SOURCE_ROOT)/RestKit/Build" (or wherever the source for
Restkit is)

* The Target Dependencies, and Linked Binaries for the target remain
unchanged from those listed in the Restkit instructions.


Hopefully this is useful or instructive in some way.

Thanks again for the help.

Sal

unread,
Jun 29, 2011, 5:29:03 PM6/29/11
to RestKit
Having the same issue here none of the suggested fixes worked

I am not doing this inside an XCode workspace but have seen others
mention it.

Any other ideas?

Mike

unread,
Jun 30, 2011, 6:23:10 AM6/30/11
to RestKit
Hi Sal,

Sorry, can't give you much more insight, but I can tell you that I am
developing in an Xcode Workspace. However the Restkit project is still
a sub-project of my main one, not an external project in the same
workspace.

Also, every time I made any changes to the header, library, or user
header search paths, I found it necessary to delete the derived data
before rebuilding or else my changes didn't have any effect.

Hope this helps.

Mike

unread,
Jun 30, 2011, 7:59:23 AM6/30/11
to RestKit

Unfortunately, it seems I spoke too soon. I just rebooted my machine,
and what was a working project before has reverted to this "cannot
find interface declaration for NSManagedObject" error again.

No idea why it would work and then suddenly stop without any changes
to the project whatsoever. Definitely feels like an underlying bug in
Xcode 4.

Blake Watters

unread,
Jun 30, 2011, 8:17:10 AM6/30/11
to res...@googlegroups.com
Very frustrating.

Sal or Mike you can shoot me a project to triage if you would like. I am curious to see if it works or not on another machine.
Blake Watters

Robin Eggenkamp

unread,
Jul 4, 2011, 7:55:31 AM7/4/11
to RestKit
I had this same problem, and it seems the compiler uses the RestKit
CoreData.h instead of the Apple CoreData.h. After renaming the RestKit
CoreData.h to RKCoreData.h I can build again. As I'm not using
CoreData in this project, I'm not sure if I walk into problems later.
Hopefully this helps some of you!

Blake Watters

unread,
Jul 5, 2011, 5:01:48 PM7/5/11
to res...@googlegroups.com
Hrm. Were you pulling in #import <RestKit/CoreData.h>? That should be unambiguous and not be able to overlap with #import <CoreData/CoreData.h>
Blake Watters

Mike

unread,
Jul 6, 2011, 6:53:21 AM7/6/11
to RestKit
Robin: I had a feeling it might have had something to do with a naming
conflict with Xcode not being able to find the actual headers for
CoreData.

Blake: in the version Restkit I have, the CoreData.h file is actually
located at: Code/CoreData/CoreData.h

When I put the Restkit project and archives inside the Frameworks
group of my project, I always saw this compile error. What I've done
is just left Restkit and its archives in the root of my project and
the compile works. Makes my project tree a bit of a mess, but at least
it compiles.


On Jul 5, 11:01 pm, Blake Watters <bl...@twotoasters.com> wrote:
> Hrm. Were you pulling in #import <RestKit/CoreData.h>? That should be
> unambiguous and not be able to overlap with #import <CoreData/CoreData.h>
>

Blake Watters

unread,
Jul 6, 2011, 2:48:49 PM7/6/11
to res...@googlegroups.com
When you link against RestKit as outlined in the installation docs you are not including the files from Code/CoreData/CoreData.h into your project. The headers get copied via the Copy Headers build task and rearranged into a RestKit/ rooted layout in the DerivedData and Build/ directories. This should ensure that you are always able to #import <RestKit/*> without ambiguity.
Blake Watters

Robin Eggenkamp

unread,
Jul 7, 2011, 7:05:26 AM7/7/11
to res...@googlegroups.com
Then maybe the problem was the recursive option in the header search paths, for some reason this was checked.

Blake Watters

unread,
Jul 7, 2011, 10:23:39 AM7/7/11
to res...@googlegroups.com
That's why it says NOT to check it in the read me :-P


On Thu, Jul 7, 2011 at 7:05 AM, Robin Eggenkamp <robin.e...@m4n.nl> wrote:
Then maybe the problem was the recursive option in the header search paths, for some reason this was checked.

Robin Eggenkamp

unread,
Jul 7, 2011, 10:29:44 AM7/7/11
to res...@googlegroups.com
But only in one of the three, as I took the quick start readme it wasn't there.

Blake Watters

unread,
Jul 7, 2011, 10:31:43 AM7/7/11
to res...@googlegroups.com
Fixed! Added to the quick start


On Thu, Jul 7, 2011 at 10:29 AM, Robin Eggenkamp <robin.e...@m4n.nl> wrote:
But only in one of the three, as I took the quick start readme it wasn't there.

Reply all
Reply to author
Forward
0 new messages