我在我的iPhone项目中包含了amalgamation sqlite代码,并删除了对iPhone sqlite框架的引用。
我的主要目标编译好。
我有第二个使用google framework进行单元测试的目标。编译时我得到:
错误:'@'令牌之前的语法错误
我不明白为什么。我已将两个项目都设置为sdk 2.
更新:我包含了sqlite代码的链接&谷歌。我必须补充说,在我添加sqlite代码之前,目标编译好几个月。我没有发布示例代码,因为我收到1263错误 - 所以我在所有文件中都出错 - 但这是一个示例回溯:
@class NSString, Protocol; <== ERROR HERE
回溯:
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
答案 0 :(得分:2)
我终于弄明白了这个问题。
我将其从iPhone目标复制到测试目标:
GCC_DYNAMIC_NO_PIC = NO
GCC_OPTIMIZATION_LEVEL = 0
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = JhonSell_Prefix.pch
GCC_PREPROCESSOR_DEFINITIONS = DEBUG
但为什么在我没有问题之前呢?我真的不明白。
答案 1 :(得分:1)
很少继续下去,我的猜测是包含来自C / C ++实现文件的Objective C头,因此用C / C ++而不是Objective C / Objective C ++编译头文件。
查看更新后的信息,实际上是在编译头文件,即UIKit.h。编译器不知道它是什么类型的头文件,所以默认为C,当然没有@class,因此语法错误。
所以你必须弄清楚为什么Xcode想要在你的第二个目标中编译 UIKit.h。
答案 2 :(得分:0)
您的gcc
命令行正在将.h
文件编译为.gch
文件。
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0
# ...
-x c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs # ...
# ...
# THE INPUT FILE:
/Developer/Platforms/iPhoneSimulator.platform/Developer/
SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Framework/
UIKit.framework/Headers/UIKit.h
# THE OUTPUT FILE:
-o /var/folders/EA/EAmC8fuyElexZfnpnjdyr++++TI/
-Caches-/com.apple.Xcode.501/
SharedPrecompiledHeaders/UIKit-dqqtnrciylhdtjbmyglpcezxchmz/UIKit.h.gch
即。 UIKit.h
转换为UIKit.h.gch
:将头文件转换为“预编译”标头,可以更快地包含,因为它是标记化形式。
看起来编译器不知道它应该预编译一个头;它以某种方式配置错误,只是将其视为实际编译的代码,并因为代码是Objective C而窒息。