未知的类型名称'NSError'和其他 [英] Unknown type name 'NSError' and others

查看:121
本文介绍了未知的类型名称'NSError'和其他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个菜鸟,但我现在感觉像是一个。



我带了我现有的工作应用程序。一个在Xcode 5下工作,现在可以在Xcode 6下工作。它可以很好地编译并运行。我在Xcode 6中开始了一个新项目,并开始使用我的工作应用程序的结构重建一个新的应用程序shell。移动我在每个应用程序中使用的所有标准库。我已经在Xcode 5下完成了几次没有问题。



但是现在当我构建时,我在特定库(TBXML)中遇到了很多错误,但即使它有相同的库,我也没有在我的其他工作项目中得到任何错误。如果我取出这些文件(因此它没有编译它们)没有错误,应用程序启动正常。



我甚至没有包括库。如果我做或不做,也会出现相同的错误。但它们列在编译源下,因此它们正在编译。



错误类似于:
.... blah .... / TBXML /TBXML-Headers/TBXML.h:124:49:未知类型名称'NSError'



就行:

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

.... blah .... / TBXML / TBXML-Headers / TBXML.h:126 :71:未知类型名称'NSString'



就行:

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

.... blah .... / TBXML / TBXML-Headers / TBXML.h:133 :20:找不到'NSObject'的接口声明,超级类'TBXML'



就行了:

  @interface TBXML:NSObject {

要检查的项目list:


  1. 我确实拥有所有适当的框架,包括Foundation。

  2. 这些没有编译器标志文件 - 与旧项目相匹配。

  3. Build for和Target iOS在两个项目中是相同的。

  4. 我不是在寻找不要不使用TBXML,因为它在其他项目中运行良好。

我假设它在项目中有一些差异设置,因为我的旧项目是在Xcode 5下创建的,而这是在Xcode 6下创建的。但是我看到了我知道要查找的所有地方。



* UPDATE *



这似乎解决了这个问题:


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.

解决方案

Prefix Headers!!!

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

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/

这篇关于未知的类型名称'NSError'和其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆