Thousand of errors in base classes like NSObject.h,NSObjCRuntime.h - iphone

I don't know why its happening .... I an integrating a twitpic api and its working fine all the projects except one. I am getting 5488 errors and that too in classes like NSObject.h and NSObjCRuntime.h . This api has a folder named Crypto which has two .c files in it, when i remove this folder from my project then the error decreases to 1 (because one of the class from this folder is used else where).All 5k+ errors are in these two class only, errors are like
FOUNDATION_EXPORT Class NSClassFromString(NSString *aClassName);
expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
few errors are
expected identifier or '(' before '#' token
expected identifier or '(' before '-' token
expected identifier or '(' before '+' token
One thing i am sure of is that there is no error in the classes because the same code is working good in other projects.
One more thing to mention is that I have two .pch and there is no effect of removing one of them.

compile the files as objc, not c

Usually these errors are caused by a problem in the .pch file, like an #import that doesn't belong, or something similar.

I got this error several times. This could happen because of superfluous curly bracket. Like
- (void)a {
}
}
Check latest changes in a project.

Related

iOS - expected '=', ',', ';', 'asm' or '__attribute__' before typedef [duplicate]

I'm trying to port the speakhere example into another app and I'm having issues. I copied all the files, and all the frameworks, but for some reason I get a bunch of compile errors that I've never seen before and thus don't know what to do. The only difference is that i'm not suing IB and so i had to change it slightly.
What does error: expected '=', ',', ';', 'asm' or '__attribute__' before 'foo' mean?... I get this error multiple times for different files
In my situation the first error is pointing at 'MeterTable'.. a class that includes <stdlib.h>,<stdio.h> and <math.h>. But those files seem to be importing fine (if i remove them i get more errors)
Any suggestions on how to debug this?
TIA!
EDIT:
I still can't seem to figure it out. I'm literally just copying files from the example into another project. Can someone check it out please ? SpeakHerePort.zip and the original is here SpeakHere.zip
Your problem is that you are compiling SpeakHerePortAppDelegate.m, which is an Objective C file, but it is indirectly including MeterTable.h which is a C++ header file.
Rename it to SpeakHerePortAppDelegate.mm (double m) so that it is compiled as Objective C++ and your problem is resolved.
Name all your files .mm and then all your code will be compiled as Objective C++
In my case, the .h and .m in question are built fine with regular target, and the App can run as well.
However after the subset of the files are moved under a static library target, it gets this compile error when the static library is built.
Was stuck for a while & tried the above mentioned techniques, unfortunately they didn't help in my case.
Noted that this error happened only for the NSString*, for e.g.,
extern double const kTimeout; // fine
extern NSString* const kImageType; // compile error
After the above analysis & little break, eventually the problem is resolved by adding the the following import to the .h - "Foundation/Foundation.h"
It sounds like an unfinished declaration, probably in a header file. Search for 'foo' (or whatever the symbol actually is) across all project files, using ⇧⌘F (Edit ▸ Find ▸ Find In Project...) in Xcode, and/or examine the headers you're including where MeterTable is declared. Sometimes the compiler gets confused about the actual location of the error, since header files are frequently #imported into other files, so the problem can be manifest in multiple locations.
This might not have applied to this exact situation, but I had this exact error too, which was caused by a bad forward declaration. In Objective-C, make sure your forward-declares begin with the # sign - e.g.
#class MyClass;
Those of us still on autopilot from C++ will forget the #, see that XCode has highlighted class as a reserved keyword, and think all is well with the world. It is not.
It means that you have a syntax error. If you paste the code in question, it's easier to debug.
I had a similar scenario to some of the posts above. I'd written a C++ class based off of the examples in the Audio Queue Services documentation, and had this compilation issue in a test project. This post helped a tremendous amount.
Today, I'm incorporating the C++ class in my project, and got the build error again. In my scenario, I had to also set the type (using the "Get Info" window) to sourcecode.cpp.objcpp for the objective-c class that was calling my C++ class.

Request for member which is of non-class

I've got a C++ class I want to use which has all the code in the header file, rather than the CPP file. I'm trying to call it from an objective-C file which inherits a UIViewController class. I've renamed the file to .mm and imported the header file for the C++ file. When I compile, I keep getting a compile-time error when I try and access a method from the C++ class saying Request for member '<method>' in '<objectName>' which is of non-class type '<C++ class name>'. I did a search and it seemed that the header was usually the issue, but I've included the header in my file. What else could it be? (I can include generic code if required, but the I'm not sure if I'm allowed to show the actual code since it belongs to a third party).
The problem is likely in the declaration of the object that gives you the error, not in the header file. Sometimes the problem is hard to spot, you'll have to share some code if you can't figure it out by yourself.
I'm not a C++ coder, so this was probably an obvious mistake, but if anyone else comes across a similar problem, I simply changed my code from:
myObject.method();
to
myObject->method();

iphone error when unit testing: Expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

I get the following error when I try to build (Build->build) a unit test. My unit test is a logic test (it does not run on the device).
Things that are probably related to my problem are:
I am using libxml2 and a wrapper around it (which I found at cocoawithlove).
This wrapper has some C functions defined (it is not an Objective C class with #interface and #implementation).
The function I am using (and on which the error is occuring) is
NSArray *PerformHTMLXPathQuery(NSData *document, NSString *query);
The strange thing is that all works perfectly well, when I build my application and run it in the simulator. However when I try to run my unit test, I get this error:
/Users/me/XCodeWorkspace/MyProject/XPathQuery.h:15:0 Expected '=', ',', ';', 'asm' or '__attribute__' before '*' token in /Users/me/XCodeWorkspace/MyProject/XPathQuery.h
There are some related questions here, but none of them seems to solve my problem.
In particular:
iphone error: expected '=', ',', ';', 'asm' or '__attribute__' before ' 'foo'
But here some c++ code should be included.
Thank you for help.
In my case, the .h and .m in question are built fine with regular target, and the App can run as well.
However after the subset of the files are moved under a static library target, it gets this compile error when the static library is built.
Was stuck for a while & tried the techniques from another post here, unfortunately they didn't help in my case.
Noted that this error happened only for the NSString*, for e.g.,
extern double const kTimeout; // fine
extern NSString* const kImageType; // compile error
After the above analysis & little break, eventually the problem is resolved by adding the the following import to the .h - "Foundation/Foundation.h"
Hope it helps.
Most likely the compiler is trying to compile your file as C code and not Objective-C code. It's seeing something strange like NSString, which isn't part of the C language, so it's barfing at you.
If you change the file to Objective-C or Objective-C++, it should work. (You can do this be getting info on the file and changing the source type)
After trying to change the filetype of my files (I tried several different things and none of them helped) I decided to rewrite these files as Objective-C files with methods instead of functions.
This solved my problem.

Objective-C error: expected '=', ',', ';', 'asm' or '__attribute__' before 'class'

I'm getting this from an iPhone app I'm working on. Not sure how to interpret the error... It's thrown at a few place in my code. I can't see any pattern of occurrence.
Is this a generic error? What's the meaning of it?
The error you posted indicates that you have a syntax error around your use of class. Manually inspect the first location the error is reported, and you might notice the cause.
To help you debug further, please include the surrounding code so we can better help you.
Most common causes:
Missed # in #class for forward class declaration in headers
Missed ; after the declaration of an enum, a structure, or a typedef
Copied C++ code, where class is used to declare a structure, but code is invalid in Objective-C
I've just solved this exact same problem and I have been tearing my hair out over it.
GCC wasn't highlighting the problem in the header file where the error actually occurred - I had a stray 'B' character at the bottom of a header file (from running command-B to compile). The error was then being thrown in the .m file and other .h files which included the problematic one, often at the #class statement.
If it's throwing an issue with your #class statement, the problem is almost definitely in one of the preceding header files, as you include them directly beforehand - try commenting these out one-by-one and recompiling to find out which. Once you find the culprit file, finding the actual error will be much easier.
Same as Ronan except this time I had a stray character in a source file just before I started importing headers (similarly it was an 's' for Command-S). This particularly threw me since the error message was associated with a library header file that I had never touched and the app was working fine for weeks before that. So if you are getting these errors associated with header files that appear to be fine and that you haven't touched look around for something like this.

iphone error: expected '=', ',', ';', 'asm' or '__attribute__' before ' 'foo'

I'm trying to port the speakhere example into another app and I'm having issues. I copied all the files, and all the frameworks, but for some reason I get a bunch of compile errors that I've never seen before and thus don't know what to do. The only difference is that i'm not suing IB and so i had to change it slightly.
What does error: expected '=', ',', ';', 'asm' or '__attribute__' before 'foo' mean?... I get this error multiple times for different files
In my situation the first error is pointing at 'MeterTable'.. a class that includes <stdlib.h>,<stdio.h> and <math.h>. But those files seem to be importing fine (if i remove them i get more errors)
Any suggestions on how to debug this?
TIA!
EDIT:
I still can't seem to figure it out. I'm literally just copying files from the example into another project. Can someone check it out please ? SpeakHerePort.zip and the original is here SpeakHere.zip
Your problem is that you are compiling SpeakHerePortAppDelegate.m, which is an Objective C file, but it is indirectly including MeterTable.h which is a C++ header file.
Rename it to SpeakHerePortAppDelegate.mm (double m) so that it is compiled as Objective C++ and your problem is resolved.
Name all your files .mm and then all your code will be compiled as Objective C++
In my case, the .h and .m in question are built fine with regular target, and the App can run as well.
However after the subset of the files are moved under a static library target, it gets this compile error when the static library is built.
Was stuck for a while & tried the above mentioned techniques, unfortunately they didn't help in my case.
Noted that this error happened only for the NSString*, for e.g.,
extern double const kTimeout; // fine
extern NSString* const kImageType; // compile error
After the above analysis & little break, eventually the problem is resolved by adding the the following import to the .h - "Foundation/Foundation.h"
It sounds like an unfinished declaration, probably in a header file. Search for 'foo' (or whatever the symbol actually is) across all project files, using ⇧⌘F (Edit ▸ Find ▸ Find In Project...) in Xcode, and/or examine the headers you're including where MeterTable is declared. Sometimes the compiler gets confused about the actual location of the error, since header files are frequently #imported into other files, so the problem can be manifest in multiple locations.
This might not have applied to this exact situation, but I had this exact error too, which was caused by a bad forward declaration. In Objective-C, make sure your forward-declares begin with the # sign - e.g.
#class MyClass;
Those of us still on autopilot from C++ will forget the #, see that XCode has highlighted class as a reserved keyword, and think all is well with the world. It is not.
It means that you have a syntax error. If you paste the code in question, it's easier to debug.
I had a similar scenario to some of the posts above. I'd written a C++ class based off of the examples in the Audio Queue Services documentation, and had this compilation issue in a test project. This post helped a tremendous amount.
Today, I'm incorporating the C++ class in my project, and got the build error again. In my scenario, I had to also set the type (using the "Get Info" window) to sourcecode.cpp.objcpp for the objective-c class that was calling my C++ class.