Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown type name 'NSError' and others

I'm not exactly a noob but I completley feel like one right now.

I took an existing working app of mine. One that works under Xcode 5 and now works under Xcode 6. It compiles fine and runs. I started a new project in Xcode 6 and started to rebuild a new app shell using the structure of my working app. Moving over all of my standard libraries in it that I use in every app. I've done this several times under Xcode 5 with no problems.

But now when I build I'm getting a lot of errors in a specific library (TBXML), but I don't get any of those errors on my other working project even though it has the same library. If I take those files out (so it's not compiling them) there are no errors and the app launches fine.

I'm not even including the library yet. Same errors if I do or don't. But they are listed under Compile Sources and so they're compiling.

The errors are things like: ....blah..../TBXML/TBXML-Headers/TBXML.h:124:49: Unknown type name 'NSError'

on the line:

typedef void (^TBXMLFailureBlock)(TBXML *tbxml, NSError *error);

....blah..../TBXML/TBXML-Headers/TBXML.h:126:71: Unknown type name 'NSString'

on the line:

typedef void (^TBXMLIterateAttributeBlock)(TBXMLAttribute *attribute, NSString *attributeName, NSString *attributeValue);

....blah..../TBXML/TBXML-Headers/TBXML.h:133:20: Cannot find interface declaration for 'NSObject', superclass of 'TBXML'

on the line:

@interface TBXML : NSObject {

Items to check off the list:

  1. I do have all the proper frameworks including Foundation.
  2. no compiler flags for these files - which matches the old project.
  3. Build for and Target iOS is the same on both projects.
  4. I'm not looking for "don't use TBXML" as it works fine as is in the other project.

I'm assuming that it is some difference in project settings as my old project was created under Xcode 5 and this one under Xcode 6. But I've looked everywhere I know to look.

* UPDATE *

This seems to fix it: TBXML in an iOS 8 extension fails to build

I would like to know why though. The question is still out there. Why would one project need the #include and the other one not? The main difference is that one was created under Xcode 5 and the other under Xcode 6. But both projects are now in Xcode 6.

like image 546
badweasel Avatar asked Sep 13 '14 22:09

badweasel


1 Answers

Prefix Headers!!!

Thanks Hot Licks - you lead me to the answer. In my old project I had this:

Xcode Build Settings

And in the new project I didn't. The contents of that file are:

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

So basically every file had Foundation and UIKit included. So on the new project there were times when these were needed and not included. Perhaps apple read this: http://qualitycoding.org/precompiled-headers/

like image 159
badweasel Avatar answered Oct 25 '22 14:10

badweasel