2015-09-27 99 views
1

我已经升级到Xcode 7,并突然出现一个目标未能建立与“宏名称必须是标识符”消息。这个目标的调试配置可以正常工作,我可以在设备上运行它,但发布配置不会生成。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 &ltUIKit/UIKit.h> 
    #import &ltFoundation/Foundation.h> 
    #import "Enums.h" 
#endif 
#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate]) 

我已经尝试过的干净和Xcode的重新启动。

我会很感激任何指针,我该如何深入挖掘并找到问题所在。

+0

我有类似的问题,它是用于枚举。你可以用enums.h的枚举来更新你的问题吗? – Miknash

+0

我删除了“Enums.h”行,仍然存在相同的问题。那应该是别的东西。我会分享“Enums.h”,但它很大。试图同时在项目的git历史中找到任何东西... –

回答

1

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

+0

这就是它!非常感谢。我不小心重新访问了Xcode中的预处理器宏,并且对于发布配置,我只设置了一个空间:TAXI(空间)= 1,它在Xcode,TAXI和= 1中创建了多个宏。因此,-D = 1。谢谢你的鹰锐利的眼睛和智慧! –

0

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

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

作为一个侧面说明,请确保你没有任何预处理器的值设置为APPAPP设置为1。要排除,请尝试使用与APP不同的变量。

相关问题