Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

ios - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...