Xcode 7 - 宏名称必须是标识符

时间:2015-09-27 11:44:03

标签: ios objective-c xcode

我已升级到Xcode 7,突然我的目标之一无法使用"宏名称必须是标识符"信息。这个目标的调试配置构建正常,我可以在设备上运行它,但是发布配置不构建。

错误指向目标的.pch文件,但同样的.pch文件对许多其他目标(包括发布的目标)构建正常。

以下是错误消息:

ProcessPCH /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.pch speedometer/speedometer-Prefix.pch normal armv7 c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/stanislavdvoychenko/Documents/code/speedo
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c-header -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -gmodules -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCOCOAPODS=1 -DCOCOAPODS=1 -DTAXI -D=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -fstrict-aliasing -Wdeprecated-declarations -miphoneos-version-min=7.0 -g -fvisibility=hidden -Wno-sign-conversion -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/taximeter.hmap -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Products/Release-iphoneos/include -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public/GoogleMaps -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources/armv7 -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources -F/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Products/Release-iphoneos -F/Users/stanislavdvoychenko/Documents/code/speedo/Pods/GoogleMaps/Frameworks -F/Users/stanislavdvoychenko/Documents/code/speedo -DNS_BLOCK_ASSERTIONS=1 -isystem /Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -isystem /Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public/GoogleMaps -MD -MT dependencies -MF /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.d -c /Users/stanislavdvoychenko/Documents/code/speedo/speedometer/speedometer-Prefix.pch -o /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.pch --serialize-diagnostics /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.dia

In file included from :334:
:4:10: error: macro name must be an identifier
#define  1
         ^
1 error generated.

这是.pch文件:

#import 

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import "Enums.h"
#endif
#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])

我已经尝试过清理并重新启动Xcode。

如果我能深入挖掘并找出问题所在,我会感激不尽。

2 个答案:

答案 0 :(得分:5)

问题在于编译命令中的-D=1命令行选项。您在构建设置中的某处可能存在错误值,可能是在预处理器宏或其他C标志中。

答案 1 :(得分:0)

您在.pch文件中显示的内容看起来不错;它正确编译给我。但是,编译器抱怨下面的代码没有为宏指定名称。 #define必须后跟宏名称,而在您的语句中则缺少。您能否在代码库中搜索#define 1语句并进行更正。

In file included from :334:
:4:10: error: macro name must be an identifier
#define  1

作为旁注,请确保您没有为设置为APP的{​​{1}} APP设置任何预处理器值。要排除,请尝试使用与1不同的变量。