views:

549

answers:

2

I include the amalgamation sqlite code in my iPhone project, and remove the reference to the iPhone sqlite framework.

My main target compile fine.

I have a second target for unit testing with the google framework. When compile I get:

error: syntax error before '@' token

I don't understand why. I have set both projects to sdk 2.

UPDATE: I include the link to the sqlite code & google. I must add that the target compile just fine for months before I added the sqlite code. I don't post sample code because I get 1263 errors - so I get error in all files -, but this is a sample traceback:

@class NSString, Protocol; <== ERROR HERE

Traceback:

        cd /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -x c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-generated-files.hmap -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-own-target-headers.hmap -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-all-target-headers.hmap -iquote /Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/Testing-project-headers.hmap -F/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/Debug-iphonesimulator -F/Volumes/CrashReporter-1.0-rc2/CrashReporter-iPhone -F/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/Debug-iphonesimulator/include -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/usr/include/libxml2 "-I/Developer/RemObjects Software/Source" -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/DerivedSources/i386 -I/Users/trtrrtrtr/mamcx/projects/JhonSell/iPhone/build/JhonSell.build/Debug-iphonesimulator/Testing.build/DerivedSources -c /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h -o /var/folders/EA/EAmC8fuyElexZfnpnjdyr++++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/UIKit-dqqtnrciylhdtjbmyglpcezxchmz/UIKit.h.gch
    In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:120: 
error: syntax error before '@' token
+1  A: 

With very little to go on, my guess would be including an Objective C header from a C/C++ implementation file, hence compiling the header in C/C++ instead of Objective C/Objective C++.

Looking at your updated information, you are actually compiling a header file, namely UIKit.h. The compiler has no idea what type of header file it is, so it defaults to C, which of course does not have @class and hence the syntax error.

So you will have to figure out why Xcode wants to compile UIKit.h in your second target.

Peter N Lewis
ANd how I figure that? I have no clue about this error.
mamcx
+2  A: 

I finally figure out the problem.

I copy this from the iPhone target to the Testing target:

GCC_DYNAMIC_NO_PIC = NO
GCC_OPTIMIZATION_LEVEL = 0
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = JhonSell_Prefix.pch
GCC_PREPROCESSOR_DEFINITIONS = DEBUG

But why before I have not issues? I truly not understand.

mamcx
I ran into the exact same issue with my iPhone static library project. My Tests target uses GHUnit, but this does not seem to matter. Initially everything compiled fine, but after adding another static library dependency and some additional third party code, I got the same error as you.The main fix seems to be to change the Prefix Header setting from the default (mine was `$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/`) to the same as the main Target (e.g. `MyProject_Prefix.pch`).Thanks for getting me on the right track. :)
Mirko Froehlich